summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/syscalls.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2004-04-20 15:51:24 +0000
committerCorinna Vinschen <corinna@vinschen.de>2004-04-20 15:51:24 +0000
commitc8daf9983b445c9a2a0238af2d6e3ae23d0f3411 (patch)
treef836ae20b5aa189f864d6448c7a205c6ba7e7fc2 /winsup/cygwin/syscalls.cc
parent4cc12c56301d5092226264aa294674f17640448e (diff)
downloadcygnal-c8daf9983b445c9a2a0238af2d6e3ae23d0f3411.tar.gz
cygnal-c8daf9983b445c9a2a0238af2d6e3ae23d0f3411.tar.bz2
cygnal-c8daf9983b445c9a2a0238af2d6e3ae23d0f3411.zip
* fhandler_disk_file.cc (fhandler_base::open_fs): Change
set_file_attribute call to indicate that NT security isn't used. (fhandler_disk_file::fchmod): Rearrange to isolate 9x related statements. Do not set FILE_ATTRIBUTE_SYSTEM. (fhandler_disk_file::fchown): Check noop case first. * fhandler.cc (fhandler_base::open9x): Remove ntsec related statements. (fhandler_base::set_name): Do not set namehash. * fhandler.h (fhandler_base::get_namehash): Compute and set namehash if needed. * syscalls.cc (access): Verify that fh is not NULL. Do not set PC_FULL. (chmod): Ditto. (chown_worker): Ditto. (stat_worker): Ditto. Verify if the path exists.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc42
1 files changed, 27 insertions, 15 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index d89b86484..521906590 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -827,8 +827,11 @@ chown_worker (const char *name, unsigned fmode, __uid32_t uid, __gid32_t gid)
return 0; // return zero (and do nothing) under Windows 9x
int res = -1;
- fhandler_base *fh = build_fh_name (name, NULL, fmode | PC_FULL,
- stat_suffixes);
+ fhandler_base *fh;
+
+ if (!(fh = build_fh_name (name, NULL, fmode, stat_suffixes)))
+ goto error;
+
if (fh->error ())
{
debug_printf ("got %d error from build_fh_name", fh->error ());
@@ -838,6 +841,7 @@ chown_worker (const char *name, unsigned fmode, __uid32_t uid, __gid32_t gid)
res = fh->fchown (uid, gid);
delete fh;
+ error:
syscall_printf ("%d = %schown (%s,...)",
res, (fmode & PC_SYM_NOFOLLOW) ? "l" : "", name);
return res;
@@ -916,8 +920,10 @@ extern "C" int
chmod (const char *path, mode_t mode)
{
int res = -1;
- fhandler_base *fh = build_fh_name (path, NULL, PC_SYM_FOLLOW | PC_FULL,
- stat_suffixes);
+ fhandler_base *fh;
+ if (!(fh = build_fh_name (path, NULL, PC_SYM_FOLLOW, stat_suffixes)))
+ goto error;
+
if (fh->error ())
{
debug_printf ("got %d error from build_fh_name", fh->error ());
@@ -927,6 +933,7 @@ chmod (const char *path, mode_t mode)
res = fh->fchmod (mode);
delete fh;
+ error:
syscall_printf ("%d = chmod (%s, %p)", res, path, mode);
return res;
}
@@ -1056,17 +1063,18 @@ stat_worker (const char *name, struct __stat64 *buf, int nofollow)
fhandler_base *fh = NULL;
if (check_null_invalid_struct_errno (buf))
- goto done;
-
- fh = build_fh_name (name, NULL, (nofollow ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW)
- | PC_FULL, stat_suffixes);
+ goto error;
+ if (!(fh = build_fh_name (name, NULL, nofollow ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW,
+ stat_suffixes)))
+ goto error;
+
if (fh->error ())
{
debug_printf ("got %d error from build_fh_name", fh->error ());
set_errno (fh->error ());
}
- else
+ else if (fh->exists ())
{
debug_printf ("(%s, %p, %d, %p), file_attributes %d", name, buf, nofollow,
fh, (DWORD) *fh);
@@ -1082,10 +1090,11 @@ stat_worker (const char *name, struct __stat64 *buf, int nofollow)
buf->st_rdev = buf->st_dev;
}
}
+ else
+ set_errno (ENOENT);
- done:
- if (fh)
- delete fh;
+ delete fh;
+ error:
MALLOC_CHECK;
syscall_printf ("%d = (%s, %p)", res, name, buf);
return res;
@@ -1158,9 +1167,12 @@ access (const char *fn, int flags)
set_errno (EINVAL);
else
{
- fhandler_base *fh = build_fh_name (fn, NULL, PC_SYM_FOLLOW | PC_FULL, stat_suffixes);
- res = fh->fhaccess (flags);
- delete fh;
+ fhandler_base *fh = build_fh_name (fn, NULL, PC_SYM_FOLLOW, stat_suffixes);
+ if (fh)
+ {
+ res = fh->fhaccess (flags);
+ delete fh;
+ }
}
debug_printf ("returning %d", res);
return res;