]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(wipename): Work even if the directory is writeable
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 9 Aug 2004 23:34:49 +0000 (23:34 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 9 Aug 2004 23:34:49 +0000 (23:34 +0000)
and not readable.  Prefer write access, since this should work
better with fdatasync.

src/shred.c

index 4d3b18d5e3e084d6102469c4b79f5a6c7cfc8256..d9da0bb7b784669fc448a37cd5a7417bb446bbf5 100644 (file)
@@ -1434,10 +1434,13 @@ wipename (char *oldname, char const *qoldname, struct Options const *flags)
   size_t len = base_len (base);
   char *dir = dir_name (newname);
   char *qdir = xstrdup (quotearg_colon (dir));
-  int dir_fd = open (dir, O_RDONLY | O_NOCTTY);
   bool first = true;
   bool ok = true;
 
+  int dir_fd = open (dir, O_WRONLY | O_NOCTTY);
+  if (dir_fd < 0)
+    dir_fd = open (dir, O_RDONLY | O_NOCTTY);
+
   if (flags->verbose)
     error (0, 0, _("%s: removing"), qoldname);