1.1 --- a/librazor/atomic-actions.c Tue Sep 09 15:27:12 2014 +0100
1.2 +++ b/librazor/atomic-actions.c Fri Oct 17 09:57:19 2014 +0100
1.3 @@ -247,6 +247,7 @@
1.4 struct atomic_action *action)
1.5 {
1.6 mode_t mode;
1.7 + struct stat buf;
1.8
1.9 if (razor_atomic_in_error_state(atomic)) {
1.10 atomic_action_free(action);
1.11 @@ -256,16 +257,22 @@
1.12 mode = action->args.u.create_dir.mode & (S_IRWXU | S_IRWXG | S_IRWXO);
1.13
1.14 if (!mkdir(action->args.path, mode))
1.15 - return 0;
1.16 + return action;
1.17
1.18 - if (errno != EEXIST || chmod(action->args.path, mode) < 0) {
1.19 + if (errno != EEXIST || stat(action->args.path, &buf)) {
1.20 if (!atomic->error)
1.21 atomic->error = razor_error_new_posix(action->args.path);
1.22 atomic_action_free(action);
1.23 return NULL;
1.24 }
1.25
1.26 - return action;
1.27 + if (!S_ISDIR(buf.st_mode) && !atomic->error)
1.28 + atomic->error = razor_error_new_str(RAZOR_POSIX_ERROR, EEXIST,
1.29 + action->args.path,
1.30 + "Not a directory");
1.31 +
1.32 + atomic_action_free(action);
1.33 + return NULL;
1.34 }
1.35
1.36 static struct atomic_action *atomic_action_rmdir(struct razor_atomic *atomic,