From 09f9d297f71fd5d930f030dbdce2cbe2dbe88a0c Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Sun, 5 Jan 2025 17:19:01 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20disk:=20refactor=20zfs=20pool=20?= =?UTF-8?q?creation=20using=20gucc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/disk.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/disk.cpp b/src/disk.cpp index 0b65982..c978dee 100644 --- a/src/disk.cpp +++ b/src/disk.cpp @@ -239,22 +239,17 @@ bool zfs_create_zpool(const std::string_view& partition, const std::string_view& static constexpr auto zpool_options{"-f -o ashift=12 -o autotrim=on -O acltype=posixacl -O compression=zstd -O atime=off -O relatime=off -O normalization=formD -O xattr=sa -O mountpoint=none"sv}; #ifdef NDEVENV - std::int32_t ret_code{}; + std::string device_path{partition}; // Find the UUID of the partition const auto& partuuid = gucc::utils::exec(fmt::format(FMT_COMPILE("lsblk -lno PATH,PARTUUID | grep \"^{}\" | {}"), partition, "awk '{print $2}'"sv), false); // See if the partition has a partuuid, if not use the device name - const auto& zfs_zpool_cmd = fmt::format(FMT_COMPILE("zpool create {} {}"), zpool_options, pool_name); if (!partuuid.empty()) { - ret_code = utils::to_int(gucc::utils::exec(fmt::format(FMT_COMPILE("{} {} 2>>/tmp/cachyos-install.log"), zfs_zpool_cmd, partuuid), true)); - spdlog::info("Creating zpool {} on device {} using partuuid {}", pool_name, partition, partuuid); - } else { - ret_code = utils::to_int(gucc::utils::exec(fmt::format(FMT_COMPILE("{} {} 2>>/tmp/cachyos-install.log"), zfs_zpool_cmd, partition), true)); - spdlog::info("Creating zpool {} on device {}", pool_name, partition); + device_path = partuuid; } - if (ret_code != 0) { + if (!gucc::fs::zfs_create_zpool(device_path, pool_name, zpool_options)) { spdlog::error("Failed to create zpool!"); return false; }