summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/path.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r--winsup/cygwin/path.cc20
1 files changed, 9 insertions, 11 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 59b0d59df..95e4ef703 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -3136,19 +3136,17 @@ extern "C"
int
fchdir (int fd)
{
+ int res;
sigframe thisframe (mainthread);
- if (cygheap->fdtab.not_open (fd))
- {
- syscall_printf ("-1 = fchdir (%d)", fd);
- set_errno (EBADF);
- return -1;
- }
- SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fchdir");
- int ret = chdir (cygheap->fdtab[fd]->get_name ());
- ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fchdir");
- syscall_printf ("%d = fchdir (%d)", ret, fd);
- return ret;
+ cygheap_fdget cfd (fd);
+ if (cfd >= 0)
+ res = chdir (cfd->get_name ());
+ else
+ res = -1;
+
+ syscall_printf ("%d = fchdir (%d)", res, fd);
+ return res;
}
/******************** Exported Path Routines *********************/