mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-14 06:48:39 -04:00
refactor: simpler ways to construct filesystem_v2
This commit is contained in:
parent
0987dba63d
commit
dc4ccadd53
@ -59,6 +59,14 @@ class filesystem_v2 {
|
|||||||
public:
|
public:
|
||||||
filesystem_v2() = default;
|
filesystem_v2() = default;
|
||||||
|
|
||||||
|
filesystem_v2(logger& lgr, os_access const& os,
|
||||||
|
std::filesystem::path const& path);
|
||||||
|
|
||||||
|
filesystem_v2(logger& lgr, os_access const& os,
|
||||||
|
std::filesystem::path const& path,
|
||||||
|
filesystem_options const& options,
|
||||||
|
std::shared_ptr<performance_monitor const> perfmon = nullptr);
|
||||||
|
|
||||||
filesystem_v2(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm);
|
filesystem_v2(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm);
|
||||||
|
|
||||||
filesystem_v2(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm,
|
filesystem_v2(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm,
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include <dwarfs/logger.h>
|
#include <dwarfs/logger.h>
|
||||||
#include <dwarfs/mmif.h>
|
#include <dwarfs/mmif.h>
|
||||||
#include <dwarfs/options.h>
|
#include <dwarfs/options.h>
|
||||||
|
#include <dwarfs/os_access.h>
|
||||||
#include <dwarfs/performance_monitor.h>
|
#include <dwarfs/performance_monitor.h>
|
||||||
#include <dwarfs/util.h>
|
#include <dwarfs/util.h>
|
||||||
#include <dwarfs/writer_progress.h>
|
#include <dwarfs/writer_progress.h>
|
||||||
@ -1177,6 +1178,17 @@ filesystem_<LoggerPolicy>::header() const {
|
|||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
|
filesystem_v2::filesystem_v2(logger& lgr, os_access const& os,
|
||||||
|
std::filesystem::path const& path)
|
||||||
|
: filesystem_v2(lgr, os, os.map_file(os.canonical(path))) {}
|
||||||
|
|
||||||
|
filesystem_v2::filesystem_v2(logger& lgr, os_access const& os,
|
||||||
|
std::filesystem::path const& path,
|
||||||
|
filesystem_options const& options,
|
||||||
|
std::shared_ptr<performance_monitor const> perfmon)
|
||||||
|
: filesystem_v2(lgr, os, os.map_file(os.canonical(path)), options,
|
||||||
|
std::move(perfmon)) {}
|
||||||
|
|
||||||
filesystem_v2::filesystem_v2(logger& lgr, os_access const& os,
|
filesystem_v2::filesystem_v2(logger& lgr, os_access const& os,
|
||||||
std::shared_ptr<mmif> mm)
|
std::shared_ptr<mmif> mm)
|
||||||
: filesystem_v2(lgr, os, std::move(mm), filesystem_options()) {}
|
: filesystem_v2(lgr, os, std::move(mm), filesystem_options()) {}
|
||||||
|
@ -1462,9 +1462,8 @@ void load_filesystem(dwarfs_userdata& userdata) {
|
|||||||
|
|
||||||
LOG_DEBUG << "attempting to load filesystem from " << fsimage;
|
LOG_DEBUG << "attempting to load filesystem from " << fsimage;
|
||||||
|
|
||||||
userdata.fs =
|
userdata.fs = filesystem_v2(userdata.lgr, *userdata.iol.os, fsimage, fsopts,
|
||||||
filesystem_v2(userdata.lgr, *userdata.iol.os,
|
userdata.perfmon);
|
||||||
std::make_shared<mmap>(fsimage), fsopts, userdata.perfmon);
|
|
||||||
|
|
||||||
ti << "file system initialized";
|
ti << "file system initialized";
|
||||||
}
|
}
|
||||||
|
@ -99,8 +99,7 @@ int dwarfsbench_main(int argc, sys_char** argv, iolayer const& iol) {
|
|||||||
fsopts.block_cache.num_workers = num_workers;
|
fsopts.block_cache.num_workers = num_workers;
|
||||||
fsopts.block_cache.decompress_ratio = to<double>(decompress_ratio_str);
|
fsopts.block_cache.decompress_ratio = to<double>(decompress_ratio_str);
|
||||||
|
|
||||||
dwarfs::filesystem_v2 fs(
|
dwarfs::filesystem_v2 fs(lgr, *iol.os, filesystem, fsopts);
|
||||||
lgr, *iol.os, std::make_shared<dwarfs::mmap>(filesystem), fsopts);
|
|
||||||
|
|
||||||
thread_pool pool(lgr, *iol.os, "reader", num_readers);
|
thread_pool pool(lgr, *iol.os, "reader", num_readers);
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ constexpr std::string_view kDash{"-"};
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int dwarfsextract_main(int argc, sys_char** argv, iolayer const& iol) {
|
int dwarfsextract_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||||
sys_string filesystem, output, trace_file;
|
sys_string fs_image, output, trace_file;
|
||||||
std::string format, cache_size_str, image_offset;
|
std::string format, cache_size_str, image_offset;
|
||||||
logger_options logopts;
|
logger_options logopts;
|
||||||
#if DWARFS_PERFMON_ENABLED
|
#if DWARFS_PERFMON_ENABLED
|
||||||
@ -70,7 +70,7 @@ int dwarfsextract_main(int argc, sys_char** argv, iolayer const& iol) {
|
|||||||
po::options_description opts("Command line options");
|
po::options_description opts("Command line options");
|
||||||
opts.add_options()
|
opts.add_options()
|
||||||
("input,i",
|
("input,i",
|
||||||
po_sys_value<sys_string>(&filesystem),
|
po_sys_value<sys_string>(&fs_image),
|
||||||
"input filesystem file")
|
"input filesystem file")
|
||||||
("output,o",
|
("output,o",
|
||||||
po_sys_value<sys_string>(&output),
|
po_sys_value<sys_string>(&output),
|
||||||
@ -164,9 +164,7 @@ int dwarfsextract_main(int argc, sys_char** argv, iolayer const& iol) {
|
|||||||
std::shared_ptr<performance_monitor> perfmon = performance_monitor::create(
|
std::shared_ptr<performance_monitor> perfmon = performance_monitor::create(
|
||||||
perfmon_enabled, iol.file, perfmon_trace_file);
|
perfmon_enabled, iol.file, perfmon_trace_file);
|
||||||
|
|
||||||
auto fs_path = iol.os->canonical(filesystem);
|
filesystem_v2 fs(lgr, *iol.os, fs_image, fsopts, perfmon);
|
||||||
|
|
||||||
filesystem_v2 fs(lgr, *iol.os, iol.os->map_file(fs_path), fsopts, perfmon);
|
|
||||||
filesystem_extractor fsx(lgr, *iol.os);
|
filesystem_extractor fsx(lgr, *iol.os);
|
||||||
|
|
||||||
if (format.empty()) {
|
if (format.empty()) {
|
||||||
|
@ -1159,14 +1159,14 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<filesystem_v2> input_filesystem;
|
std::optional<filesystem_v2> input_filesystem;
|
||||||
std::shared_ptr<category_resolver> cat_resolver;
|
std::shared_ptr<category_resolver> cat_resolver;
|
||||||
|
|
||||||
if (recompress) {
|
if (recompress) {
|
||||||
filesystem_options fsopts;
|
input_filesystem.emplace(
|
||||||
fsopts.image_offset = filesystem_options::IMAGE_OFFSET_AUTO;
|
lgr, *iol.os, path,
|
||||||
input_filesystem = std::make_unique<filesystem_v2>(
|
filesystem_options{.image_offset =
|
||||||
lgr, *iol.os, iol.os->map_file(path), fsopts);
|
filesystem_options::IMAGE_OFFSET_AUTO});
|
||||||
|
|
||||||
LOG_INFO << "checking input filesystem...";
|
LOG_INFO << "checking input filesystem...";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user