Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-06-10 14:00:21 +0400
committerCorinna Vinschen <corinna@vinschen.de>2001-06-10 14:00:21 +0400
commit463513f0e2cfa15ebebb5df41ea13b324f83934b (patch)
treee5b0af3c4b9c47efdcfcefece96bbe4fbf461371 /winsup/cygwin/path.cc
parentd4217d5680a5fbec07a49c5921b41ccb886e635a (diff)
* cygwin.din: Add fchdir symbols.
* path.cc (chdir): Guard against invalid parameter. (fchdir): New function. * include/cygwin/version.h: Bump API minor version to 40. * uinfo.cc (internal_getlogin): Remove unused variable.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r--winsup/cygwin/path.cc32
1 files changed, 24 insertions, 8 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 76a009854..5dd13f67f 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -2994,8 +2994,14 @@ int
chdir (const char *dir)
{
MALLOC_CHECK;
- syscall_printf ("dir %s", dir);
path_conv path (dir, PC_FULL | PC_SYM_FOLLOW);
+ if (path.error)
+ {
+ set_errno (path.error);
+ syscall_printf ("-1 = chdir (%s)", dir);
+ return -1;
+ }
+ syscall_printf ("dir %s", dir);
char *s;
/* Incredibly. Windows allows you to specify a path with trailing
@@ -3005,13 +3011,6 @@ chdir (const char *dir)
for (s = strchr (dir, '\0'); --s >= dir && isspace ((unsigned int) (*s & 0xff)); )
*s = '\0';
- if (path.error)
- {
- set_errno (path.error);
- syscall_printf ("-1 = chdir (%s)", dir);
- return -1;
- }
-
/* Look for trailing path component consisting entirely of dots. This
is needed only in case of chdir since Windows simply ignores count
of dots > 2 here instead of returning an error code. Counts of dots
@@ -3068,6 +3067,23 @@ chdir (const char *dir)
return res;
}
+extern "C"
+int
+fchdir (int fd)
+{
+ sigframe thisframe (mainthread);
+
+ if (cygheap->fdtab.not_open (fd))
+ {
+ syscall_printf ("-1 = fchdir (%d)", fd);
+ set_errno (EBADF);
+ return -1;
+ }
+ int ret = chdir (cygheap->fdtab[fd]->get_name ());
+ syscall_printf ("%d = fchdir (%d)", ret, fd);
+ return ret;
+}
+
/******************** Exported Path Routines *********************/
/* Cover functions to the path conversion routines.