diff options
author | Christopher Faylor <me@cgf.cx> | 2004-01-24 20:34:27 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2004-01-24 20:34:27 +0000 |
commit | 9157f0f3ec8d3046603b325b6bd8b43d1b62d13a (patch) | |
tree | b9784b32688a4ba3b230be8f26bfab004cdc0ea7 /winsup/cygwin/fhandler.cc | |
parent | d5f60b41f43da8a982a1789c78c1dbc4ede190c3 (diff) | |
download | cygnal-9157f0f3ec8d3046603b325b6bd8b43d1b62d13a.tar.gz cygnal-9157f0f3ec8d3046603b325b6bd8b43d1b62d13a.tar.bz2 cygnal-9157f0f3ec8d3046603b325b6bd8b43d1b62d13a.zip |
* fhandler.h (fhandler_base::fhaccess): Return int for compatibility with
access.
* fhandler.cc (fhandler_base::fhaccess): Return int. Use consistent variable
name for exit value. Exit at bottom, printing debugging information, like
other cygwin functions.
Diffstat (limited to 'winsup/cygwin/fhandler.cc')
-rw-r--r-- | winsup/cygwin/fhandler.cc | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 98b685b87..38b95d42b 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -331,19 +331,20 @@ fhandler_base::device_access_denied (int flags) return fhaccess (mode); } -bool +int fhandler_base::fhaccess (int flags) { + int res = -1; if (error ()) { set_errno (error ()); - return -1; + goto done; } if (!exists ()) { set_errno (ENOENT); - return -1; + goto done; } if (!(flags & (R_OK | W_OK | X_OK))) @@ -354,16 +355,15 @@ fhandler_base::fhaccess (int flags) else if (has_attribute (FILE_ATTRIBUTE_READONLY) && (flags & W_OK)) { set_errno (EACCES); - return -1; + goto done; } else if (has_acls () && allow_ntsec) return check_file_access (get_win32_name (), flags); struct __stat64 st; - int r = fstat (&st); - if (r) - return -1; - r = -1; + if (fstat (&st)) + goto done; + if (flags & R_OK) { if (st.st_uid == myself->uid) @@ -379,6 +379,7 @@ fhandler_base::fhaccess (int flags) else if (!(st.st_mode & S_IROTH)) goto done; } + if (flags & W_OK) { if (st.st_uid == myself->uid) @@ -394,6 +395,7 @@ fhandler_base::fhaccess (int flags) else if (!(st.st_mode & S_IWOTH)) goto done; } + if (flags & X_OK) { if (st.st_uid == myself->uid) @@ -409,11 +411,12 @@ fhandler_base::fhaccess (int flags) else if (!(st.st_mode & S_IXOTH)) goto done; } - r = 0; + res = 0; done: - if (r) + if (res) set_errno (EACCES); - return r; + debug_printf ("returning %d", res); + return res; } /* Open system call handler function. */ |