+2002-06-05 Christopher Faylor <cgf@redhat.com>
+
+ * 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)
+
2002-06-05 Christopher Faylor <cgf@redhat.com>
* dtable.cc (handle_to_fn): Check error return value from NtQueryObject
2002-06-04 Christopher Faylor <cgf@redhat.com>
* dtable.cc (handle_to_fn): Correct placement and length of name
- buffer. (Suggested by Pavel Tsekov)
+ buffer. (Suggested by Pavel Tsekov)
2002-06-04 Christopher Faylor <cgf@redhat.com>
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. */
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);
+ }
}
}
_unlink (const char *ourname)
{
int res = -1;
+ DWORD devn;
sigframe thisframe (mainthread);
path_conv win32_name (ourname, PC_SYM_NOFOLLOW | PC_FULL);
goto done;
}
+ if ((devn = win32_name.get_devn ()) == FH_PROC || devn == FH_REGISTRY
+ || devn == FH_PROCESS)
+ {
+ set_errno (EROFS);
+ goto done;
+ }
+
syscall_printf ("_unlink (%s)", win32_name.get_win32 ());
if (!win32_name.exists ())