This is the mail archive of the
cygwin-patches@sourceware.cygnus.com
mailing list for the Cygwin project.
rmdir says it isn't a directory about a read only directory.
- To: cygwin-patches at sourceware dot cygnus dot com
- Subject: rmdir says it isn't a directory about a read only directory.
- From: Kazuhiro Fujieda <fujieda at jaist dot ac dot jp>
- Date: 25 May 2000 16:06:32 +0900
rmdir() sets ENOTDIR to the errno about a read only directory
like the following.
$ mkdir aaa
$ chmod -w aaa
$ rmdir aaa
rmdir: aaa: Not a directory
The following patch can fix this problem.
2000-05-25 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
* dir.cc (rmdir): Correct the manner in checking the target directory.
Index: dir.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/dir.cc,v
retrieving revision 1.4
diff -u -p -r1.4 dir.cc
--- dir.cc 2000/05/24 20:09:43 1.4
+++ dir.cc 2000/05/25 06:36:50
@@ -341,12 +341,13 @@ rmdir (const char *dir)
/* Under Windows 9X or on a samba share, ERROR_ACCESS_DENIED is
returned if you try to remove a file. On 9X the same error is
returned if you try to remove a non-empty directory. */
- if (GetFileAttributes (real_dir.get_win32()) != FILE_ATTRIBUTE_DIRECTORY)
- set_errno (ENOTDIR);
- else if (os_being_run != winNT)
- set_errno (ENOTEMPTY);
- else
- __seterrno ();
+ int attr = GetFileAttributes (real_dir.get_win32());
+ if (attr != -1 && !(attr & FILE_ATTRIBUTE_DIRECTORY))
+ set_errno (ENOTDIR);
+ else if (os_being_run != winNT)
+ set_errno (ENOTEMPTY);
+ else
+ __seterrno ();
}
else
__seterrno ();
____
| AIST Kazuhiro Fujieda <fujieda@jaist.ac.jp>
| HOKURIKU School of Information Science
o_/ 1990 Japan Advanced Institute of Science and Technology