aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/drivers')
-rw-r--r--arch/um/drivers/cow.h2
-rw-r--r--arch/um/drivers/cow_sys.h6
-rw-r--r--arch/um/drivers/cow_user.c24
-rw-r--r--arch/um/drivers/net_user.c34
-rw-r--r--arch/um/drivers/ubd_kern.c2
5 files changed, 41 insertions, 27 deletions
diff --git a/arch/um/drivers/cow.h b/arch/um/drivers/cow.h
index dc36b222100b..04e3958266e0 100644
--- a/arch/um/drivers/cow.h
+++ b/arch/um/drivers/cow.h
@@ -46,7 +46,7 @@ extern int file_reader(__u64 offset, char *buf, int len, void *arg);
46extern int read_cow_header(int (*reader)(__u64, char *, int, void *), 46extern int read_cow_header(int (*reader)(__u64, char *, int, void *),
47 void *arg, __u32 *version_out, 47 void *arg, __u32 *version_out,
48 char **backing_file_out, time_t *mtime_out, 48 char **backing_file_out, time_t *mtime_out,
49 unsigned long long *size_out, int *sectorsize_out, 49 __u64 *size_out, int *sectorsize_out,
50 __u32 *align_out, int *bitmap_offset_out); 50 __u32 *align_out, int *bitmap_offset_out);
51 51
52extern int write_cow_header(char *cow_file, int fd, char *backing_file, 52extern int write_cow_header(char *cow_file, int fd, char *backing_file,
diff --git a/arch/um/drivers/cow_sys.h b/arch/um/drivers/cow_sys.h
index c83fc5d68936..94de4ead4f7a 100644
--- a/arch/um/drivers/cow_sys.h
+++ b/arch/um/drivers/cow_sys.h
@@ -23,17 +23,17 @@ static inline char *cow_strdup(char *str)
23 return(uml_strdup(str)); 23 return(uml_strdup(str));
24} 24}
25 25
26static inline int cow_seek_file(int fd, unsigned long long offset) 26static inline int cow_seek_file(int fd, __u64 offset)
27{ 27{
28 return(os_seek_file(fd, offset)); 28 return(os_seek_file(fd, offset));
29} 29}
30 30
31static inline int cow_file_size(char *file, unsigned long long *size_out) 31static inline int cow_file_size(char *file, __u64 *size_out)
32{ 32{
33 return(os_file_size(file, size_out)); 33 return(os_file_size(file, size_out));
34} 34}
35 35
36static inline int cow_write_file(int fd, char *buf, int size) 36static inline int cow_write_file(int fd, void *buf, int size)
37{ 37{
38 return(os_write_file(fd, buf, size)); 38 return(os_write_file(fd, buf, size));
39} 39}
diff --git a/arch/um/drivers/cow_user.c b/arch/um/drivers/cow_user.c
index fbe2217db5dd..61951b721268 100644
--- a/arch/um/drivers/cow_user.c
+++ b/arch/um/drivers/cow_user.c
@@ -176,7 +176,7 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
176 err = -ENOMEM; 176 err = -ENOMEM;
177 header = cow_malloc(sizeof(*header)); 177 header = cow_malloc(sizeof(*header));
178 if(header == NULL){ 178 if(header == NULL){
179 cow_printf("Failed to allocate COW V3 header\n"); 179 cow_printf("write_cow_header - failed to allocate COW V3 header\n");
180 goto out; 180 goto out;
181 } 181 }
182 header->magic = htonl(COW_MAGIC); 182 header->magic = htonl(COW_MAGIC);
@@ -196,15 +196,17 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
196 196
197 err = os_file_modtime(header->backing_file, &modtime); 197 err = os_file_modtime(header->backing_file, &modtime);
198 if(err < 0){ 198 if(err < 0){
199 cow_printf("Backing file '%s' mtime request failed, " 199 cow_printf("write_cow_header - backing file '%s' mtime "
200 "err = %d\n", header->backing_file, -err); 200 "request failed, err = %d\n", header->backing_file,
201 -err);
201 goto out_free; 202 goto out_free;
202 } 203 }
203 204
204 err = cow_file_size(header->backing_file, size); 205 err = cow_file_size(header->backing_file, size);
205 if(err < 0){ 206 if(err < 0){
206 cow_printf("Couldn't get size of backing file '%s', " 207 cow_printf("write_cow_header - couldn't get size of "
207 "err = %d\n", header->backing_file, -err); 208 "backing file '%s', err = %d\n",
209 header->backing_file, -err);
208 goto out_free; 210 goto out_free;
209 } 211 }
210 212
@@ -214,10 +216,11 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
214 header->alignment = htonl(alignment); 216 header->alignment = htonl(alignment);
215 header->cow_format = COW_BITMAP; 217 header->cow_format = COW_BITMAP;
216 218
217 err = os_write_file(fd, header, sizeof(*header)); 219 err = cow_write_file(fd, header, sizeof(*header));
218 if(err != sizeof(*header)){ 220 if(err != sizeof(*header)){
219 cow_printf("Write of header to new COW file '%s' failed, " 221 cow_printf("write_cow_header - write of header to "
220 "err = %d\n", cow_file, -err); 222 "new COW file '%s' failed, err = %d\n", cow_file,
223 -err);
221 goto out_free; 224 goto out_free;
222 } 225 }
223 err = 0; 226 err = 0;
@@ -299,7 +302,7 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
299 } 302 }
300 else if(version == 3){ 303 else if(version == 3){
301 if(n < sizeof(header->v3)){ 304 if(n < sizeof(header->v3)){
302 cow_printf("read_cow_header - failed to read V2 " 305 cow_printf("read_cow_header - failed to read V3 "
303 "header\n"); 306 "header\n");
304 goto out; 307 goto out;
305 } 308 }
@@ -359,7 +362,8 @@ int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize,
359 if(err != sizeof(zero)){ 362 if(err != sizeof(zero)){
360 cow_printf("Write of bitmap to new COW file '%s' failed, " 363 cow_printf("Write of bitmap to new COW file '%s' failed, "
361 "err = %d\n", cow_file, -err); 364 "err = %d\n", cow_file, -err);
362 err = -EINVAL; 365 if (err >= 0)
366 err = -EINVAL;
363 goto out; 367 goto out;
364 } 368 }
365 369
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c
index 098fa65981ab..0e2f06187ea7 100644
--- a/arch/um/drivers/net_user.c
+++ b/arch/um/drivers/net_user.c
@@ -47,10 +47,12 @@ void tap_check_ips(char *gate_addr, unsigned char *eth_addr)
47 } 47 }
48} 48}
49 49
50/* Do reliable error handling as this fails frequently enough. */
50void read_output(int fd, char *output, int len) 51void read_output(int fd, char *output, int len)
51{ 52{
52 int remain, n, actual; 53 int remain, ret, expected;
53 char c; 54 char c;
55 char *str;
54 56
55 if(output == NULL){ 57 if(output == NULL){
56 output = &c; 58 output = &c;
@@ -58,23 +60,31 @@ void read_output(int fd, char *output, int len)
58 } 60 }
59 61
60 *output = '\0'; 62 *output = '\0';
61 n = os_read_file(fd, &remain, sizeof(remain)); 63 ret = os_read_file(fd, &remain, sizeof(remain));
62 if(n != sizeof(remain)){ 64
63 printk("read_output - read of length failed, err = %d\n", -n); 65 if (ret != sizeof(remain)) {
64 return; 66 expected = sizeof(remain);
67 str = "length";
68 goto err;
65 } 69 }
66 70
67 while(remain != 0){ 71 while(remain != 0){
68 n = (remain < len) ? remain : len; 72 expected = (remain < len) ? remain : len;
69 actual = os_read_file(fd, output, n); 73 ret = os_read_file(fd, output, expected);
70 if(actual != n){ 74 if (ret != expected) {
71 printk("read_output - read of data failed, " 75 str = "data";
72 "err = %d\n", -actual); 76 goto err;
73 return;
74 } 77 }
75 remain -= actual; 78 remain -= ret;
76 } 79 }
80
77 return; 81 return;
82
83err:
84 if (ret < 0)
85 printk("read_output - read of %s failed, errno = %d\n", str, -ret);
86 else
87 printk("read_output - read of %s failed, read only %d of %d bytes\n", str, ret, expected);
78} 88}
79 89
80int net_read(int fd, void *buf, int len) 90int net_read(int fd, void *buf, int len)
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 101efd26d467..fa617e0719ab 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1135,7 +1135,7 @@ static int path_requires_switch(char *from_cmdline, char *from_cow, char *cow)
1135static int backing_file_mismatch(char *file, __u64 size, time_t mtime) 1135static int backing_file_mismatch(char *file, __u64 size, time_t mtime)
1136{ 1136{
1137 unsigned long modtime; 1137 unsigned long modtime;
1138 long long actual; 1138 unsigned long long actual;
1139 int err; 1139 int err;
1140 1140
1141 err = os_file_modtime(file, &modtime); 1141 err = os_file_modtime(file, &modtime);