dovecot-2.2: Added UNLINK_EISDIR() helper macro.
dovecot at dovecot.org
dovecot at dovecot.org
Thu Aug 28 14:53:14 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/0ff8d85a6893
changeset: 17756:0ff8d85a6893
user: Timo Sirainen <tss at iki.fi>
date: Thu Aug 28 23:52:46 2014 +0900
description:
Added UNLINK_EISDIR() helper macro.
diffstat:
src/lib-storage/index/maildir/maildir-sync-index.c | 2 +-
src/lib-storage/list/mailbox-list-delete.c | 5 ++---
src/lib/compat.h | 5 +++++
3 files changed, 8 insertions(+), 4 deletions(-)
diffs (49 lines):
diff -r 3bc106fd69d3 -r 0ff8d85a6893 src/lib-storage/index/maildir/maildir-sync-index.c
--- a/src/lib-storage/index/maildir/maildir-sync-index.c Thu Aug 28 23:50:25 2014 +0900
+++ b/src/lib-storage/index/maildir/maildir-sync-index.c Thu Aug 28 23:52:46 2014 +0900
@@ -95,7 +95,7 @@
}
if (errno == ENOENT)
return 0;
- if (errno == EISDIR || errno == EPERM)
+ if (UNLINK_EISDIR(errno))
return maildir_lose_unexpected_dir(box->storage, path);
mail_storage_set_critical(&mbox->storage->storage,
diff -r 3bc106fd69d3 -r 0ff8d85a6893 src/lib-storage/list/mailbox-list-delete.c
--- a/src/lib-storage/list/mailbox-list-delete.c Thu Aug 28 23:50:25 2014 +0900
+++ b/src/lib-storage/list/mailbox-list-delete.c Thu Aug 28 23:52:46 2014 +0900
@@ -200,7 +200,7 @@
so don't bother stat()ing the file first */
if (unlink(str_c(full_path)) == 0)
unlinked_something = TRUE;
- else if (errno != ENOENT && errno != EISDIR && errno != EPERM) {
+ else if (errno != ENOENT && !UNLINK_EISDIR(errno)) {
mailbox_list_set_critical(list,
"unlink_directory(%s) failed: %m",
str_c(full_path));
@@ -343,8 +343,7 @@
if (errno == ENOENT) {
mailbox_list_set_error(list, MAIL_ERROR_NOTFOUND,
T_MAILBOX_LIST_ERR_NOT_FOUND(list, name));
- } else if (errno == EISDIR ||
- errno == EPERM) { /* Solaris */
+ } else if (UNLINK_EISDIR(errno)) {
mailbox_list_set_error(list, MAIL_ERROR_NOTPOSSIBLE,
"Mailbox isn't a symlink");
} else {
diff -r 3bc106fd69d3 -r 0ff8d85a6893 src/lib/compat.h
--- a/src/lib/compat.h Thu Aug 28 23:50:25 2014 +0900
+++ b/src/lib/compat.h Thu Aug 28 23:52:46 2014 +0900
@@ -254,6 +254,11 @@
#define ECANTLINK(errno) \
((errno) == EXDEV || (errno) == EMLINK || (errno) == EPERM)
+/* Returns TRUE if unlink() failed because it attempted to delete a directory */
+#define UNLINK_EISDIR(errno) \
+ ((errno) == EPERM || /* POSIX */ \
+ (errno) == EISDIR) /* Linux */
+
/* EBUSY is given by some NFS implementations */
#define EDESTDIREXISTS(errno) \
((errno) == EEXIST || (errno) == ENOTEMPTY || (errno) == EBUSY)
More information about the dovecot-cvs
mailing list