feat(filesystem): add get_all_uids() and get_all_gids() methods

This commit is contained in:
Marcus Holland-Moritz 2024-02-07 17:30:44 +01:00
parent 7ded26d6a3
commit d6bd917fae
4 changed files with 46 additions and 0 deletions

View File

@ -189,6 +189,14 @@ class filesystem_v2 {
return impl_->get_all_block_categories();
}
std::vector<file_stat::uid_type> get_all_uids() const {
return impl_->get_all_uids();
}
std::vector<file_stat::gid_type> get_all_gids() const {
return impl_->get_all_gids();
}
void rewrite(progress& prog, filesystem_writer& writer,
category_resolver const& cat_resolver,
rewrite_options const& opts) const {
@ -241,6 +249,8 @@ class filesystem_v2 {
virtual history const& get_history() const = 0;
virtual folly::dynamic get_inode_info(inode_view entry) const = 0;
virtual std::vector<std::string> get_all_block_categories() const = 0;
virtual std::vector<file_stat::uid_type> get_all_uids() const = 0;
virtual std::vector<file_stat::gid_type> get_all_gids() const = 0;
virtual void rewrite(progress& prog, filesystem_writer& writer,
category_resolver const& cat_resolver,
rewrite_options const& opts) const = 0;

View File

@ -151,6 +151,14 @@ class metadata_v2 {
return impl_->get_all_block_categories();
}
std::vector<file_stat::uid_type> get_all_uids() const {
return impl_->get_all_uids();
}
std::vector<file_stat::gid_type> get_all_gids() const {
return impl_->get_all_gids();
}
static std::pair<std::vector<uint8_t>, std::vector<uint8_t>>
freeze(const thrift::metadata::metadata& data);
@ -216,6 +224,10 @@ class metadata_v2 {
get_block_category(size_t block_number) const = 0;
virtual std::vector<std::string> get_all_block_categories() const = 0;
virtual std::vector<file_stat::uid_type> get_all_uids() const = 0;
virtual std::vector<file_stat::gid_type> get_all_gids() const = 0;
};
private:

View File

@ -433,6 +433,12 @@ class filesystem_ final : public filesystem_v2::impl {
std::vector<std::string> get_all_block_categories() const override {
return meta_.get_all_block_categories();
}
std::vector<file_stat::uid_type> get_all_uids() const override {
return meta_.get_all_uids();
}
std::vector<file_stat::gid_type> get_all_gids() const override {
return meta_.get_all_gids();
}
void rewrite(progress& prog, filesystem_writer& writer,
category_resolver const& cat_resolver,
rewrite_options const& opts) const override;

View File

@ -534,6 +534,8 @@ class metadata_ final : public metadata_v2::impl {
get_block_category(size_t block_number) const override;
std::vector<std::string> get_all_block_categories() const override;
std::vector<file_stat::uid_type> get_all_uids() const override;
std::vector<file_stat::gid_type> get_all_gids() const override;
private:
template <typename K>
@ -1766,6 +1768,22 @@ metadata_<LoggerPolicy>::get_all_block_categories() const {
return rv;
}
template <typename LoggerPolicy>
std::vector<file_stat::uid_type> metadata_<LoggerPolicy>::get_all_uids() const {
std::vector<file_stat::uid_type> rv;
rv.resize(meta_.uids().size());
std::copy(meta_.uids().begin(), meta_.uids().end(), rv.begin());
return rv;
}
template <typename LoggerPolicy>
std::vector<file_stat::gid_type> metadata_<LoggerPolicy>::get_all_gids() const {
std::vector<file_stat::gid_type> rv;
rv.resize(meta_.gids().size());
std::copy(meta_.gids().begin(), meta_.gids().end(), rv.begin());
return rv;
}
std::pair<std::vector<uint8_t>, std::vector<uint8_t>>
metadata_v2::freeze(const thrift::metadata::metadata& data) {
return freeze_to_buffer(data);