diff --git a/include/bcachefs.h b/include/bcachefs.h index 77f90b81..94a4d80f 100644 --- a/include/bcachefs.h +++ b/include/bcachefs.h @@ -34,6 +34,8 @@ public: FS get_filesystem_support(); void set_used_sectors(Partition& partition); bool create(const Partition& new_partition, OperationDetail& operationdetail); + void read_label(Partition& partition); + void read_uuid(Partition& partition); }; diff --git a/src/bcachefs.cc b/src/bcachefs.cc index 3660ed95..f8c1f082 100644 --- a/src/bcachefs.cc +++ b/src/bcachefs.cc @@ -43,6 +43,8 @@ FS bcachefs::get_filesystem_support() fs.online_read = FS::EXTERNAL; fs.create = FS::EXTERNAL; fs.create_with_label = FS::EXTERNAL; + fs.read_label = FS::EXTERNAL; + fs.read_uuid = FS::EXTERNAL; } fs_limits.min_size = 32 * MEBIBYTE; @@ -95,4 +97,38 @@ bool bcachefs::create(const Partition& new_partition, OperationDetail& operation } +void bcachefs::read_label(Partition& partition) +{ + exit_status = Utils::execute_command("bcachefs show-super " + Glib::shell_quote(partition.get_path()), + output, error, true); + if (exit_status != 0) + { + if (! output.empty()) + partition.push_back_message(output); + if (! error.empty()) + partition.push_back_message(error); + return; + } + + partition.set_filesystem_label(Utils::regexp_label(output, "^Label:[[:blank:]]*(.*)$")); +} + + +void bcachefs::read_uuid(Partition& partition) +{ + exit_status = Utils::execute_command("bcachefs show-super " + Glib::shell_quote(partition.get_path()), + output, error, true); + if (exit_status != 0) + { + if (! output.empty()) + partition.push_back_message(output); + if (! error.empty()) + partition.push_back_message(error); + return; + } + + partition.uuid = Utils::regexp_label(output, "^External UUID: *(" RFC4122_NONE_NIL_UUID_REGEXP ")"); +} + + } //GParted