+/**
+ *
+ */
+static int fusefile_truncate(const char *path, off_t len) {
+#if DEBUG
+ fprintf( stderr, "fusefile_truncate( %s, %ld )\n", path, len );
+#endif
+ if ( strcmp( path, "/" ) != 0 ) {
+ return -ENOENT;
+ }
+ return -EIO;
+}
+
+void *fusefile_init(struct fuse_conn_info *fci) {
+#if DEBUG
+ fprintf( stderr, "fusefile_init( %d, %d )\n", fci->async_read, fci->want );
+#endif
+ // Disable asynchronous reading
+ fci->async_read = 0;
+ fci->want &= ~FUSE_CAP_ASYNC_READ;
+#if DEBUG
+ fprintf( stderr, "fusefile_init( %d, %d )\n", fci->async_read, fci->want );
+#endif
+ 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 );
+}
+