diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2000-10-23 20:16:52 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2000-10-23 20:16:52 +0000 |
commit | 1eb14bae8cc488dad2da4925cb73e4376c69fe45 (patch) | |
tree | 105a09afcbb92f6c87105b135f26397cc7866f3e /winsup/cygwin/fcntl.cc | |
parent | f80cdaeecbe2f65d2b6026bd25923cca7c9ab455 (diff) | |
download | newlib-1eb14bae8cc488dad2da4925cb73e4376c69fe45.zip newlib-1eb14bae8cc488dad2da4925cb73e4376c69fe45.tar.gz newlib-1eb14bae8cc488dad2da4925cb73e4376c69fe45.tar.bz2 |
* fcntl.cc (_fcntl): Rearrange as wrapper function. Move all
functionality except F_DUPFD to fhandler classes.
* fhandler.cc (fhandler_base::fcntl): New method.
* net.cc (fhandler_socket::fcntl): Ditto.
* fhandler.h (class fhandler_base): Add method prototype for fcntl().
(class fhandler_socket): Ditto.
Diffstat (limited to 'winsup/cygwin/fcntl.cc')
-rw-r--r-- | winsup/cygwin/fcntl.cc | 83 |
1 files changed, 11 insertions, 72 deletions
diff --git a/winsup/cygwin/fcntl.cc b/winsup/cygwin/fcntl.cc index f4d1b44..408cbc2 100644 --- a/winsup/cygwin/fcntl.cc +++ b/winsup/cygwin/fcntl.cc @@ -22,10 +22,9 @@ extern "C" int _fcntl (int fd, int cmd,...) { + void *arg = NULL; va_list args; - int arg = 0; int res; - SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK, "_fcntl"); if (fdtab.not_open (fd)) { @@ -34,77 +33,17 @@ _fcntl (int fd, int cmd,...) goto done; } - switch (cmd) - { - case F_DUPFD: - va_start (args, cmd); - arg = va_arg (args,int); - va_end (args); - res = dup2 (fd, fdtab.find_unused_handle (arg)); - goto done; - - case F_GETFD: - res = fdtab[fd]->get_close_on_exec () ? FD_CLOEXEC : 0; - goto done; - - case F_SETFD: - va_start (args, cmd); - arg = va_arg (args, int); - va_end (args); - fdtab[fd]->set_close_on_exec (arg); - res = 0; - goto done; - - case F_GETFL: - { - res = fdtab[fd]->get_flags (); - goto done; - } - case F_SETFL: - { - int temp = 0; - - va_start (args, cmd); - arg = va_arg (args, int); - va_end (args); - - if (arg & O_RDONLY) - temp |= GENERIC_READ; - if (arg & O_WRONLY) - temp |= GENERIC_WRITE; - - syscall_printf ("fcntl (%d, F_SETFL, %d)", arg); - - fdtab[fd]->set_access (temp); - fdtab[fd]->set_flags (arg); - - res = 0; - goto done; - } - - case F_GETLK: - case F_SETLK: - case F_SETLKW: - { - struct flock *fl; - va_start (args, cmd); - fl = va_arg (args,struct flock *); - va_end (args); - res = fdtab[fd]->lock (cmd, fl); - goto done; - } - default: - set_errno (EINVAL); - res = -1; - goto done; - } - - set_errno (ENOSYS); - res = -1; - - done: + SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK, "_fcntl"); + va_start (args, cmd); + arg = va_arg (args, void *); + if (cmd == F_DUPFD) + res = dup2 (fd, fdtab.find_unused_handle ((int) arg)); + else + res = fdtab[fd]->fcntl(cmd, arg); + va_end (args); ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"_fcntl"); - syscall_printf ("%d = fcntl (%d, %d, %d)", res, fd, cmd, arg); +done: + syscall_printf ("%d = fcntl (%d, %d, %p)", res, fd, cmd, arg); return res; } |