🚧 gucc: add helper function to get UUID of device/part

This commit is contained in:
Vladislav Nepogodin 2024-07-28 19:52:06 +04:00
parent a905a9ebe7
commit 45ade9ed50
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
2 changed files with 7 additions and 0 deletions

View File

@ -12,6 +12,9 @@ auto get_mountpoint_fs(std::string_view mountpoint) noexcept -> std::string;
// Get SOURCE of mountpoint // Get SOURCE of mountpoint
auto get_mountpoint_source(std::string_view mountpoint) noexcept -> std::string; auto get_mountpoint_source(std::string_view mountpoint) noexcept -> std::string;
// Get UUID of device/partition
auto get_device_uuid(std::string_view device) noexcept -> std::string;
} // namespace gucc::fs::utils } // namespace gucc::fs::utils
#endif // FS_UTILS_HPP #endif // FS_UTILS_HPP

View File

@ -16,4 +16,8 @@ auto get_mountpoint_source(std::string_view mountpoint) noexcept -> std::string
return gucc::utils::exec(fmt::format(FMT_COMPILE("findmnt -ln -o SOURCE \"{}\""), mountpoint)); return gucc::utils::exec(fmt::format(FMT_COMPILE("findmnt -ln -o SOURCE \"{}\""), mountpoint));
} }
auto get_device_uuid(std::string_view device) noexcept -> std::string {
return gucc::utils::exec(fmt::format(FMT_COMPILE("lsblk -o UUID '{}' | awk 'NR==2'"), device));
}
} // namespace gucc::fs::utils } // namespace gucc::fs::utils