🧹 gucc: move partition struct into own header

This commit is contained in:
Vladislav Nepogodin 2024-06-30 23:50:26 +04:00
parent a8af65e38b
commit f5f8886e00
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
2 changed files with 36 additions and 24 deletions

View File

@ -1,37 +1,16 @@
#ifndef FSTAB_HPP
#define FSTAB_HPP
#include <optional> // for optional
#include "gucc/partition.hpp"
#include <string> // for string
#include <string_view> // for string_view
#include <vector> // for vector
namespace gucc::fs {
struct Partition final {
std::string fstype;
std::string mountpoint;
std::string uuid_str;
std::string device;
// mount points that will be written in fstab,
// excluding subvol={subvol name}
// if device is ssd, mount options for ssd should be appended
std::string mount_opts;
std::optional<std::string> luks_mapper_name;
std::optional<std::string> luks_uuid;
/*
// subvolumes per partition
// e.g we have partition /dev/nvme0n1p1 with subvolumes: /@, /@home, /@cache
std::optional<std::vector<BtrfsSubvolume>> subvols;
*/
// subvolume name if the partition is btrrfs subvolume
std::optional<std::string> subvolume;
};
// Generate fstab
auto generate_fstab(const std::vector<Partition>& partitions, std::string_view root_mountpoint, std::string_view crypttab_opts) noexcept -> bool;
auto generate_fstab(const std::vector<Partition>& partitions, std::string_view root_mountpoint) noexcept -> bool;
// Generate fstab into string
auto generate_fstab_content(const std::vector<Partition>& partitions) noexcept -> std::string;

View File

@ -0,0 +1,33 @@
#ifndef PARTITION_HPP
#define PARTITION_HPP
#include <optional> // for optional
#include <string> // for string
namespace gucc::fs {
struct Partition final {
std::string fstype;
std::string mountpoint;
std::string uuid_str;
std::string device;
// mount points that will be written in fstab,
// excluding subvol={subvol name}
// if device is ssd, mount options for ssd should be appended
std::string mount_opts;
std::optional<std::string> luks_mapper_name;
std::optional<std::string> luks_uuid;
/*
// subvolumes per partition
// e.g we have partition /dev/nvme0n1p1 with subvolumes: /@, /@home, /@cache
std::optional<std::vector<BtrfsSubvolume>> subvols;
*/
// subvolume name if the partition is btrrfs subvolume
std::optional<std::string> subvolume;
};
} // namespace gucc::fs
#endif // PARTITION_HPP