diff -r 0a5e583393e1 -r 56ff755c268c librazor/atomic-actions.c --- a/librazor/atomic-actions.c Tue Sep 09 15:27:12 2014 +0100 +++ b/librazor/atomic-actions.c Sat Oct 04 18:12:58 2014 +0100 @@ -247,6 +247,7 @@ struct atomic_action *action) { mode_t mode; + struct stat buf; if (razor_atomic_in_error_state(atomic)) { atomic_action_free(action); @@ -256,16 +257,22 @@ mode = action->args.u.create_dir.mode & (S_IRWXU | S_IRWXG | S_IRWXO); if (!mkdir(action->args.path, mode)) - return 0; + return action; - if (errno != EEXIST || chmod(action->args.path, mode) < 0) { + if (errno != EEXIST || stat(action->args.path, &buf)) { if (!atomic->error) atomic->error = razor_error_new_posix(action->args.path); atomic_action_free(action); return NULL; } - return action; + if (!S_ISDIR(buf.st_mode) && !atomic->error) + atomic->error = razor_error_new_str(RAZOR_POSIX_ERROR, EEXIST, + action->args.path, + "Not a directory"); + + atomic_action_free(action); + return NULL; } static struct atomic_action *atomic_action_rmdir(struct razor_atomic *atomic,