aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux/file.c
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2006-07-10 07:45:14 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-07-10 16:24:24 -0400
commit108ffa8cbfa323d462a2f4b49f38da3205d36e5a (patch)
treea9474c48ff4da341ce296b9b26da70dd5bba0fd2 /arch/um/os-Linux/file.c
parent1d3468a6643a6a5905e2ac9ae1fa1aefc06d882a (diff)
[PATCH] uml: formatting fixes
Fix a bunch of formatting problems. Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/os-Linux/file.c')
-rw-r--r--arch/um/os-Linux/file.c137
1 files changed, 66 insertions, 71 deletions
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
index 09251338d99..367ac33c566 100644
--- a/arch/um/os-Linux/file.c
+++ b/arch/um/os-Linux/file.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -47,11 +47,11 @@ int os_stat_fd(const int fd, struct uml_stat *ubuf)
47 } while((err < 0) && (errno == EINTR)) ; 47 } while((err < 0) && (errno == EINTR)) ;
48 48
49 if(err < 0) 49 if(err < 0)
50 return(-errno); 50 return -errno;
51 51
52 if(ubuf != NULL) 52 if(ubuf != NULL)
53 copy_stat(ubuf, &sbuf); 53 copy_stat(ubuf, &sbuf);
54 return(err); 54 return err;
55} 55}
56 56
57int os_stat_file(const char *file_name, struct uml_stat *ubuf) 57int os_stat_file(const char *file_name, struct uml_stat *ubuf)
@@ -64,11 +64,11 @@ int os_stat_file(const char *file_name, struct uml_stat *ubuf)
64 } while((err < 0) && (errno == EINTR)) ; 64 } while((err < 0) && (errno == EINTR)) ;
65 65
66 if(err < 0) 66 if(err < 0)
67 return(-errno); 67 return -errno;
68 68
69 if(ubuf != NULL) 69 if(ubuf != NULL)
70 copy_stat(ubuf, &sbuf); 70 copy_stat(ubuf, &sbuf);
71 return(err); 71 return err;
72} 72}
73 73
74int os_access(const char* file, int mode) 74int os_access(const char* file, int mode)
@@ -80,9 +80,9 @@ int os_access(const char* file, int mode)
80 80
81 err = access(file, amode); 81 err = access(file, amode);
82 if(err < 0) 82 if(err < 0)
83 return(-errno); 83 return -errno;
84 84
85 return(0); 85 return 0;
86} 86}
87 87
88void os_print_error(int error, const char* str) 88void os_print_error(int error, const char* str)
@@ -99,9 +99,9 @@ int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg)
99 99
100 err = ioctl(fd, cmd, arg); 100 err = ioctl(fd, cmd, arg);
101 if(err < 0) 101 if(err < 0)
102 return(-errno); 102 return -errno;
103 103
104 return(err); 104 return err;
105} 105}
106 106
107int os_window_size(int fd, int *rows, int *cols) 107int os_window_size(int fd, int *rows, int *cols)
@@ -109,12 +109,12 @@ int os_window_size(int fd, int *rows, int *cols)
109 struct winsize size; 109 struct winsize size;
110 110
111 if(ioctl(fd, TIOCGWINSZ, &size) < 0) 111 if(ioctl(fd, TIOCGWINSZ, &size) < 0)
112 return(-errno); 112 return -errno;
113 113
114 *rows = size.ws_row; 114 *rows = size.ws_row;
115 *cols = size.ws_col; 115 *cols = size.ws_col;
116 116
117 return(0); 117 return 0;
118} 118}
119 119
120int os_new_tty_pgrp(int fd, int pid) 120int os_new_tty_pgrp(int fd, int pid)
@@ -125,16 +125,16 @@ int os_new_tty_pgrp(int fd, int pid)
125 if(tcsetpgrp(fd, pid) < 0) 125 if(tcsetpgrp(fd, pid) < 0)
126 return -errno; 126 return -errno;
127 127
128 return(0); 128 return 0;
129} 129}
130 130
131/* FIXME: ensure namebuf in os_get_if_name is big enough */ 131/* FIXME: ensure namebuf in os_get_if_name is big enough */
132int os_get_ifname(int fd, char* namebuf) 132int os_get_ifname(int fd, char* namebuf)
133{ 133{
134 if(ioctl(fd, SIOCGIFNAME, namebuf) < 0) 134 if(ioctl(fd, SIOCGIFNAME, namebuf) < 0)
135 return(-errno); 135 return -errno;
136 136
137 return(0); 137 return 0;
138} 138}
139 139
140int os_set_slip(int fd) 140int os_set_slip(int fd)
@@ -149,7 +149,7 @@ int os_set_slip(int fd)
149 if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0) 149 if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0)
150 return -errno; 150 return -errno;
151 151
152 return(0); 152 return 0;
153} 153}
154 154
155int os_set_owner(int fd, int pid) 155int os_set_owner(int fd, int pid)
@@ -158,10 +158,10 @@ int os_set_owner(int fd, int pid)
158 int save_errno = errno; 158 int save_errno = errno;
159 159
160 if(fcntl(fd, F_GETOWN, 0) != pid) 160 if(fcntl(fd, F_GETOWN, 0) != pid)
161 return(-save_errno); 161 return -save_errno;
162 } 162 }
163 163
164 return(0); 164 return 0;
165} 165}
166 166
167/* FIXME? moved wholesale from sigio_user.c to get fcntls out of that file */ 167/* FIXME? moved wholesale from sigio_user.c to get fcntls out of that file */
@@ -192,9 +192,9 @@ int os_mode_fd(int fd, int mode)
192 } while((err < 0) && (errno==EINTR)) ; 192 } while((err < 0) && (errno==EINTR)) ;
193 193
194 if(err < 0) 194 if(err < 0)
195 return(-errno); 195 return -errno;
196 196
197 return(0); 197 return 0;
198} 198}
199 199
200int os_file_type(char *file) 200int os_file_type(char *file)
@@ -204,15 +204,21 @@ int os_file_type(char *file)
204 204
205 err = os_stat_file(file, &buf); 205 err = os_stat_file(file, &buf);
206 if(err < 0) 206 if(err < 0)
207 return(err); 207 return err;
208 208
209 if(S_ISDIR(buf.ust_mode)) return(OS_TYPE_DIR); 209 if(S_ISDIR(buf.ust_mode))
210 else if(S_ISLNK(buf.ust_mode)) return(OS_TYPE_SYMLINK); 210 return OS_TYPE_DIR;
211 else if(S_ISCHR(buf.ust_mode)) return(OS_TYPE_CHARDEV); 211 else if(S_ISLNK(buf.ust_mode))
212 else if(S_ISBLK(buf.ust_mode)) return(OS_TYPE_BLOCKDEV); 212 return OS_TYPE_SYMLINK;
213 else if(S_ISFIFO(buf.ust_mode)) return(OS_TYPE_FIFO); 213 else if(S_ISCHR(buf.ust_mode))
214 else if(S_ISSOCK(buf.ust_mode)) return(OS_TYPE_SOCK); 214 return OS_TYPE_CHARDEV;
215 else return(OS_TYPE_FILE); 215 else if(S_ISBLK(buf.ust_mode))
216 return OS_TYPE_BLOCKDEV;
217 else if(S_ISFIFO(buf.ust_mode))
218 return OS_TYPE_FIFO;
219 else if(S_ISSOCK(buf.ust_mode))
220 return OS_TYPE_SOCK;
221 else return OS_TYPE_FILE;
216} 222}
217 223
218int os_file_mode(char *file, struct openflags *mode_out) 224int os_file_mode(char *file, struct openflags *mode_out)
@@ -302,8 +308,8 @@ int os_seek_file(int fd, __u64 offset)
302 308
303 actual = lseek64(fd, offset, SEEK_SET); 309 actual = lseek64(fd, offset, SEEK_SET);
304 if(actual != offset) 310 if(actual != offset)
305 return(-errno); 311 return -errno;
306 return(0); 312 return 0;
307} 313}
308 314
309static int fault_buffer(void *start, int len, 315static int fault_buffer(void *start, int len,
@@ -314,13 +320,13 @@ static int fault_buffer(void *start, int len,
314 320
315 for(i = 0; i < len; i += page){ 321 for(i = 0; i < len; i += page){
316 if((*copy_proc)(start + i, &c, sizeof(c))) 322 if((*copy_proc)(start + i, &c, sizeof(c)))
317 return(-EFAULT); 323 return -EFAULT;
318 } 324 }
319 if((len % page) != 0){ 325 if((len % page) != 0){
320 if((*copy_proc)(start + len - 1, &c, sizeof(c))) 326 if((*copy_proc)(start + len - 1, &c, sizeof(c)))
321 return(-EFAULT); 327 return -EFAULT;
322 } 328 }
323 return(0); 329 return 0;
324} 330}
325 331
326static int file_io(int fd, void *buf, int len, 332static int file_io(int fd, void *buf, int len,
@@ -334,26 +340,26 @@ static int file_io(int fd, void *buf, int len,
334 if((n < 0) && (errno == EFAULT)){ 340 if((n < 0) && (errno == EFAULT)){
335 err = fault_buffer(buf, len, copy_user_proc); 341 err = fault_buffer(buf, len, copy_user_proc);
336 if(err) 342 if(err)
337 return(err); 343 return err;
338 n = (*io_proc)(fd, buf, len); 344 n = (*io_proc)(fd, buf, len);
339 } 345 }
340 } while((n < 0) && (errno == EINTR)); 346 } while((n < 0) && (errno == EINTR));
341 347
342 if(n < 0) 348 if(n < 0)
343 return(-errno); 349 return -errno;
344 return(n); 350 return n;
345} 351}
346 352
347int os_read_file(int fd, void *buf, int len) 353int os_read_file(int fd, void *buf, int len)
348{ 354{
349 return(file_io(fd, buf, len, (int (*)(int, void *, int)) read, 355 return file_io(fd, buf, len, (int (*)(int, void *, int)) read,
350 copy_from_user_proc)); 356 copy_from_user_proc);
351} 357}
352 358
353int os_write_file(int fd, const void *buf, int len) 359int os_write_file(int fd, const void *buf, int len)
354{ 360{
355 return(file_io(fd, (void *) buf, len, 361 return file_io(fd, (void *) buf, len,
356 (int (*)(int, void *, int)) write, copy_to_user_proc)); 362 (int (*)(int, void *, int)) write, copy_to_user_proc);
357} 363}
358 364
359int os_file_size(char *file, unsigned long long *size_out) 365int os_file_size(char *file, unsigned long long *size_out)
@@ -398,11 +404,11 @@ int os_file_modtime(char *file, unsigned long *modtime)
398 err = os_stat_file(file, &buf); 404 err = os_stat_file(file, &buf);
399 if(err < 0){ 405 if(err < 0){
400 printk("Couldn't stat \"%s\" : err = %d\n", file, -err); 406 printk("Couldn't stat \"%s\" : err = %d\n", file, -err);
401 return(err); 407 return err;
402 } 408 }
403 409
404 *modtime = buf.ust_mtime; 410 *modtime = buf.ust_mtime;
405 return(0); 411 return 0;
406} 412}
407 413
408int os_get_exec_close(int fd, int* close_on_exec) 414int os_get_exec_close(int fd, int* close_on_exec)
@@ -455,7 +461,7 @@ int os_pipe(int *fds, int stream, int close_on_exec)
455 if(err < 0) 461 if(err < 0)
456 goto error; 462 goto error;
457 463
458 return(0); 464 return 0;
459 465
460 error: 466 error:
461 printk("os_pipe : Setting FD_CLOEXEC failed, err = %d\n", -err); 467 printk("os_pipe : Setting FD_CLOEXEC failed, err = %d\n", -err);
@@ -486,12 +492,12 @@ int os_set_fd_async(int fd, int owner)
486 (fcntl(fd, F_SETOWN, owner) < 0)){ 492 (fcntl(fd, F_SETOWN, owner) < 0)){
487 err = -errno; 493 err = -errno;
488 printk("os_set_fd_async : Failed to fcntl F_SETOWN " 494 printk("os_set_fd_async : Failed to fcntl F_SETOWN "
489 "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd, 495 "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd,
490 owner, errno); 496 owner, errno);
491 return err; 497 return err;
492 } 498 }
493 499
494 return(0); 500 return 0;
495} 501}
496 502
497int os_clear_fd_async(int fd) 503int os_clear_fd_async(int fd)
@@ -500,8 +506,8 @@ int os_clear_fd_async(int fd)
500 506
501 flags &= ~(O_ASYNC | O_NONBLOCK); 507 flags &= ~(O_ASYNC | O_NONBLOCK);
502 if(fcntl(fd, F_SETFL, flags) < 0) 508 if(fcntl(fd, F_SETFL, flags) < 0)
503 return(-errno); 509 return -errno;
504 return(0); 510 return 0;
505} 511}
506 512
507int os_set_fd_block(int fd, int blocking) 513int os_set_fd_block(int fd, int blocking)
@@ -516,7 +522,7 @@ int os_set_fd_block(int fd, int blocking)
516 if(fcntl(fd, F_SETFL, flags) < 0) 522 if(fcntl(fd, F_SETFL, flags) < 0)
517 return -errno; 523 return -errno;
518 524
519 return(0); 525 return 0;
520} 526}
521 527
522int os_accept_connection(int fd) 528int os_accept_connection(int fd)
@@ -524,9 +530,9 @@ int os_accept_connection(int fd)
524 int new; 530 int new;
525 531
526 new = accept(fd, NULL, 0); 532 new = accept(fd, NULL, 0);
527 if(new < 0) 533 if(new < 0)
528 return(-errno); 534 return -errno;
529 return(new); 535 return new;
530} 536}
531 537
532#ifndef SHUT_RD 538#ifndef SHUT_RD
@@ -550,12 +556,12 @@ int os_shutdown_socket(int fd, int r, int w)
550 else if(w) what = SHUT_WR; 556 else if(w) what = SHUT_WR;
551 else { 557 else {
552 printk("os_shutdown_socket : neither r or w was set\n"); 558 printk("os_shutdown_socket : neither r or w was set\n");
553 return(-EINVAL); 559 return -EINVAL;
554 } 560 }
555 err = shutdown(fd, what); 561 err = shutdown(fd, what);
556 if(err < 0) 562 if(err < 0)
557 return(-errno); 563 return -errno;
558 return(0); 564 return 0;
559} 565}
560 566
561int os_rcv_fd(int fd, int *helper_pid_out) 567int os_rcv_fd(int fd, int *helper_pid_out)
@@ -578,7 +584,7 @@ int os_rcv_fd(int fd, int *helper_pid_out)
578 584
579 n = recvmsg(fd, &msg, 0); 585 n = recvmsg(fd, &msg, 0);
580 if(n < 0) 586 if(n < 0)
581 return(-errno); 587 return -errno;
582 588
583 else if(n != sizeof(iov.iov_len)) 589 else if(n != sizeof(iov.iov_len))
584 *helper_pid_out = -1; 590 *helper_pid_out = -1;
@@ -586,16 +592,16 @@ int os_rcv_fd(int fd, int *helper_pid_out)
586 cmsg = CMSG_FIRSTHDR(&msg); 592 cmsg = CMSG_FIRSTHDR(&msg);
587 if(cmsg == NULL){ 593 if(cmsg == NULL){
588 printk("rcv_fd didn't receive anything, error = %d\n", errno); 594 printk("rcv_fd didn't receive anything, error = %d\n", errno);
589 return(-1); 595 return -1;
590 } 596 }
591 if((cmsg->cmsg_level != SOL_SOCKET) || 597 if((cmsg->cmsg_level != SOL_SOCKET) ||
592 (cmsg->cmsg_type != SCM_RIGHTS)){ 598 (cmsg->cmsg_type != SCM_RIGHTS)){
593 printk("rcv_fd didn't receive a descriptor\n"); 599 printk("rcv_fd didn't receive a descriptor\n");
594 return(-1); 600 return -1;
595 } 601 }
596 602
597 new = ((int *) CMSG_DATA(cmsg))[0]; 603 new = ((int *) CMSG_DATA(cmsg))[0];
598 return(new); 604 return new;
599} 605}
600 606
601int os_create_unix_socket(char *file, int len, int close_on_exec) 607int os_create_unix_socket(char *file, int len, int close_on_exec)
@@ -623,7 +629,7 @@ int os_create_unix_socket(char *file, int len, int close_on_exec)
623 if(err < 0) 629 if(err < 0)
624 return -errno; 630 return -errno;
625 631
626 return(sock); 632 return sock;
627} 633}
628 634
629void os_flush_stdout(void) 635void os_flush_stdout(void)
@@ -654,16 +660,5 @@ int os_lock_file(int fd, int excl)
654 printk("F_SETLK failed, file already locked by pid %d\n", lock.l_pid); 660 printk("F_SETLK failed, file already locked by pid %d\n", lock.l_pid);
655 err = save; 661 err = save;
656 out: 662 out:
657 return(err); 663 return err;
658} 664}
659
660/*
661 * Overrides for Emacs so that we follow Linus's tabbing style.
662 * Emacs will notice this stuff at the end of the file and automatically
663 * adjust the settings for this buffer only. This must remain at the end
664 * of the file.
665 * ---------------------------------------------------------------------------
666 * Local variables:
667 * c-file-style: "linux"
668 * End:
669 */