]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
import: use our new btrfs_subvol_make_fallback() at two places
authorLennart Poettering <lennart@poettering.net>
Thu, 9 Apr 2020 09:57:00 +0000 (11:57 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 9 Apr 2020 10:13:08 +0000 (12:13 +0200)
src/import/import-tar.c
src/import/pull-tar.c

index 1e50d31bc2bbf32023fd6060311030458cd847c6..5d2bf22fb25d7d5d27ee561aaf1edfa5506f9fb4 100644 (file)
@@ -220,13 +220,10 @@ static int tar_import_fork_tar(TarImport *i) {
 
         (void) mkdir_parents_label(i->temp_path, 0700);
 
-        r = btrfs_subvol_make(i->temp_path);
-        if (r == -ENOTTY) {
-                if (mkdir(i->temp_path, 0755) < 0)
-                        return log_error_errno(errno, "Failed to create directory %s: %m", i->temp_path);
-        } else if (r < 0)
-                return log_error_errno(r, "Failed to create subvolume %s: %m", i->temp_path);
-        else
+        r = btrfs_subvol_make_fallback(i->temp_path, 0755);
+        if (r < 0)
+                return log_error_errno(r, "Failed to create directory/subvolume %s: %m", i->temp_path);
+        if (r > 0) /* actually btrfs subvol */
                 (void) import_assign_pool_quota_and_warn(i->temp_path);
 
         i->tar_fd = import_fork_tar_x(i->temp_path, &i->tar_pid);
index 3930578a8cee3a6f58ac6970266cffbf2ee8e079..ede28bee1b1d0c88a856bb75b881062af3f0f218 100644 (file)
@@ -415,13 +415,10 @@ static int tar_pull_job_on_open_disk_tar(PullJob *j) {
 
         mkdir_parents_label(i->temp_path, 0700);
 
-        r = btrfs_subvol_make(i->temp_path);
-        if (r == -ENOTTY) {
-                if (mkdir(i->temp_path, 0755) < 0)
-                        return log_error_errno(errno, "Failed to create directory %s: %m", i->temp_path);
-        } else if (r < 0)
-                return log_error_errno(r, "Failed to create subvolume %s: %m", i->temp_path);
-        else
+        r = btrfs_subvol_make_fallback(i->temp_path, 0755);
+        if (r < 0)
+                return log_error_errno(r, "Failed to create directory/subvolume %s: %m", i->temp_path);
+        if (r > 0) /* actually btrfs subvol */
                 (void) import_assign_pool_quota_and_warn(i->temp_path);
 
         j->disk_fd = import_fork_tar_x(i->temp_path, &i->tar_pid);