static int tar_import_fork_tar(TarImport *i) { int r; assert(i); assert(!i->final_path); assert(!i->temp_path); assert(i->tar_fd < 0); i->final_path = strjoin(i->image_root, "/", i->local); if (!i->final_path) return log_oom(); r = tempfn_random(i->final_path, NULL, &i->temp_path); if (r < 0) return log_oom(); (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 (void) import_assign_pool_quota_and_warn(i->temp_path); i->tar_fd = import_fork_tar_x(i->temp_path, &i->tar_pid); if (i->tar_fd < 0) return i->tar_fd; return 0; }
static int tar_pull_job_on_open_disk_tar(PullJob *j) { TarPull *i; int r; assert(j); assert(j->userdata); i = j->userdata; assert(i->tar_job == j); assert(i->tar_pid <= 0); if (!i->temp_path) { r = tempfn_random_child(i->image_root, "tar", &i->temp_path); if (r < 0) return log_oom(); } 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 (void) import_assign_pool_quota_and_warn(i->temp_path); j->disk_fd = import_fork_tar_x(i->temp_path, &i->tar_pid); if (j->disk_fd < 0) return j->disk_fd; return 0; }