dovecot-2.0: Handle rmdir() failing with EEXIST the same as fail...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Jul 12 17:14:49 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/6ebe8d8fd1fd
changeset: 11800:6ebe8d8fd1fd
user: Timo Sirainen <tss at iki.fi>
date: Mon Jul 12 15:14:45 2010 +0100
description:
Handle rmdir() failing with EEXIST the same as failing with ENOTEMPTY.
This is allowed by POSIX, and at least Solaris does that.
diffstat:
src/lib-storage/list/mailbox-list-delete.c | 5 +++--
src/lib-storage/list/mailbox-list-fs.c | 12 +++++++-----
src/lib/unlink-directory.c | 14 ++++++++++++--
3 files changed, 22 insertions(+), 9 deletions(-)
diffs (98 lines):
diff -r 30317b89b101 -r 6ebe8d8fd1fd src/lib-storage/list/mailbox-list-delete.c
--- a/src/lib-storage/list/mailbox-list-delete.c Mon Jul 12 15:11:18 2010 +0100
+++ b/src/lib-storage/list/mailbox-list-delete.c Mon Jul 12 15:14:45 2010 +0100
@@ -219,7 +219,8 @@
if (rmdir_path) {
if (rmdir(path) == 0)
unlinked_something = TRUE;
- else if (errno != ENOENT && errno != ENOTEMPTY) {
+ else if (errno != ENOENT &&
+ errno != ENOTEMPTY && errno != EEXIST) {
mailbox_list_set_critical(list, "rmdir(%s) failed: %m",
path);
return -1;
@@ -260,7 +261,7 @@
}
while (strcmp(path, root_dir) != 0) {
if (rmdir(path) < 0 && errno != ENOENT) {
- if (errno == ENOTEMPTY)
+ if (errno == ENOTEMPTY || errno == EEXIST)
return;
mailbox_list_set_critical(list, "rmdir(%s) failed: %m",
diff -r 30317b89b101 -r 6ebe8d8fd1fd src/lib-storage/list/mailbox-list-fs.c
--- a/src/lib-storage/list/mailbox-list-fs.c Mon Jul 12 15:11:18 2010 +0100
+++ b/src/lib-storage/list/mailbox-list-fs.c Mon Jul 12 15:14:45 2010 +0100
@@ -391,7 +391,8 @@
/* try to delete the parent directory */
path = mailbox_list_get_path(list, name,
MAILBOX_LIST_PATH_TYPE_DIR);
- if (rmdir(path) < 0 && errno != ENOENT && errno != ENOTEMPTY) {
+ if (rmdir(path) < 0 && errno != ENOENT &&
+ errno != ENOTEMPTY && errno != EEXIST) {
mailbox_list_set_critical(list, "rmdir(%s) failed: %m",
path);
}
@@ -435,7 +436,7 @@
if (errno == ENOENT) {
mailbox_list_set_error(list, MAIL_ERROR_NOTFOUND,
T_MAIL_ERR_MAILBOX_NOT_FOUND(name));
- } else if (errno == ENOTEMPTY) {
+ } else if (errno == ENOTEMPTY || errno == EEXIST) {
/* mbox workaround: if only .imap/ directory is preventing the
deletion, remove it */
child_name = t_strdup_printf("%s%cchild", name,
@@ -479,8 +480,8 @@
}
if (rmdir_parent && (p = strrchr(oldpath, '/')) != NULL) {
oldpath = t_strdup_until(oldpath, p);
- if (rmdir(oldpath) < 0 &&
- errno != ENOENT && errno != ENOTEMPTY) {
+ if (rmdir(oldpath) < 0 && errno != ENOENT &&
+ errno != ENOTEMPTY && errno != EEXIST) {
mailbox_list_set_critical(oldlist,
"rmdir(%s) failed: %m", oldpath);
}
@@ -603,7 +604,8 @@
MAILBOX_LIST_PATH_TYPE_DIR);
if (rmdir(oldpath) == 0)
rmdir_parent = TRUE;
- else if (errno != ENOENT && errno != ENOTEMPTY) {
+ else if (errno != ENOENT &&
+ errno != ENOTEMPTY && errno != EEXIST) {
mailbox_list_set_critical(oldlist,
"rmdir(%s) failed: %m", oldpath);
}
diff -r 30317b89b101 -r 6ebe8d8fd1fd src/lib/unlink-directory.c
--- a/src/lib/unlink-directory.c Mon Jul 12 15:11:18 2010 +0100
+++ b/src/lib/unlink-directory.c Mon Jul 12 15:14:45 2010 +0100
@@ -117,8 +117,13 @@
break;
if (rmdir(d->d_name) < 0) {
- if (errno != ENOENT)
+ if (errno != ENOENT) {
+ if (errno == EEXIST) {
+ /* standardize errno */
+ errno = ENOTEMPTY;
+ }
break;
+ }
errno = 0;
}
} else {
@@ -169,8 +174,13 @@
}
if (unlink_dir) {
- if (rmdir(dir) < 0 && errno != ENOENT)
+ if (rmdir(dir) < 0 && errno != ENOENT) {
+ if (errno == EEXIST) {
+ /* standardize errno */
+ errno = ENOTEMPTY;
+ }
return -1;
+ }
}
return 0;
More information about the dovecot-cvs
mailing list