diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-05-06 17:51:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-07 15:13:03 -0400 |
commit | a61f334fd2864b9b040f7e882726426ed7e8a317 (patch) | |
tree | 51874236a1f324a2664118f54aadd9ba3beb95ca /arch/um/os-Linux/sigio.c | |
parent | ef0470c053274c343b2be8737e0146d65e17f9be (diff) |
uml: convert libc layer to call read and write
This patch converts calls in the os layer to os_{read,write}_file to calls
directly to libc read() and write() where it is clear that the I/O buffer is
in the kernel.
We can do that here instead of calling os_{read,write}_file_k since we are in
libc code and can call libc directly.
With the change in the calls, error handling needs to be changed to refer to
errno directly rather than the return value of the call.
CATCH_EINTR wrappers were also added where needed.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/os-Linux/sigio.c')
-rw-r--r-- | arch/um/os-Linux/sigio.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/arch/um/os-Linux/sigio.c b/arch/um/os-Linux/sigio.c index 8ccf6a36f1c6..8d4e0c6b8c92 100644 --- a/arch/um/os-Linux/sigio.c +++ b/arch/um/os-Linux/sigio.c | |||
@@ -69,11 +69,12 @@ static int write_sigio_thread(void *unused) | |||
69 | p = &fds->poll[i]; | 69 | p = &fds->poll[i]; |
70 | if(p->revents == 0) continue; | 70 | if(p->revents == 0) continue; |
71 | if(p->fd == sigio_private[1]){ | 71 | if(p->fd == sigio_private[1]){ |
72 | n = os_read_file(sigio_private[1], &c, sizeof(c)); | 72 | CATCH_EINTR(n = read(sigio_private[1], &c, |
73 | sizeof(c))); | ||
73 | if(n != sizeof(c)) | 74 | if(n != sizeof(c)) |
74 | printk("write_sigio_thread : " | 75 | printk("write_sigio_thread : " |
75 | "read on socket failed, " | 76 | "read on socket failed, " |
76 | "err = %d\n", -n); | 77 | "err = %d\n", errno); |
77 | tmp = current_poll; | 78 | tmp = current_poll; |
78 | current_poll = next_poll; | 79 | current_poll = next_poll; |
79 | next_poll = tmp; | 80 | next_poll = tmp; |
@@ -86,10 +87,10 @@ static int write_sigio_thread(void *unused) | |||
86 | (fds->used - i) * sizeof(*fds->poll)); | 87 | (fds->used - i) * sizeof(*fds->poll)); |
87 | } | 88 | } |
88 | 89 | ||
89 | n = os_write_file(respond_fd, &c, sizeof(c)); | 90 | CATCH_EINTR(n = write(respond_fd, &c, sizeof(c))); |
90 | if(n != sizeof(c)) | 91 | if(n != sizeof(c)) |
91 | printk("write_sigio_thread : write on socket " | 92 | printk("write_sigio_thread : write on socket " |
92 | "failed, err = %d\n", -n); | 93 | "failed, err = %d\n", errno); |
93 | } | 94 | } |
94 | } | 95 | } |
95 | 96 | ||
@@ -127,15 +128,15 @@ static void update_thread(void) | |||
127 | char c; | 128 | char c; |
128 | 129 | ||
129 | flags = set_signals(0); | 130 | flags = set_signals(0); |
130 | n = os_write_file(sigio_private[0], &c, sizeof(c)); | 131 | n = write(sigio_private[0], &c, sizeof(c)); |
131 | if(n != sizeof(c)){ | 132 | if(n != sizeof(c)){ |
132 | printk("update_thread : write failed, err = %d\n", -n); | 133 | printk("update_thread : write failed, err = %d\n", errno); |
133 | goto fail; | 134 | goto fail; |
134 | } | 135 | } |
135 | 136 | ||
136 | n = os_read_file(sigio_private[0], &c, sizeof(c)); | 137 | CATCH_EINTR(n = read(sigio_private[0], &c, sizeof(c))); |
137 | if(n != sizeof(c)){ | 138 | if(n != sizeof(c)){ |
138 | printk("update_thread : read failed, err = %d\n", -n); | 139 | printk("update_thread : read failed, err = %d\n", errno); |
139 | goto fail; | 140 | goto fail; |
140 | } | 141 | } |
141 | 142 | ||
@@ -459,10 +460,10 @@ static void tty_output(int master, int slave) | |||
459 | 460 | ||
460 | memset(buf, 0, sizeof(buf)); | 461 | memset(buf, 0, sizeof(buf)); |
461 | 462 | ||
462 | while(os_write_file(master, buf, sizeof(buf)) > 0) ; | 463 | while(write(master, buf, sizeof(buf)) > 0) ; |
463 | if(errno != EAGAIN) | 464 | if(errno != EAGAIN) |
464 | panic("tty_output : write failed, errno = %d\n", errno); | 465 | panic("tty_output : write failed, errno = %d\n", errno); |
465 | while(((n = os_read_file(slave, buf, sizeof(buf))) > 0) && !got_sigio) ; | 466 | while(((n = read(slave, buf, sizeof(buf))) > 0) && !got_sigio) ; |
466 | 467 | ||
467 | if(got_sigio){ | 468 | if(got_sigio){ |
468 | printk("Yes\n"); | 469 | printk("Yes\n"); |