2 fusefile - overlay a file path with a concatenation of parts of
5 Copyright (C) 2019- Ralph Ronnquist
7 This program is free software: you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation, either version 3 of the
10 License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see
19 <http://www.gnu.org/licenses/>.
21 This source was inspired by the "null.c" example of the libfuse
22 sources, which is distributed under GPL2, and copyright (C)
23 2001-2007 Miklos Szeredi <miklos@szeredi.hu>.
26 #define FUSE_USE_VERSION 33
29 #include <fuse/fuse_lowlevel.h>
36 #include <sys/ioctl.h>
48 ssize_t start; // starting position in concatenated file
78 * Find the nearest overlay.table region below pos. Returns the index,
79 * or -1 if there is none, i.e. pos < overlay.table[0].
81 static ssize_t overlay_prior_fragment(off_t pos) {
82 size_t lo = 0, hi = overlay.count;
84 size_t m = ( lo + hi ) / 2;
86 return overlay.table[m].beg <= pos? m : -1;
88 if ( overlay.table[m].beg <= pos ) {
98 * Save the entry count for overlay.table as 64-bit integer
99 * immediately following the overlay content at the index
100 * corresponding to the fused file size.
102 static void overlay_save_count() {
103 lseek( overlay.source.fd, overlay.source.to, SEEK_SET );
104 size_t size = sizeof( overlay.count );
105 char *p = (char *) &overlay.count ;
107 size_t n = write( overlay.source.fd, p, size );
109 perror( overlay.source.filename );
115 if ( overlay.source.dirty++ > 1000 ) {
116 fsync( overlay.source.fd );
117 overlay.source.dirty = 0;
122 * Update the on-disk cache of overlay.table between the given
123 * indexes. The table is laid out immediately following the table
124 * count with each region saved as two 64-bit unsigned integers.
126 static void overlay_save_table(size_t lo,size_t hi) {
127 char *p = (char *) &overlay.table[ lo ];
128 size_t pos = overlay.source.to + sizeof( overlay.count ) +
129 lo * sizeof( struct Region );
130 size_t size = ( hi - lo ) * sizeof( struct Region );
131 if ( pos != lseek( overlay.source.fd, pos, SEEK_SET ) ) {
132 fprintf( stderr, "%s: seek error\n", overlay.source.filename );
136 size_t n = write( overlay.source.fd, p, size );
138 perror( overlay.source.filename );
144 if ( overlay.source.dirty++ > 1000 ) {
145 fsync( overlay.source.fd );
146 overlay.source.dirty = 0;
151 * Insert a new region at index p, with previous portion [p,count]
152 * moved up to make space.
154 static void overlay_insert(size_t p,off_t beg,off_t end) {
156 // Grow the table if needed
157 if ( overlay.count >= overlay.limit ) {
158 overlay.limit = overlay.count + 10;
159 bytes = overlay.limit * sizeof( struct Region );
160 overlay.table = overlay.table?
161 realloc( overlay.table, bytes ) : malloc( bytes );
163 bytes = ( overlay.count++ - p ) * sizeof( struct Region );
165 memmove( (char*) &overlay.table[ p+1 ],
166 (char*) &overlay.table[ p ],
169 overlay.table[ p ].beg = beg;
170 overlay.table[ p ].end = end;
171 overlay_save_count();
175 * Delete the region entry at p by moving the portion [p+1,count]
178 static void overlay_delete(size_t p) {
179 size_t bytes = ( --overlay.count - p ) * sizeof( struct Region );
181 memmove( (char*) &overlay.table[ p ],
182 (char*) &overlay.table[ p+1 ],
188 * Mark the given region as updated, i.e. written to the overlay. The
189 * mark region may attach to prior marked regions or be a new,
190 * separate region. If attaching, it causes the prior regions to
191 * expand and the table adjusted by deleting any regions that become
192 * fully contained in other regions.
194 static void overlay_mark(off_t beg,off_t end) {
196 fprintf( stderr, "overlay_mark( %ld, %ld )\n", beg, end );
200 ssize_t p = overlay_prior_fragment( beg );
201 // p is the nearest region below or at beg (or -1)
202 if ( p >= 0 && beg <= overlay.table[p].end ) {
203 // p overlaps mark region
204 if ( end <= overlay.table[p].end ) {
205 // region p covers mark region already
207 fprintf( stderr, "overlay covering ( %ld %ld )\n",
208 overlay.table[p].beg, overlay.table[p].end );
212 // the new mark region extends region p
213 overlay.table[p].end = end;
215 while ( q < overlay.count &&
216 overlay.table[q].beg <= overlay.table[p].end ) {
217 // Extended region merges with subsequent region
218 if ( overlay.table[p].end < overlay.table[q].end ) {
219 overlay.table[p].end = overlay.table[q].end;
225 overlay_save_count();
228 overlay_save_table( p, q );
230 fprintf( stderr, "overlay expand ( %ld %ld ) deleted %d\n",
231 overlay.table[p].beg, overlay.table[p].end, deleted );
235 // The prior region p does not expand into new mark region
236 p++; // subsequent region
237 if ( p >= overlay.count || end < overlay.table[p].beg ) {
238 // New mark region is a separate region at p
239 overlay_insert( p, beg, end );
241 fprintf( stderr, "overlay new ( %ld %ld )\n",
242 overlay.table[p].beg, overlay.table[p].end );
244 overlay_save_table( p, overlay.count );
247 // New marks start before and overlap with region p => change p
248 // and handle any subsequent regions being covered
249 overlay.table[p].beg = beg;
251 if ( overlay.table[p].end < end ) {
252 overlay.table[p].end = end;
253 while ( q < overlay.count &&
254 overlay.table[q].beg <= overlay.table[p].end ) {
255 if ( overlay.table[p].end < overlay.table[q].end ) {
256 overlay.table[p].end = overlay.table[q].end;
262 overlay_save_count();
266 overlay_save_table( p, q );
268 fprintf( stderr, "overlay before ( %ld %ld ) deleted %d\n",
269 overlay.table[p].beg, overlay.table[p].end, deleted );
273 static void setup_overlay(char *filename) {
274 overlay.source.filename = filename;
275 overlay.source.fd = open( filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR );
276 if ( overlay.source.fd < 0 ) {
283 static void print_source(struct Source *p) {
284 fprintf( stderr, "%p { %s, %ld, %ld, %ld, %d }\n",
285 p, p->filename, p->from, p->to, p->start, p-> fd );
290 static unsigned int c;
291 static int RANGE(int s,int n ) {
292 return ( s == n ) && *(range+c) == 0;
295 static int setup_source(struct Source *p,char *frag) {
296 struct stat filestat;
297 // Open the fragment file rw if possible, else ro
298 // First try the fragment in full, thereafter with range appendix
299 if ( stat( frag, &filestat ) == 0 ) {
300 p->filename = strdup( frag );
303 range = strrchr( frag, '/' ); // last '/'
304 p->filename = range? strndup( frag, range - frag ) : frag;
306 p->fd = open( p->filename, O_RDWR );
310 p->fd = open( p->filename, O_RDONLY );
313 perror( p->filename );
314 return 1; // Error return
316 if ( ( range == 0 ) && stat( p->filename, &filestat ) ) {
317 perror( p->filename );
321 fprintf( stderr, "** %s opened read-only\n", p->filename );
324 if ( S_ISBLK( filestat.st_mode ) ) {
325 // Block devices report size differently:
326 if ( ioctl( p->fd, BLKGETSIZE64, &filestat.st_size ) < 0 ) {
327 perror( p->filename );
330 fprintf( stderr, "block device size = %ld\n", filestat.st_size );
333 p->to = filestat.st_size;
334 // Process any range variation
335 if ( range && *(++range) ) {
338 } else if ( RANGE( sscanf( range, "%ld:%ld%n", &a, &b, &c ), 2 )) {
339 p->from = ( a < 0 )? ( p->to + a ) : a;
340 p->to = ( b < 0 )? ( p->to + b ) : b;
341 } else if ( RANGE( sscanf( range, "%ld+%ld%n", &a, &b, &c ), 2 )) {
342 p->from = ( a < 0 )? ( p->to + a ) : a;
343 p->to = ( ( b < 0 )? p->to : p->from ) + b;
344 } else if ( RANGE( sscanf( range, "%ld+%n", &a, &c ), 1 )) {
345 p->from = ( a < 0 )? ( p->to + a ) : a;
346 } else if ( RANGE( sscanf( range, ":%ld%n", &b, &c ), 1 )) {
347 p->to = ( b < 0 )? ( p->to + b ) : b;
348 } else if ( RANGE( sscanf( range, "%ld:%n", &a, &c ), 1 )) {
349 p->from = ( a < 0 )? ( p->to + a ) : a;
350 } else if ( RANGE( sscanf( range, "%ld%n", &a, &c ), 1 )) {
356 } else if ( RANGE( sscanf( range, ":%n", &c), 0 ) ) {
359 fprintf( stderr, "** BAD RANGE: %s\n", frag );
363 if ( ( filestat.st_mode & S_IFMT ) == S_IFCHR ) {
364 filestat.st_size = p->to; // Pretend size of character device
369 if ( p->to > filestat.st_size ) {
370 p->to = filestat.st_size;
372 if ( p->from >= p->to || p->from >= filestat.st_size ) {
373 fprintf( stderr, "** BAD RANGE: %s [%ld:%ld]\n",
374 frag, p->from, p->to );
377 p->start = sources.size; // the fusefile position of fragment
378 sources.size += p->to - p->from;
382 static int setup_sources(char **argv,int i,int n) {
383 sources.array = calloc( n, sizeof( struct Source ) );
384 if ( sources.array == 0 ) {
390 for ( ; j < n; i++, j++ ) {
391 struct Source *p = sources.array + j;
392 if ( setup_source( p, argv[i] ) ) {
402 static int fusefile_getattr(const char *path,struct stat *stbuf) {
404 fprintf( stderr, "fusefile_getattr( %s )\n", path );
406 if ( strcmp( path, "/" ) != 0 ) {
410 fprintf( stderr, "getattr %ld\n", sources.size );
412 memset( stbuf, 0, sizeof( struct stat ) );
413 stbuf->st_mode = S_IFREG | 0644; // Hmmm
415 stbuf->st_size = sources.size;
416 stbuf->st_atime = times.atime;
417 stbuf->st_mtime = times.mtime;
418 stbuf->st_ctime = times.ctime;
419 stbuf->st_uid = getuid();
420 stbuf->st_gid = getgid();
424 static int fusefile_chmod(const char *path,mode_t m) {
426 fprintf( stderr, "fusefile_chmod( %s, %d )\n", path, m );
431 static int fusefile_open(const char *path,struct fuse_file_info *fi) {
433 fprintf( stderr, "fusefile_open( %s, %d )\n", path, fi->flags );
434 fprintf( stderr, "fixing( %d )\n", fi->flags | O_CLOEXEC );
436 if ( strcmp( path, "/" ) != 0 ) {
439 // set O-CLOEXEC for this opening?
440 times.atime = time( 0 );
444 static int find_source(off_t offset) {
446 int hi = sources.count;
447 if ( offset >= sources.size ) {
451 fprintf( stderr, "find_source( %ld )\n", offset );
453 while ( lo + 1 < hi ) {
454 int m = ( lo + hi ) / 2;
455 if ( offset < sources.array[ m ].start ) {
457 fprintf( stderr, " offset < [%d].start: %ld\n",
458 m, sources.array[ m ].start );
463 fprintf( stderr, " offset >= [%d].start: %ld\n",
464 m, sources.array[ m ].start );
470 fprintf( stderr, "found %d\n", lo );
475 static int overlay_merge(char *buf,off_t beg,off_t end) {
477 fprintf( stderr, "merge %ld %ld\n", beg, end );
479 // Find nearest overlay data before or at beg
480 ssize_t p = overlay_prior_fragment( beg );
484 for ( ; p < overlay.count && overlay.table[p].beg < end; p++ ) {
485 if ( overlay.table[p].end < beg ) {
488 if ( overlay.table[p].beg > beg ) {
489 size_t delta = overlay.table[p].beg - beg;
493 size_t size = ( overlay.table[p].end <= end )?
494 ( overlay.table[p].end - beg ) : ( end - beg );
495 lseek( overlay.source.fd, beg, SEEK_SET );
497 size_t n = read( overlay.source.fd, buf, size );
506 // Read <size> bytes from <offset> in file
507 static int fusefile_read(const char *path, char *buf, size_t size,
508 off_t off, struct fuse_file_info *fi)
511 fprintf( stderr, "fusefile_read( %s )\n", path );
513 if( strcmp( path, "/" ) != 0 ) {
517 fprintf( stderr, "read %ld %ld\n", off, size );
519 size_t rr = 0; // total reading
522 fprintf( stderr, " find_source %ld %ld\n", off, size );
524 int i = find_source( off );
526 return ( off == sources.size )? rr : -ENOENT;
528 if ( sources.array[i].fd < 0 ) {
532 print_source( &sources.array[i] );
534 times.atime = time( 0 );
535 size_t b = off - sources.array[i].start + sources.array[i].from;
536 size_t n = sources.array[i].to - b;
540 if ( sources.array[i].dirty ) {
541 fsync( sources.array[i].fd );
542 sources.array[i].dirty = 0;
545 fprintf( stderr, " seek fd=%d to %ld\n", sources.array[i].fd, b );
547 if ( lseek( sources.array[i].fd, b, SEEK_SET ) < 0 ) {
548 perror( sources.array[i].filename );
552 fprintf( stderr, " now read %ld from fd=%d\n",
553 n, sources.array[i].fd );
555 ssize_t r = read( sources.array[i].fd, buf + rr, n );
557 fprintf( stderr, " got %ld bytes\n", r );
560 perror( sources.array[i].filename );
566 if ( overlay.source.filename ) {
567 if ( overlay.source.dirty ) {
568 fsync( overlay.source.fd );
569 overlay.source.dirty = 0;
571 int x = overlay_merge( buf + rr, off + rr, off + rr + r );
581 fprintf( stderr, " total reading %ld bytes\n", rr );
587 * Poll for IO readiness.
589 int fusefile_poll(const char *path, struct fuse_file_info *fi,
590 struct fuse_pollhandle *ph, unsigned *reventsp )
593 fprintf( stderr, "fusefile_poll( %s ) %p %d\n", path, ph, *reventsp );
595 if( strcmp( path, "/" ) != 0 ) {
599 return fuse_notify_poll( ph );
604 static void overlay_load() {
605 lseek( overlay.source.fd, overlay.source.to, SEEK_SET );
607 size_t size = sizeof( overlay.count );
608 if ( read( overlay.source.fd, &x, size ) != size ) {
612 fprintf( stderr, "overlay: %s with %ld regions\n",
613 overlay.source.filename, x );
615 struct Region f = { 0, 0 };
616 size = sizeof( struct Region );
618 if ( read( overlay.source.fd, &f, size ) != size ) {
619 fprintf( stderr, "%s: bad meta data\n", overlay.source.filename );
623 fprintf( stderr, "overlay region: %ld %ld\n", f.beg, f.end );
625 overlay_mark( f.beg, f.end );
630 * Write a full block of data over the sources at the offset
632 static int write_block(off_t off,const char *buf,size_t size) {
634 fprintf( stderr, "write_block( %ld, ?, %ld )\n", off, size );
636 if ( overlay.source.filename ) {
637 overlay_mark( off, off + size ); // Mark region as written
640 int index = find_source( off ); // index of source file
642 return -EIO; // past EOF
644 struct Source *source = overlay.source.filename?
645 &overlay.source : &sources.array[ index ];
646 off_t from = off - source->start + source->from;
647 off_t max = source->to - from;
648 if ( lseek( source->fd, from, SEEK_SET ) < 0 ) {
651 ssize_t todo = ( size < max )? size : max;
653 times.mtime = time( 0 );
654 ssize_t n = write( source->fd, buf, todo );
656 return -EIO; // Something wrong
663 if ( source->dirty++ >= 1000 ) {
671 static int fusefile_write_buf(const char *path, struct fuse_bufvec *buf,
672 off_t off, struct fuse_file_info *fi) {
674 fprintf( stderr, "fusefile_write_buf( %s )\n", path );
676 if ( strcmp( path, "/" ) != 0 ) {
682 for ( i = 0; i < buf->count; i++ ) {
683 struct fuse_buf *p = &buf->buf[i];
684 if ( p->flags & FUSE_BUF_IS_FD ) {
686 fprintf( stderr, "Content held in a file ... HELP!!\n" );
690 if ( write_block( off, (char*) p->mem, p->size ) < 0 ) {
696 fprintf( stderr, "fusefile_write_buf written %ld\n", size );
702 * Write a fragment at <off>. This overwrites files.
704 static int fusefile_write(const char *path, const char *buf, size_t size,
705 off_t off, struct fuse_file_info *fi)
708 fprintf( stderr, "fusefile_write( %s %ld )\n", path, size );
710 if ( strcmp( path, "/" ) != 0 ) {
714 if ( write_block( off, buf, size ) < 0 ) {
720 #define PUSHBUF 104857600
722 * Write data from overlay to source.
724 static void push_oly(off_t beg, off_t end) {
725 static char * buffer = 0;
726 // Pretend that there isn't an overlay
727 char *filename = overlay.source.filename;
729 buffer = malloc( PUSHBUF );
731 fprintf( stderr, "** OOM!!\n" );
735 overlay.source.filename = 0;
736 while ( beg < end ) {
737 off_t size = end - beg;
738 if ( size > PUSHBUF ) {
741 if ( lseek( overlay.source.fd, beg, SEEK_SET ) < 0 ) {
742 fprintf( stderr, "** Cannot seek overlay at %ld\n", beg );
745 size = read( overlay.source.fd, buffer, size );
746 if ( write_block( beg, buffer, size ) < 0 ) {
747 fprintf( stderr, "** Cannot push %ld bytes at %ld\n", size, beg );
751 overlay.source.filename = filename;
754 static void fusefile_destroy(void *data) {
755 char *mnt = (char*) data; // As passed to fuse_main
757 fprintf( stderr, "fusefile_destroy( %s )\n", mnt? mnt : "" );
764 static void fsync_all_dirty() {
766 for ( ; i < sources.count; i++ ) {
767 if ( sources.array[i].dirty ) {
768 fsync( sources.array[i].fd );
769 sources.array[i].dirty = 0;
772 if ( overlay.source.filename && overlay.source.dirty ) {
773 fsync( overlay.source.fd );
774 overlay.source.dirty = 0;
778 static int fusefile_flush(const char *path, struct fuse_file_info *info) {
780 fprintf( stderr, "fusefile_flush( %s )\n", path );
782 if ( strcmp( path, "/" ) != 0 ) {
789 static int fusefile_release(const char *path, struct fuse_file_info *fi) {
791 fprintf( stderr, "fusefile_release( %s, %d )\n", path, fi->flags );
793 if ( strcmp( path, "/" ) != 0 ) {
799 static int fusefile_fsync(const char *path, int x, struct fuse_file_info *fi) {
801 fprintf( stderr, "fusefile_fsync( %s, %d )\n", path, x );
803 if ( strcmp( path, "/" ) != 0 ) {
813 static int fusefile_truncate(const char *path, off_t len) {
815 fprintf( stderr, "fusefile_truncate( %s, %ld )\n", path, len );
817 if ( strcmp( path, "/" ) != 0 ) {
823 void *fusefile_init(struct fuse_conn_info *fci) {
825 fprintf( stderr, "fusefile_init( %d, %d )\n", fci->async_read, fci->want );
827 // Disable asynchronous reading
829 fci->want &= ~FUSE_CAP_ASYNC_READ;
831 fprintf( stderr, "fusefile_init( %d, %d )\n", fci->async_read, fci->want );
836 #define ENDSOURCE( S ) ( S.start + ( S.to - S.from ) )
839 * Dump the current fragmentation to stdout.
841 static int dump_fragments(int push) {
845 while ( src < sources.count ) {
846 size_t x = ( oly < overlay.count )?
847 overlay.table[ oly ].beg : sources.size;
848 for ( ; src < sources.count &&
849 ENDSOURCE( sources.array[ src ] ) <= x; src++ ) {
850 // Dump sources.array[src] in full
852 fprintf( stdout, "%s/%ld:%ld\n",
853 sources.array[ src ].filename,
854 pos - sources.array[ src ].start,
855 sources.array[ src ].to );
857 pos = ENDSOURCE( sources.array[ src ] );
859 if ( ( src < sources.count ) && ( sources.array[ src ].start < x ) ) {
860 // Dump sources.array[src] up to x;
862 fprintf( stdout, "%s/%ld:%ld\n",
863 sources.array[ src ].filename,
864 pos - sources.array[ src ].start,
865 x - sources.array[ src ].start );
867 pos = ENDSOURCE( sources.array[ src ] );
869 if ( oly < overlay.count ) {
871 fprintf( stdout, "%s/%ld:%ld\n",
872 overlay.source.filename,
873 overlay.table[ oly ].beg,
874 overlay.table[ oly ].end );
876 push_oly( overlay.table[ oly ].beg, overlay.table[ oly ].end );
878 pos = overlay.table[ oly++ ].end;
880 for ( ; src < sources.count &&
881 ENDSOURCE( sources.array[ src ] ) <= pos; src++ ) {
882 // Just skip these fragments.
888 static struct fuse_operations fusefile_oper = {
889 .getattr = fusefile_getattr,
890 // NYI .fgetattr = fusefile_fgetattr,
891 .chmod = fusefile_chmod,
892 .open = fusefile_open,
893 .read = fusefile_read,
894 .poll = fusefile_poll,
895 .write = fusefile_write,
896 .write_buf = fusefile_write_buf,
897 .destroy = fusefile_destroy,
898 // NYI .access = fusefile_access,
899 .flush = fusefile_flush,
900 .release = fusefile_release,
901 .fsync = fusefile_fsync,
902 // NYI .ftruncate = fusefile_ftruncate,
903 .truncate = fusefile_truncate,
904 //.truncate = fusefile_truncate,
905 //.release = fusefile_release,
906 .init = fusefile_init,
909 static void usage() {
911 "Usage: fusefile [ <fuse options> ] <mount> <file/from-to> ... \n"
912 "Mounts a virtual, file that is a concatenation of file fragments\n"
914 fprintf( stderr, "%s", usage );
919 * Set up the arguments for the fuse_main call, adding our own.
920 * argv[argc] is the mount point argument
922 static int setup_argv(int argc,char ***argv) {
923 // note: (*argv)[ argc ] is the mount point argument
925 "-odefault_permissions",
928 #define OURSN ( sizeof( OURS ) / sizeof( char* ) )
929 int N = argc + OURSN;
930 // Allocate new arg array plus terminating null pointer
931 char **out = malloc( ( N + 1 ) * sizeof( char* ) );
933 for ( i = 0; i < argc; i++ ) {
934 out[ i ] = (*argv)[i];
935 //fprintf( stderr, " %s", out[ i ] );
937 for ( i = 0; i < OURSN; i++ ) {
938 out[ argc + i ] = OURS[i];
939 //fprintf( stderr, " %s", out[ i ] );
942 //fprintf( stderr, "\n" );
944 return N; // Don't include the terminating null pointer
948 * Mount a concatenation of files,
949 * [ <fuse options> ] <mount> <file/from-to> ...
951 int main(int argc, char *argv[])
961 for ( i = 1; i < argc; i++ ) {
962 if ( *argv[i] != '-' ) {
966 if ( i > argc - 2 ) { // At least mount point plus one source
970 mnt = argv[ i++ ]; // First non-option argument is the mount pount
971 char *overlaytag = "-overlay:";
972 int overlaytagsize = strlen( overlaytag );
973 if ( strncmp( argv[i], overlaytag, overlaytagsize ) == 0 ) {
974 // consume "-overlay:filename"
975 setup_overlay( argv[i++] + overlaytagsize ); // Need a writable file
980 if ( setup_sources( argv, i, argc-i ) ) {
983 if ( overlay.source.filename ) {
984 overlay.source.to = sources.size; // Register total size.
987 if ( stat( mnt, &stbuf ) == -1 ) {
988 int fd = open( mnt, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR );
993 time_t now = time( 0 );
999 } else if ( ! S_ISREG( stbuf.st_mode ) ) {
1000 fprintf( stderr, "mountpoint is not a regular file\n" );
1003 times.atime = stbuf.st_atime;
1004 times.mtime = stbuf.st_mtime;
1005 times.ctime = stbuf.st_ctime;
1009 int fd = open( mnt, O_RDWR, S_IRUSR | S_IWUSR );
1014 if ( lseek( fd, sources.size, SEEK_SET ) < 0 ) {
1018 fuseargc = setup_argv( fuseargc, &argv );
1019 if ( strcmp( "-dump", argv[ 1 ] ) == 0 ) {
1020 return dump_fragments( 0 );
1022 if ( strcmp( "-push", argv[ 1 ] ) == 0 ) {
1023 return dump_fragments( 1 );
1025 struct fuse_args args = FUSE_ARGS_INIT( fuseargc, argv );
1026 if ( fuse_parse_cmdline( &args, &mnt, &mt, &fg ) ) {
1029 fuse_opt_free_args( &args );
1031 fprintf( stderr, "missing mountpoint parameter\n" );
1034 return fuse_main( fuseargc, argv, &fusefile_oper, temporary? mnt : NULL );