]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added UNLINK_EISDIR() helper macro.
authorTimo Sirainen <tss@iki.fi>
Thu, 28 Aug 2014 14:52:46 +0000 (23:52 +0900)
committerTimo Sirainen <tss@iki.fi>
Thu, 28 Aug 2014 14:52:46 +0000 (23:52 +0900)
src/lib-storage/index/maildir/maildir-sync-index.c
src/lib-storage/list/mailbox-list-delete.c
src/lib/compat.h

index f2be00e220afc890b523cd156e40b8e0baac53c8..dc344929187ec4195e36af31ac55dad6c623c1b8 100644 (file)
@@ -95,7 +95,7 @@ static int maildir_expunge(struct maildir_mailbox *mbox, const char *path,
        }
        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,
index a295dceaae7c9b1cbaf6d0f1878a755ea16b9206..b1a5368797ed4aaedbcdc6c9a45bafd8e19c70e7 100644 (file)
@@ -200,7 +200,7 @@ int mailbox_list_delete_mailbox_nonrecursive(struct mailbox_list *list,
                   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 @@ int mailbox_list_delete_symlink_default(struct mailbox_list *list,
        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 {
index e13165620a5b2cb74e4f6839ec2061a30678cf6c..2abdee70bc7035c3a3b0acfd057421826fd6d578 100644 (file)
@@ -254,6 +254,11 @@ int i_my_clock_gettime(int clk_id, struct timespec *tp);
 #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)