summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/path.cc
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2009-09-25 23:55:00 +0000
committerEric Blake <eblake@redhat.com>2009-09-25 23:55:00 +0000
commit2bf78f09289d43d727c0bc95132be1bb22f00e7f (patch)
tree862de1f2ab1b6e07b4113b8fe308be944f9603db /winsup/cygwin/path.cc
parent358d4e3cb0a44d725e54494c97b2ddbaa2281b7b (diff)
downloadcygnal-2bf78f09289d43d727c0bc95132be1bb22f00e7f.tar.gz
cygnal-2bf78f09289d43d727c0bc95132be1bb22f00e7f.tar.bz2
cygnal-2bf78f09289d43d727c0bc95132be1bb22f00e7f.zip
Provide euidaccess, canonicalize_file_name; fix fchmodat.
* syscalls.cc (fchmodat): lchmod is not yet implemented. (euidaccess): New function. * path.cc (realpath): Update comment. (canonicalize_file_name): New function. * include/cygwin/stdlib.h (canonicalize_file_name): Declare it. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. * cygwin.din: Export canonicalize_file_name, eaccess, euidaccess. * posix.sgml: Mention them.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r--winsup/cygwin/path.cc24
1 files changed, 16 insertions, 8 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 89552d999..e543dd4b7 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -2845,7 +2845,7 @@ cygwin_conv_to_full_posix_path (const char *path, char *posix_path)
MAX_PATH);
}
-/* The realpath function is supported on some UNIX systems. */
+/* The realpath function is required by POSIX:2008. */
extern "C" char *
realpath (const char *path, char *resolved)
@@ -2876,11 +2876,9 @@ realpath (const char *path, char *resolved)
path_conv real_path (tpath, PC_SYM_FOLLOW | PC_POSIX, stat_suffixes);
- /* Linux has this funny non-standard extension. If "resolved" is NULL,
- realpath mallocs the space by itself and returns it to the application.
- The application is responsible for calling free() then. This extension
- is backed by POSIX, which allows implementation-defined behaviour if
- "resolved" is NULL. That's good enough for us to do the same here. */
+ /* POSIX 2008 requires malloc'ing if resolved is NULL, and states
+ that using non-NULL resolved is asking for portability
+ problems. */
if (!real_path.error && real_path.exists ())
{
@@ -2894,14 +2892,24 @@ realpath (const char *path, char *resolved)
return resolved;
}
- /* FIXME: on error, we are supposed to put the name of the path
- component which could not be resolved into RESOLVED. */
+ /* FIXME: on error, Linux puts the name of the path
+ component which could not be resolved into RESOLVED, but POSIX
+ does not require this. */
if (resolved)
resolved[0] = '\0';
set_errno (real_path.error ?: ENOENT);
return NULL;
}
+/* Linux provides this extension. Since the only portable use of
+ realpath requires a NULL second argument, we might as well have a
+ one-argument wrapper. */
+extern "C" char *
+canonicalize_file_name (const char *path)
+{
+ return realpath (path, NULL);
+}
+
/* Return non-zero if path is a POSIX path list.
This is exported to the world as cygwin_foo by cygwin.din.