mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-09 20:41:04 -04:00
Fix rewrite of file system
This commit is contained in:
parent
9b4f365828
commit
fc4f1546b2
@ -111,10 +111,11 @@ class filesystem_parser {
|
|||||||
using section_map =
|
using section_map =
|
||||||
std::unordered_map<section_type, filesystem_parser::section>;
|
std::unordered_map<section_type, filesystem_parser::section>;
|
||||||
|
|
||||||
folly::ByteRange get_section_data(std::shared_ptr<mmif> mm,
|
folly::ByteRange
|
||||||
|
get_section_data(std::shared_ptr<mmif> mm,
|
||||||
filesystem_parser::section const& section,
|
filesystem_parser::section const& section,
|
||||||
std::vector<uint8_t>& buffer) {
|
std::vector<uint8_t>& buffer, bool force_buffer) {
|
||||||
if (section.header.compression == compression_type::NONE) {
|
if (!force_buffer && section.header.compression == compression_type::NONE) {
|
||||||
return mm->range(section.start, section.header.length);
|
return mm->range(section.start, section.header.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +131,7 @@ make_metadata(logger& lgr, std::shared_ptr<mmif> mm,
|
|||||||
section_map const& sections, std::vector<uint8_t>& schema_buffer,
|
section_map const& sections, std::vector<uint8_t>& schema_buffer,
|
||||||
std::vector<uint8_t>& meta_buffer,
|
std::vector<uint8_t>& meta_buffer,
|
||||||
const struct ::stat* stat_defaults = nullptr,
|
const struct ::stat* stat_defaults = nullptr,
|
||||||
int inode_offset = 0) {
|
int inode_offset = 0, bool force_buffers = false) {
|
||||||
auto schema_it = sections.find(section_type::METADATA_V2_SCHEMA);
|
auto schema_it = sections.find(section_type::METADATA_V2_SCHEMA);
|
||||||
auto meta_it = sections.find(section_type::METADATA_V2);
|
auto meta_it = sections.find(section_type::METADATA_V2);
|
||||||
|
|
||||||
@ -142,9 +143,10 @@ make_metadata(logger& lgr, std::shared_ptr<mmif> mm,
|
|||||||
throw std::runtime_error("no metadata found");
|
throw std::runtime_error("no metadata found");
|
||||||
}
|
}
|
||||||
|
|
||||||
return metadata_v2(lgr,
|
return metadata_v2(
|
||||||
get_section_data(mm, schema_it->second, schema_buffer),
|
lgr,
|
||||||
get_section_data(mm, meta_it->second, meta_buffer),
|
get_section_data(mm, schema_it->second, schema_buffer, force_buffers),
|
||||||
|
get_section_data(mm, meta_it->second, meta_buffer, force_buffers),
|
||||||
stat_defaults, inode_offset);
|
stat_defaults, inode_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +360,8 @@ void filesystem_v2::rewrite(logger& lgr, progress& prog,
|
|||||||
|
|
||||||
std::vector<uint8_t> schema_raw;
|
std::vector<uint8_t> schema_raw;
|
||||||
std::vector<uint8_t> meta_raw;
|
std::vector<uint8_t> meta_raw;
|
||||||
auto meta = make_metadata(lgr, mm, sections, schema_raw, meta_raw);
|
auto meta =
|
||||||
|
make_metadata(lgr, mm, sections, schema_raw, meta_raw, nullptr, 0, true);
|
||||||
|
|
||||||
struct ::statvfs stbuf;
|
struct ::statvfs stbuf;
|
||||||
meta.statvfs(&stbuf);
|
meta.statvfs(&stbuf);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user