}
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,
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));
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 {
#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)