Mercurial > dovecot > original-hg > dovecot-2.2
changeset 17756:0ff8d85a6893
Added UNLINK_EISDIR() helper macro.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 28 Aug 2014 23:52:46 +0900 |
parents | 3bc106fd69d3 |
children | 2324dea38a03 |
files | src/lib-storage/index/maildir/maildir-sync-index.c src/lib-storage/list/mailbox-list-delete.c src/lib/compat.h |
diffstat | 3 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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,
--- 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 {
--- 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)