diff options
author | Christopher Faylor <me@cgf.cx> | 2002-06-05 16:01:55 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-06-05 16:01:55 +0000 |
commit | ea4e6ec8f9fe4a784d4ce2ef71037e05fb9a876d (patch) | |
tree | f29a1b8689d3bc188ebc5d6822c1cbdb562e266d /winsup/cygwin/dir.cc | |
parent | 2bb6b3e50619d10b93a8a2640dd4784e01e97236 (diff) | |
download | cygnal-ea4e6ec8f9fe4a784d4ce2ef71037e05fb9a876d.tar.gz cygnal-ea4e6ec8f9fe4a784d4ce2ef71037e05fb9a876d.tar.bz2 cygnal-ea4e6ec8f9fe4a784d4ce2ef71037e05fb9a876d.zip |
* dir.cc (rmdir): Streamline. Detect attempts to remove directories from
"read-only" virtual devices. (Suggested by Pavel Tsekov)
* syscalls.cc (unlink): Detect attempts to remove directories from "read-only"
virtual devices. (From Pavel Tsekov)
Diffstat (limited to 'winsup/cygwin/dir.cc')
-rw-r--r-- | winsup/cygwin/dir.cc | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index c9509b65a..45ba57ff6 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -273,24 +273,19 @@ extern "C" int rmdir (const char *dir) { int res = -1; + DWORD devn; path_conv real_dir (dir, PC_SYM_NOFOLLOW); if (real_dir.error) - { - set_errno (real_dir.error); - res = -1; - } + set_errno (real_dir.error); + else if ((devn = real_dir.get_devn ()) == FH_PROC || devn == FH_REGISTRY + || devn == FH_PROCESS) + set_errno (EROFS); else if (!real_dir.exists ()) - { - set_errno (ENOENT); - res = -1; - } + set_errno (ENOENT); else if (!real_dir.isdir ()) - { - set_errno (ENOTDIR); - res = -1; - } + set_errno (ENOTDIR); else { /* Even own directories can't be removed if R/O attribute is set. */ @@ -330,22 +325,20 @@ rmdir (const char *dir) else if ((res = rmdir (dir))) SetCurrentDirectory (cygheap->cwd.win32); } - if (GetLastError () == ERROR_ACCESS_DENIED) + if (res) { - - /* On 9X ERROR_ACCESS_DENIED is returned if you try to remove - a non-empty directory. */ - if (wincap.access_denied_on_delete ()) - set_errno (ENOTEMPTY); - else + if (GetLastError () != ERROR_ACCESS_DENIED + || !wincap.access_denied_on_delete ()) __seterrno (); - } - else - __seterrno (); + else + set_errno (ENOTEMPTY); /* On 9X ERROR_ACCESS_DENIED is + returned if you try to remove a + non-empty directory. */ - /* If directory still exists, restore R/O attribute. */ - if (real_dir.has_attribute (FILE_ATTRIBUTE_READONLY)) - SetFileAttributes (real_dir, real_dir); + /* If directory still exists, restore R/O attribute. */ + if (real_dir.has_attribute (FILE_ATTRIBUTE_READONLY)) + SetFileAttributes (real_dir, real_dir); + } } } |