aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers
diff options
context:
space:
mode:
authorPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>2006-02-24 16:03:57 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-02-24 17:31:37 -0500
commitf462e8f913bdc7a28ce55508d0c045a0c445b157 (patch)
treece584e748f632d90307d3c2cd62294f3b209c903 /arch/um/drivers
parentdc1561ac019ff7b6f75c5175abd2ec65c8dbd581 (diff)
[PATCH] uml: better error reporting for read_output
Do precise error handling: print precise error messages, distinguishing short reads and read errors. This functions fails frequently enough for me so I bothered doing this fix. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Acked-by: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/drivers')
-rw-r--r--arch/um/drivers/net_user.c34
1 files changed, 22 insertions, 12 deletions
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)