mirror of
https://github.com/torarnv/sparsebundlefs.git
synced 2026-02-26 18:35:50 +01:00
Add option and test for reading without read_buf
This commit is contained in:
@@ -93,6 +93,7 @@ struct sparsebundle_t {
|
||||
struct {
|
||||
bool allow_other = false;
|
||||
bool allow_root = false;
|
||||
bool noreadbuf = false;
|
||||
} options;
|
||||
};
|
||||
|
||||
@@ -495,13 +496,15 @@ static int sparsebundle_show_usage(char *program_name)
|
||||
|
||||
enum {
|
||||
SPARSEBUNDLE_OPT_HANDLED = 0, SPARSEBUNDLE_OPT_IGNORED = 1,
|
||||
SPARSEBUNDLE_OPT_DEBUG, SPARSEBUNDLE_OPT_ALLOW_OTHER, SPARSEBUNDLE_OPT_ALLOW_ROOT
|
||||
SPARSEBUNDLE_OPT_DEBUG, SPARSEBUNDLE_OPT_ALLOW_OTHER, SPARSEBUNDLE_OPT_ALLOW_ROOT,
|
||||
SPARSEBUNDLE_OPT_NOREADBUF
|
||||
};
|
||||
|
||||
struct fuse_opt sparsebundle_options[] = {
|
||||
FUSE_OPT_KEY("-D", SPARSEBUNDLE_OPT_DEBUG),
|
||||
FUSE_OPT_KEY("allow_other", SPARSEBUNDLE_OPT_ALLOW_OTHER),
|
||||
FUSE_OPT_KEY("allow_root", SPARSEBUNDLE_OPT_ALLOW_ROOT),
|
||||
FUSE_OPT_KEY("noreadbuf", SPARSEBUNDLE_OPT_NOREADBUF),
|
||||
FUSE_OPT_END
|
||||
};
|
||||
|
||||
@@ -522,6 +525,10 @@ static int sparsebundle_opt_proc(void *data, const char *arg, int key, struct fu
|
||||
sparsebundle->options.allow_root = true;
|
||||
return SPARSEBUNDLE_OPT_IGNORED;
|
||||
|
||||
case SPARSEBUNDLE_OPT_NOREADBUF:
|
||||
sparsebundle->options.noreadbuf = true;
|
||||
return SPARSEBUNDLE_OPT_HANDLED;
|
||||
|
||||
case FUSE_OPT_KEY_NONOPT:
|
||||
if (!sparsebundle->path) {
|
||||
sparsebundle->path = realpath(arg, 0);
|
||||
@@ -612,7 +619,11 @@ int main(int argc, char **argv)
|
||||
sparsebundle_filesystem_operations.readdir = sparsebundle_readdir;
|
||||
sparsebundle_filesystem_operations.release = sparsebundle_release;
|
||||
#if FUSE_SUPPORTS_ZERO_COPY
|
||||
sparsebundle_filesystem_operations.read_buf = sparsebundle_read_buf;
|
||||
syslog(LOG_DEBUG, "fuse supports zero-copy");
|
||||
if (sparsebundle.options.noreadbuf)
|
||||
syslog(LOG_DEBUG, "disabling zero-copy");
|
||||
else
|
||||
sparsebundle_filesystem_operations.read_buf = sparsebundle_read_buf;
|
||||
#endif
|
||||
|
||||
int ret = fuse_main(args.argc, args.argv, &sparsebundle_filesystem_operations, &sparsebundle);
|
||||
|
||||
23
tests/30_noreadbuf.tst
Normal file
23
tests/30_noreadbuf.tst
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env testrunner.sh
|
||||
|
||||
source "$(dirname "$0")/testhelpers.sh"
|
||||
|
||||
function setup() {
|
||||
mount_sparsebundle -o noreadbuf
|
||||
}
|
||||
|
||||
function test_dmg_has_correct_number_of_blocks() {
|
||||
hfsdump $dmg_file | grep "total_blocks: 268435456"
|
||||
}
|
||||
|
||||
function test_dmg_contents_is_same_as_testdata() {
|
||||
for f in $(ls $HFSFUSE_DIR/src); do
|
||||
echo "Diffing $HFSFUSE_DIR/src/$f"
|
||||
diff $HFSFUSE_DIR/src/$f <(hfsdump $dmg_file read "/src/$f")
|
||||
done
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
umount $mount_dir
|
||||
rm -Rf $mount_dir
|
||||
}
|
||||
Reference in New Issue
Block a user