From a612d030f62d300f1a305477b43d28e24d648337 Mon Sep 17 00:00:00 2001 From: FactorialN <8838579+FactorialN@users.noreply.github.com> Date: Sun, 3 Dec 2023 11:19:44 -0800 Subject: [PATCH] some persistency imple --- README.md | 17 +++++++++++++++++ lib/fischl.cpp | 15 ++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 43d625f..43a7cbe 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,23 @@ cmake .. make # cmake --build . is same ``` +## mount and test +normal usage: +```bash +./fischl diskpath mountpoint +``` +diskpath must be the provided following ./fischl + +if the diskpath need to be accessed by root: +```bash +sudo ./fischl diskpath -o allow_other mountpoint +``` + +for debugging: +```bash +sudo ./fischl diskpath -o allow_other -d mountpoint +``` + ## run test ### add your own test file on test/CMakeList.txt ``` diff --git a/lib/fischl.cpp b/lib/fischl.cpp index f0168ab..f123ea6 100644 --- a/lib/fischl.cpp +++ b/lib/fischl.cpp @@ -191,13 +191,22 @@ static void show_help(const char *progname) int fischl(int argc, char *argv[]) { int ret; - struct fuse_args args = FUSE_ARGS_INIT(argc, argv); + if(argc < 2){ + printf("WRONG ARGUMENTS"); + return 0; + } + std::swap(argv[0], argv[1]); + struct fuse_args args = FUSE_ARGS_INIT(argc-1, argv+1); srand(time(NULL)); // Seed the random number generator //const char* d = (argc < 2) ? "/dev/vdc" : argv[1]; //setupTestDirectory(&options.root); - options.H = new FakeRawDisk(23552); - //options.H = new RealRawDisk("/dev/vdb"); + if(strcmp(argv[0], "fake")==0){ + options.H = new FakeRawDisk(27648); + } + else{ + options.H = new RealRawDisk(argv[0]); + } options.fs = new Fs(options.H); options.fs->format(); options.fsop = new FilesOperation(*options.H, options.fs);