From: Guillem Jover Date: Fri, 18 Jan 2008 04:41:21 +0000 (+0200) Subject: Additionally check if errno is EEXIST after rmdir(2) X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76877c6f670321ffdff5f35e879ae1f07a335a46;p=dpkg 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. --- diff --git a/ChangeLog b/ChangeLog index f2613576..34000b1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-01-18 Guillem Jover + + * 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 * scripts/update-alternatives.pl: Stop parsing '--test' as a valid diff --git a/debian/changelog b/debian/changelog index 734aada4..d6900193 100644 --- a/debian/changelog +++ b/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 diff --git a/src/help.c b/src/help.c index 5c0b8009..b6401ab9 100644 --- a/src/help.c +++ b/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); diff --git a/src/remove.c b/src/remove.c index 4a431678..e9851702 100644 --- a/src/remove.c +++ b/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"),