#endif
int i = find_source( off );
if ( i < 0 ) {
- return ( off == sources.size )? 0 : -ENOENT;
+ return ( off == sources.size )? rr : -ENOENT;
}
if ( sources.array[i].fd < 0 ) {
return -ENOENT;
return rr;
}
+/**
+ * Poll for IO readiness.
+ */
+int fusefile_poll(const char *path, struct fuse_file_info *fi,
+ struct fuse_pollhandle *ph, unsigned *reventsp )
+{
+#if DEBUG
+ fprintf( stderr, "fusefile_poll( %s ) %p %d\n", path, ph, *reventsp );
+#endif
+ if( strcmp( path, "/" ) != 0 ) {
+ return -ENOENT;
+ }
+ if ( ph ) {
+ return fuse_notify_poll( ph );
+ }
+ return 0;
+}
+
+
/**
* Write a full block of data over the sources at the offset
*/
.chmod = fusefile_chmod,
.open = fusefile_open,
.read = fusefile_read,
+ .poll = fusefile_poll,
.write = fusefile_write,
.write_buf = fusefile_write_buf,
.destroy = fusefile_destroy,
/**
* Set up the arguments for the fuse_main call, adding our own.
+ * argv[argc] is the mount point argument
*/
static int setup_argv(int argc,char ***argv) {
+ // note: (*argv)[ argc ] is the mount point argument
char *OURS[] = {
"-odefault_permissions",
- (*argv)[ --argc ] // note: (*argv)[ argc-1 ] = the mount point
+ (*argv)[ argc ]
};
#define OURSN ( sizeof( OURS ) / sizeof( char* ) )
- int N = argc + OURSN; // new argv-tobe size, excluding null
- char **out = malloc( ( N + 1 ) * sizeof( char* ) );
+ int N = argc + OURSN;
+ // Allocate new arg array plus terminating null pointer
+ char **out = malloc( ( N + 1 ) * sizeof( char* ) );
int i;
for ( i = 0; i < argc; i++ ) {
out[ i ] = (*argv)[i];
- fprintf( stderr, " %s", out[ i ] );
+ //fprintf( stderr, " %s", out[ i ] );
}
for ( i = 0; i < OURSN; i++ ) {
out[ argc + i ] = OURS[i];
- fprintf( stderr, " %s", out[ i ] );
+ //fprintf( stderr, " %s", out[ i ] );
}
out[ N ] = 0;
- fprintf( stderr, "\n" );
+ //fprintf( stderr, "\n" );
(*argv) = out;
- return N;
+ return N; // Don't include the terminating null pointer
}
/**
if ( i > argc - 2 ) { // At least mount point plus one source
usage();
}
- mnt = argv[ i++ ]; // First non-option argument is the mount pount
fuseargc = i;
+ mnt = argv[ i++ ]; // First non-option argument is the mount pount
if ( setup_sources( argv, i, argc-i ) ) {
return 1;
}