Просмотр исходного кода

Additionally check if errno is EEXIST after rmdir(2)

SUSv3 specifies that on non-empty directories it can either return
that or ENOTEMPTY. This should fix run time problems on Solaris.
Guillem Jover лет назад: 18
Родитель
Сommit
76877c6f67
4 измененных файлов с 14 добавлено и 3 удалено
  1. 8 0
      ChangeLog
  2. 3 0
      debian/changelog
  3. 1 1
      src/help.c
  4. 2 2
      src/remove.c

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-01-18  Guillem Jover  <guillem@debian.org>
+
+	* src/remove.c (ensure_pathname_nonexisting): Additionally check if
+	errno is EEXIST after calling rmdir, per SUSv3 when the directory
+	is not empty errno can be ENOTEMPTY or EEXIST.
+	* src/help.c (removal_bulk_remove_files): Likewise.
+	(removal_bulk_remove_leftover_dirs): Likewise.
+
 2008-01-18  Guillem Jover  <guillem@debian.org>
 
 	* scripts/update-alternatives.pl: Stop parsing '--test' as a valid

+ 3 - 0
debian/changelog

@@ -16,6 +16,9 @@ dpkg (1.14.16) UNRELEASED; urgency=low
     Based on a patch by Samuel Thibault.
   * Remove unimplemented --test option from update-alternatives.
     Closes: #392432, #461247
+  * Additionally check if errno is EEXIST after rmdir(2), as SUSv3 specifies
+    that on non-empty directories it can either return that or ENOTEMPTY.
+    This fixes run time problems on Solaris.
 
   [ Frank Lichtenheld ]
   * Make the -L option of dpkg-parsechangelog actually work (it's

+ 1 - 1
src/help.c

@@ -510,7 +510,7 @@ void ensure_pathname_nonexisting(const char *pathname) {
     if (!chmodsafe_unlink(pathname, &failed)) return; /* OK, it was */
     if (errno == ENOTDIR) return;
   }
-  if (errno != ENOTEMPTY) { /* Huh ? */
+  if (errno != ENOTEMPTY && errno != EEXIST) { /* Huh ? */
     char mbuf[250];
     snprintf(mbuf, sizeof(mbuf), N_("failed to %s `%%.255s'"), failed);
     ohshite(_(mbuf),pathname);

+ 2 - 2
src/remove.c

@@ -249,7 +249,7 @@ static void removal_bulk_remove_files(
       }
       debug(dbg_eachfiledetail, "removal_bulk removing `%s'", fnvb.buf);
       if (!rmdir(fnvb.buf) || errno == ENOENT || errno == ELOOP) continue;
-      if (errno == ENOTEMPTY) {
+      if (errno == ENOTEMPTY || errno == EEXIST) {
 	debug(dbg_eachfiledetail, "removal_bulk `%s' was not empty, will try again later",
 	      fnvb.buf);
         push_leftover(&leftover,namenode);
@@ -364,7 +364,7 @@ static void removal_bulk_remove_leftover_dirs(struct pkginfo *pkg) {
 
     debug(dbg_eachfiledetail, "removal_bulk removing `%s'", fnvb.buf);
     if (!rmdir(fnvb.buf) || errno == ENOENT || errno == ELOOP) continue;
-    if (errno == ENOTEMPTY) {
+    if (errno == ENOTEMPTY || errno == EEXIST) {
       fprintf(stderr,
               _("dpkg - warning: while removing %.250s, directory `%.250s' not empty "
               "so not removed.\n"),