aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux/aio.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/os-Linux/aio.c')
-rw-r--r--arch/um/os-Linux/aio.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/arch/um/os-Linux/aio.c b/arch/um/os-Linux/aio.c
index c1f0f76291cf..5d258eb4f506 100644
--- a/arch/um/os-Linux/aio.c
+++ b/arch/um/os-Linux/aio.c
@@ -132,10 +132,10 @@ static int aio_thread(void *arg)
132 { .data = (void *) (long) event.data, 132 { .data = (void *) (long) event.data,
133 .err = event.res }); 133 .err = event.res });
134 reply_fd = ((struct aio_context *) reply.data)->reply_fd; 134 reply_fd = ((struct aio_context *) reply.data)->reply_fd;
135 err = os_write_file(reply_fd, &reply, sizeof(reply)); 135 err = write(reply_fd, &reply, sizeof(reply));
136 if(err != sizeof(reply)) 136 if(err != sizeof(reply))
137 printk("aio_thread - write failed, fd = %d, " 137 printk("aio_thread - write failed, fd = %d, "
138 "err = %d\n", reply_fd, -err); 138 "err = %d\n", reply_fd, errno);
139 } 139 }
140 } 140 }
141 return 0; 141 return 0;
@@ -147,7 +147,7 @@ static int do_not_aio(struct aio_thread_req *req)
147{ 147{
148 char c; 148 char c;
149 unsigned long long actual; 149 unsigned long long actual;
150 int err; 150 int n;
151 151
152 actual = lseek64(req->io_fd, req->offset, SEEK_SET); 152 actual = lseek64(req->io_fd, req->offset, SEEK_SET);
153 if(actual != req->offset) 153 if(actual != req->offset)
@@ -155,21 +155,22 @@ static int do_not_aio(struct aio_thread_req *req)
155 155
156 switch(req->type){ 156 switch(req->type){
157 case AIO_READ: 157 case AIO_READ:
158 err = os_read_file(req->io_fd, req->buf, req->len); 158 n = read(req->io_fd, req->buf, req->len);
159 break; 159 break;
160 case AIO_WRITE: 160 case AIO_WRITE:
161 err = os_write_file(req->io_fd, req->buf, req->len); 161 n = write(req->io_fd, req->buf, req->len);
162 break; 162 break;
163 case AIO_MMAP: 163 case AIO_MMAP:
164 err = os_read_file(req->io_fd, &c, sizeof(c)); 164 n = read(req->io_fd, &c, sizeof(c));
165 break; 165 break;
166 default: 166 default:
167 printk("do_not_aio - bad request type : %d\n", req->type); 167 printk("do_not_aio - bad request type : %d\n", req->type);
168 err = -EINVAL; 168 return -EINVAL;
169 break;
170 } 169 }
171 170
172 return err; 171 if(n < 0)
172 return -errno;
173 return 0;
173} 174}
174 175
175/* These are initialized in initcalls and not changed */ 176/* These are initialized in initcalls and not changed */
@@ -185,12 +186,12 @@ static int not_aio_thread(void *arg)
185 186
186 signal(SIGWINCH, SIG_IGN); 187 signal(SIGWINCH, SIG_IGN);
187 while(1){ 188 while(1){
188 err = os_read_file(aio_req_fd_r, &req, sizeof(req)); 189 err = read(aio_req_fd_r, &req, sizeof(req));
189 if(err != sizeof(req)){ 190 if(err != sizeof(req)){
190 if(err < 0) 191 if(err < 0)
191 printk("not_aio_thread - read failed, " 192 printk("not_aio_thread - read failed, "
192 "fd = %d, err = %d\n", aio_req_fd_r, 193 "fd = %d, err = %d\n", aio_req_fd_r,
193 -err); 194 errno);
194 else { 195 else {
195 printk("not_aio_thread - short read, fd = %d, " 196 printk("not_aio_thread - short read, fd = %d, "
196 "length = %d\n", aio_req_fd_r, err); 197 "length = %d\n", aio_req_fd_r, err);
@@ -200,10 +201,10 @@ static int not_aio_thread(void *arg)
200 err = do_not_aio(&req); 201 err = do_not_aio(&req);
201 reply = ((struct aio_thread_reply) { .data = req.aio, 202 reply = ((struct aio_thread_reply) { .data = req.aio,
202 .err = err }); 203 .err = err });
203 err = os_write_file(req.aio->reply_fd, &reply, sizeof(reply)); 204 err = write(req.aio->reply_fd, &reply, sizeof(reply));
204 if(err != sizeof(reply)) 205 if(err != sizeof(reply))
205 printk("not_aio_thread - write failed, fd = %d, " 206 printk("not_aio_thread - write failed, fd = %d, "
206 "err = %d\n", req.aio->reply_fd, -err); 207 "err = %d\n", req.aio->reply_fd, errno);
207 } 208 }
208 209
209 return 0; 210 return 0;
@@ -277,10 +278,12 @@ static int submit_aio_26(enum aio_type type, int io_fd, char *buf, int len,
277 if(err){ 278 if(err){
278 reply = ((struct aio_thread_reply) { .data = aio, 279 reply = ((struct aio_thread_reply) { .data = aio,
279 .err = err }); 280 .err = err });
280 err = os_write_file(aio->reply_fd, &reply, sizeof(reply)); 281 err = write(aio->reply_fd, &reply, sizeof(reply));
281 if(err != sizeof(reply)) 282 if(err != sizeof(reply)){
283 err = -errno;
282 printk("submit_aio_26 - write failed, " 284 printk("submit_aio_26 - write failed, "
283 "fd = %d, err = %d\n", aio->reply_fd, -err); 285 "fd = %d, err = %d\n", aio->reply_fd, -err);
286 }
284 else err = 0; 287 else err = 0;
285 } 288 }
286 289
@@ -375,9 +378,10 @@ static int submit_aio_24(enum aio_type type, int io_fd, char *buf, int len,
375 }; 378 };
376 int err; 379 int err;
377 380
378 err = os_write_file(aio_req_fd_w, &req, sizeof(req)); 381 err = write(aio_req_fd_w, &req, sizeof(req));
379 if(err == sizeof(req)) 382 if(err == sizeof(req))
380 err = 0; 383 err = 0;
384 else err = -errno;
381 385
382 return err; 386 return err;
383} 387}