public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: rmdir: handle /dev in fhandler_dev::rmdir
@ 2021-01-19  9:54 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2021-01-19  9:54 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=877f0d13f0f6c6cc8b7988951edac73709d82861

commit 877f0d13f0f6c6cc8b7988951edac73709d82861
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Tue Jan 19 10:50:36 2021 +0100

    Cygwin: rmdir: handle /dev in fhandler_dev::rmdir
    
    The isdev_dev check in rmdir is unclean.  Create a virtual method
    fhandler_dev::rmdir to handle this transparently.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/dir.cc          | 2 --
 winsup/cygwin/fhandler.h      | 1 +
 winsup/cygwin/fhandler_dev.cc | 7 +++++++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index f912a9e47..7762557d6 100644
--- a/winsup/cygwin/dir.cc
+++ b/winsup/cygwin/dir.cc
@@ -410,8 +410,6 @@ rmdir (const char *dir)
 	set_errno (ENOENT);
       else if (has_dot_last_component (dir, false))
 	set_errno (EINVAL);
-      else if (isdev_dev (fh->dev ()))
-	set_errno (ENOTEMPTY);
       else if (!fh->rmdir ())
 	res = 0;
       delete fh;
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index e1829e28f..af1ef3a45 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -1765,6 +1765,7 @@ public:
   int close ();
   int __reg2 fstat (struct stat *buf);
   int __reg2 fstatvfs (struct statvfs *buf);
+  int rmdir ();
   DIR __reg2 *opendir (int fd);
   int __reg3 readdir (DIR *, dirent *);
   void rewinddir (DIR *);
diff --git a/winsup/cygwin/fhandler_dev.cc b/winsup/cygwin/fhandler_dev.cc
index 28b0e3cf0..5fd75a58e 100644
--- a/winsup/cygwin/fhandler_dev.cc
+++ b/winsup/cygwin/fhandler_dev.cc
@@ -107,6 +107,13 @@ fhandler_dev::fstatvfs (struct statvfs *sfs)
   return ret;
 }
 
+int
+fhandler_dev::rmdir ()
+{
+  set_errno (ENOTEMPTY);
+  return -1;
+}
+
 DIR *
 fhandler_dev::opendir (int fd)
 {


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-19  9:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-19  9:54 [newlib-cygwin] Cygwin: rmdir: handle /dev in fhandler_dev::rmdir Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).