1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 00:51:24 +03:00

tmpfiles: don't fail if we cannot create a subvolume because a file system is read-only but a dir already exists anyway

https://bugs.freedesktop.org/show_bug.cgi?id=90281
This commit is contained in:
Lennart Poettering 2015-05-15 21:47:22 +02:00
parent 0fef704c6f
commit 7b135a7399

View File

@ -1214,20 +1214,25 @@ static int create_item(Item *i) {
r = mkdir_label(i->path, i->mode); r = mkdir_label(i->path, i->mode);
if (r < 0) { if (r < 0) {
if (r != -EEXIST) int k;
if (r != -EEXIST && r != -EROFS)
return log_error_errno(r, "Failed to create directory or subvolume \"%s\": %m", i->path); return log_error_errno(r, "Failed to create directory or subvolume \"%s\": %m", i->path);
if (stat(i->path, &st) < 0) k = is_dir(i->path, false);
return log_error_errno(errno, "stat(%s) failed: %m", i->path); if (k == -ENOENT && r == -EROFS)
return log_error_errno(r, "%s does not exist and cannot be created as the file system is read-only.", i->path);
if (!S_ISDIR(st.st_mode)) { if (k < 0)
log_debug("\"%s\" already exists and is not a directory.", i->path); return log_error_errno(k, "Failed to check if %s exists: %m", i->path);
if (!k) {
log_warning("\"%s\" already exists and is not a directory.", i->path);
return 0; return 0;
} }
creation = CREATION_EXISTING; creation = CREATION_EXISTING;
} else } else
creation = CREATION_NORMAL; creation = CREATION_NORMAL;
log_debug("%s directory \"%s\".", creation_mode_verb_to_string(creation), i->path); log_debug("%s directory \"%s\".", creation_mode_verb_to_string(creation), i->path);
r = path_set_perms(i, i->path); r = path_set_perms(i, i->path);