Rev | Line | |
---|
[9] | 1 | #include <lib.h>
|
---|
| 2 | #define fcntl _fcntl
|
---|
| 3 | #include <fcntl.h>
|
---|
| 4 | #include <stdarg.h>
|
---|
| 5 |
|
---|
| 6 | #if _ANSI
|
---|
| 7 | PUBLIC int fcntl(int fd, int cmd, ...)
|
---|
| 8 | #else
|
---|
| 9 | PUBLIC int fcntl(fd, cmd)
|
---|
| 10 | int fd;
|
---|
| 11 | int cmd;
|
---|
| 12 | #endif
|
---|
| 13 | {
|
---|
| 14 | va_list argp;
|
---|
| 15 | message m;
|
---|
| 16 |
|
---|
| 17 | va_start(argp, cmd);
|
---|
| 18 |
|
---|
| 19 | /* Set up for the sensible case where there is no variable parameter. This
|
---|
| 20 | * covers F_GETFD, F_GETFL and invalid commands.
|
---|
| 21 | */
|
---|
| 22 | m.m1_i3 = 0;
|
---|
| 23 | m.m1_p1 = NIL_PTR;
|
---|
| 24 |
|
---|
| 25 | /* Adjust for the stupid cases. */
|
---|
| 26 | switch(cmd) {
|
---|
| 27 | case F_DUPFD:
|
---|
| 28 | case F_SETFD:
|
---|
| 29 | case F_SETFL:
|
---|
| 30 | m.m1_i3 = va_arg(argp, int);
|
---|
| 31 | break;
|
---|
| 32 | case F_GETLK:
|
---|
| 33 | case F_SETLK:
|
---|
| 34 | case F_SETLKW:
|
---|
| 35 | case F_FREESP:
|
---|
| 36 | m.m1_p1 = (char *) va_arg(argp, struct flock *);
|
---|
| 37 | break;
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | /* Clean up and make the system call. */
|
---|
| 41 | va_end(argp);
|
---|
| 42 | m.m1_i1 = fd;
|
---|
| 43 | m.m1_i2 = cmd;
|
---|
| 44 | return(_syscall(FS, FCNTL, &m));
|
---|
| 45 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.