[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-tar] ported GNU tar to Solaris 10's treatment of unlinking director
From: |
Paul Eggert |
Subject: |
[Bug-tar] ported GNU tar to Solaris 10's treatment of unlinking directories |
Date: |
Sat, 14 May 2005 23:26:25 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) |
I installed this. It uses the new unlinkdir module of gnulib.
2005-05-14 Paul Eggert <address@hidden>
Port to Solaris 10's treatment of unlinking directories.
* gnulib-modules: Add unlinkdir.
* lib/.cvsignore: Add unlinkdir.h, unlinkdir.c.
* src/common.h (we_are_root): Remove extern decl; it's now static.
* src/extract.c (we_are_root): Now static.
* src/misc.c: Include <unlinkdir.h>.
(remove_any_file): Use cannot_unlink_dir () rather than we_are_root.
Index: gnulib.modules
===================================================================
RCS file: /cvsroot/tar/tar/gnulib.modules,v
retrieving revision 1.1
diff -p -u -b -r1.1 gnulib.modules
--- gnulib.modules 6 Feb 2005 20:00:09 -0000 1.1
+++ gnulib.modules 15 May 2005 06:22:47 -0000
@@ -37,6 +37,7 @@ stpcpy
strtol
strtoul
timespec
+unlinkdir
unlocked-io
utime
xalloc
Index: lib/.cvsignore
===================================================================
RCS file: /cvsroot/tar/tar/lib/.cvsignore,v
retrieving revision 1.20
diff -p -u -b -r1.20 .cvsignore
--- lib/.cvsignore 12 May 2005 15:46:18 -0000 1.20
+++ lib/.cvsignore 15 May 2005 06:22:47 -0000
@@ -145,6 +145,8 @@ time_r.c
time_r.h
timespec.h
unistd-safer.h
+unlinkdir.c
+unlinkdir.h
unlocked-io.h
unsetenv.c
utime.c
@@ -163,4 +165,3 @@ xstrtol.c
xstrtol.h
xstrtoul.c
xstrtoumax.c
-
Index: src/common.h
===================================================================
RCS file: /cvsroot/tar/tar/src/common.h,v
retrieving revision 1.51
diff -p -u -b -r1.51 common.h
--- src/common.h 15 May 2005 03:59:09 -0000 1.51
+++ src/common.h 15 May 2005 06:22:47 -0000
@@ -441,7 +441,6 @@ void verify_volume (void);
/* Module extract.c. */
-extern bool we_are_root;
void extr_init (void);
void extract_archive (void);
void extract_finish (void);
Index: src/extract.c
===================================================================
RCS file: /cvsroot/tar/tar/src/extract.c,v
retrieving revision 1.75
diff -p -u -b -r1.75 extract.c
--- src/extract.c 15 May 2005 03:59:09 -0000 1.75
+++ src/extract.c 15 May 2005 06:22:47 -0000
@@ -36,7 +36,7 @@ struct utimbuf
#include "common.h"
-bool we_are_root; /* true if our effective uid == 0 */
+static bool we_are_root; /* true if our effective uid == 0 */
static mode_t newdir_umask; /* umask when creating new directories */
static mode_t current_umask; /* current umask (which is set to 0 if -p) */
Index: src/misc.c
===================================================================
RCS file: /cvsroot/tar/tar/src/misc.c,v
retrieving revision 1.28
diff -p -u -b -r1.28 misc.c
--- src/misc.c 15 May 2005 03:59:10 -0000 1.28
+++ src/misc.c 15 May 2005 06:22:47 -0000
@@ -22,6 +22,7 @@
#include "common.h"
#include <quotearg.h>
#include <save-cwd.h>
+#include <unlinkdir.h>
static void call_arg_fatal (char const *, char const *)
__attribute__ ((noreturn));
@@ -268,9 +269,10 @@ safer_rmdir (const char *file_name)
int
remove_any_file (const char *file_name, enum remove_option option)
{
- /* Try unlink first if we are not root, as this saves us a system
- call in the common case where we're removing a non-directory. */
- if (! we_are_root)
+ /* Try unlink first if we cannot unlink directories, as this saves
+ us a system call in the common case where we're removing a
+ non-directory. */
+ if (cannot_unlink_dir ())
{
if (unlink (file_name) == 0)
return 1;
@@ -288,7 +290,7 @@ remove_any_file (const char *file_name,
switch (errno)
{
case ENOTDIR:
- return we_are_root && unlink (file_name) == 0;
+ return cannot_unlink_dir () && unlink (file_name) == 0;
case 0:
case EEXIST:
- [Bug-tar] ported GNU tar to Solaris 10's treatment of unlinking directories,
Paul Eggert <=