Merge tag '1.1' into debian
authorRalph Ronnquist <rrq@rrq.au>
Sat, 12 Aug 2023 03:20:24 +0000 (13:20 +1000)
committerRalph Ronnquist <rrq@rrq.au>
Sat, 12 Aug 2023 03:20:24 +0000 (13:20 +1000)
* Allow for fragment pathnames including "/" without range appendix
* Fix index oob in -dump function

.gitweb [new file with mode: 0644]
fusefile.c

diff --git a/.gitweb b/.gitweb
new file mode 100644 (file)
index 0000000..2c7a849
--- /dev/null
+++ b/.gitweb
@@ -0,0 +1,2 @@
+description = FUSE file mount combining fragments of files as a file.
+category = goodies
index f6d7bc84859506cad1a272cdab9e7f9dfa1791ad..9e5cb45d835b771e73548b8b443461474fcaa487 100644 (file)
@@ -295,8 +295,14 @@ static int RANGE(int s,int n ) {
 static int setup_source(struct Source *p,char *frag) {
     struct stat filestat;
     // Open the fragment file rw if possible, else ro
-    range = strrchr( frag, '/' ); // last '/'
-    p->filename = range? strndup( frag, range - frag ) : frag;
+    // First try the fragment in full, thereafter with range appendix
+    if ( stat( frag, &filestat ) == 0 ) {
+       p->filename = strdup( frag );
+       range = 0;
+    } else {
+       range = strrchr( frag, '/' ); // last '/'
+       p->filename = range? strndup( frag, range - frag ) : frag;
+    }
     p->fd = open( p->filename, O_RDWR );
     int rdonly = 0;
     if ( p->fd < 0 ) {
@@ -307,7 +313,7 @@ static int setup_source(struct Source *p,char *frag) {
        perror( p->filename );
        return 1; // Error return
     }
-    if ( stat( p->filename, &filestat ) ) {
+    if ( ( range == 0 ) && stat( p->filename, &filestat ) ) {
        perror( p->filename );
        return 1; 
     }
@@ -814,7 +820,7 @@ static int dump_fragments() {
                     sources.array[ src ].to );
            pos = ENDSOURCE( sources.array[ src ] );
        }
-       if ( sources.array[ src ].start < x ) {
+       if ( ( src < sources.count ) && ( sources.array[ src ].start < x ) ) {
            // Dump sources.array[src] up to x;
            fprintf( stdout, "%s/%ld:%ld\n",
                     sources.array[ src ].filename,