X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=fusefile.c;h=00f7f7fd33e3565e6cff5966cbf7690ed58273c8;hb=332f7fd744dea0cfea9e29efea6d8ff576ba39ac;hp=632221f917b33c12e51892d6956c8893e3138a14;hpb=81d273f526ffaa4d00d63bf3221ee43b405a678b;p=rrq%2Ffusefile.git diff --git a/fusefile.c b/fusefile.c index 632221f..00f7f7f 100644 --- a/fusefile.c +++ b/fusefile.c @@ -1,12 +1,26 @@ -/* - FUSE: Filesystem in Userspace - Copyright (C) 2001-2007 Miklos Szeredi +/*** + fusefile - overlay a file path with a concatenation of parts of + other files, read only. - This program can be distributed under the terms of the GNU GPL. - See the file COPYING. + Copyright (C) 2019 Ralph Ronnquist - Overlay a file path with a concatenation of parts of other files. - read only + This program is free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see + . + + This source was inspired by the "null.c" example of the libfuse + sources, which is distributed under GPL2, and copyright (C) + 2001-2007 Miklos Szeredi . */ #define FUSE_USE_VERSION 31 @@ -22,16 +36,16 @@ struct Source { char *filename; - size_t from; - size_t to; - size_t start; // starting position in concatenated file + ssize_t from; + ssize_t to; + ssize_t start; // starting position in concatenated file int fd; }; static struct { struct Source *array; int count; - size_t size; + ssize_t size; } sources; #if DEBUG @@ -62,6 +76,7 @@ static size_t scan_source(char *in,struct Source *p) { m = i; } } + fprintf( stderr, "m=%d s=%d\n", m, s ); // Copy the filename, and set from and to p->filename = strndup( in, ( s < 0 )? e : s ); struct stat buf; @@ -73,6 +88,7 @@ static size_t scan_source(char *in,struct Source *p) { if ( p->from < 0 ) { p->from = 0; } + fprintf( stderr, "p->from=%ld\n", p->from ); p->to = ( m < 0 )? buf.st_size : atol( in+m+1 ); if ( p->from > p->to || p->to > buf.st_size ) { return 1; @@ -219,16 +235,16 @@ static void fusefile_destroy(void *data) { } static struct fuse_operations fusefile_oper = { - .getattr = fusefile_getattr, - .open = fusefile_open, - .read = fusefile_read, + .getattr = fusefile_getattr, + .open = fusefile_open, + .read = fusefile_read, .destroy = fusefile_destroy, }; static void usage() { char *usage = -"Usage: catfs [ ] ... \n" -"Mount a concatenation of files\n" +"Usage: fusefile [ ] ... \n" +"Mounts a virtual, read-only file that is a concatenation of file fragments\n" ; fprintf( stderr, "%s", usage ); exit( 1 ); @@ -236,7 +252,7 @@ static void usage() { /** * Mount a concatenation of files, - * [ ] ... + * [ ] ... */ int main(int argc, char *argv[]) {