distinguish between new, written content and old content that comes
from the fragments.
+The option \fB-dump\fR together with an overlay fusefile setup will
+print the current overlay table to standard output rather than
+establishing a fusefile mount. The table is printed as the series of
+fusefile fragments using the argments as given.
+
.SH FRAGMENT ARGUMENTS
The fragment arguments include the filename of a source file, and
\fBfusedisk\fR and thereby give user or group ownership for the mount
to the nominated user or group.
+.TP
+\fI-dump\fR
+
+This "mount option" triggers fusefil to, instead of setting up a mount
+point, print out the applicable fusefile fragment sequence for the
+current setup as way of presenting the overlay table.
+
.SH EXAMPLES
This section illustrates uses of \fBfusefile\fR.
/***
fusefile - overlay a file path with a concatenation of parts of
- other files, read only.
+ other files.
- Copyright (C) 2019 Ralph Ronnquist
+ Copyright (C) 2019- Ralph Ronnquist
This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
return 0;
}
+#define ENDSOURCE( S ) ( S.start + ( S.to - S.from ) )
+
+/**
+ * Dump the current fragmentation to stdout.
+ */
+static int dump_fragments() {
+ int oly = 0;
+ int src = 0;
+ size_t pos = 0;
+ while ( src < sources.count ) {
+ size_t x = ( oly < overlay.count )?
+ overlay.table[ oly ].beg : sources.size;
+ for ( ; src < sources.count &&
+ ENDSOURCE( sources.array[ src ] ) <= x; src++ ) {
+ // Dump sources.array[src] in full
+ fprintf( stdout, "%s/%ld:%ld\n",
+ sources.array[ src ].filename,
+ pos - sources.array[ src ].start,
+ sources.array[ src ].to );
+ pos = ENDSOURCE( sources.array[ src ] );
+ }
+ if ( sources.array[ src ].start < x ) {
+ // Dump sources.array[src] up to x;
+ fprintf( stdout, "%s/%ld:%ld\n",
+ sources.array[ src ].filename,
+ pos - sources.array[ src ].start,
+ x - sources.array[ src ].start );
+ pos = ENDSOURCE( sources.array[ src ] );
+ }
+ if ( oly < overlay.count ) {
+ fprintf( stdout, "%s/%ld:%ld\n",
+ overlay.source.filename,
+ overlay.table[ oly ].beg,
+ overlay.table[ oly ].end );
+ pos = overlay.table[ oly++ ].end;
+ }
+ for ( ; src < sources.count &&
+ ENDSOURCE( sources.array[ src ] ) <= pos; src++ ) {
+ // Just skip these fragments.
+ }
+ }
+ return( 0 );
+}
+
static struct fuse_operations fusefile_oper = {
.getattr = fusefile_getattr,
+ // NYI .fgetattr = fusefile_fgetattr,
.chmod = fusefile_chmod,
.open = fusefile_open,
.read = fusefile_read,
.write = fusefile_write,
.write_buf = fusefile_write_buf,
.destroy = fusefile_destroy,
+ // NYI .access = fusefile_access,
.flush = fusefile_flush,
.release = fusefile_release,
.fsync = fusefile_fsync,
+ // NYI .ftruncate = fusefile_ftruncate,
.truncate = fusefile_truncate,
//.truncate = fusefile_truncate,
//.release = fusefile_release,
}
}
fuseargc = setup_argv( fuseargc, &argv );
+ if ( strcmp( "-dump", argv[ 1 ] ) == 0 ) {
+ return dump_fragments();
+ }
struct fuse_args args = FUSE_ARGS_INIT( fuseargc, argv );
if ( fuse_parse_cmdline( &args, &mnt, &mt, &fg ) ) {
return 1;