diff options
Diffstat (limited to 'winsup/cygwin/fcntl.cc')
-rw-r--r-- | winsup/cygwin/fcntl.cc | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/winsup/cygwin/fcntl.cc b/winsup/cygwin/fcntl.cc index b531218f6..0ba704991 100644 --- a/winsup/cygwin/fcntl.cc +++ b/winsup/cygwin/fcntl.cc @@ -1,6 +1,6 @@ /* fcntl.cc: fcntl syscall - Copyright 1996, 1997, 1998, 1999, 2000, 2001 Red Hat, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. This file is part of Cygwin. @@ -9,7 +9,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ #include "winsup.h" -#include <fcntl.h> #include <stdarg.h> #include <errno.h> #include <unistd.h> @@ -17,8 +16,8 @@ details. */ #include "fhandler.h" #include "path.h" #include "dtable.h" -#include "cygheap.h" #include "cygerrno.h" +#include "cygheap.h" #include "thread.h" extern "C" @@ -29,22 +28,20 @@ _fcntl (int fd, int cmd,...) va_list args; int res; - if (cygheap->fdtab.not_open (fd)) + cygheap_fdget cfd (fd, true); + if (cfd < 0) { - set_errno (EBADF); res = -1; goto 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, cygheap->fdtab.find_unused_handle ((int) arg)); + if (cmd != F_DUPFD) + res = cfd->fcntl(cmd, arg); else - res = cygheap->fdtab[fd]->fcntl(cmd, arg); + res = dup2 (fd, cygheap_fdnew (((int) arg) - 1)); va_end (args); - ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"_fcntl"); done: syscall_printf ("%d = fcntl (%d, %d, %p)", res, fd, cmd, arg); |