diff --git a/libfuse/include/fuse.h b/libfuse/include/fuse.h index cc79b884..1a62f960 100644 --- a/libfuse/include/fuse.h +++ b/libfuse/include/fuse.h @@ -140,12 +140,6 @@ struct fuse_operations /** Change the size of a file */ int (*truncate) (const char *, off_t); - /** Change the access and/or modification times of a file - * - * Deprecated, use utimens() instead. - */ - int (*utime) (const char *, struct utimbuf *); - /** File open operation * * No creation (O_CREAT, O_EXCL) and by default also no @@ -165,35 +159,6 @@ struct fuse_operations */ int (*open) (const char *, fuse_file_info_t *); - /** Read data from an open file - * - * Read should return exactly the number of bytes requested except - * on EOF or error, otherwise the rest of the data will be - * substituted with zeroes. An exception to this is when the - * 'direct_io' mount option is specified, in which case the return - * value of the read system call will reflect the return value of - * this operation. - * - * Changed in version 2.2 - */ - int (*read) (const fuse_file_info_t *, - char *, - size_t, - off_t); - - /** Write data to an open file - * - * Write should return exactly the number of bytes requested - * except on error. An exception to this is when the 'direct_io' - * mount option is specified (see read operation). - * - * Changed in version 2.2 - */ - int (*write) (const fuse_file_info_t *, - const char *, - size_t, - off_t); - /** Get file system statistics * * The 'f_frsize', 'f_favail', 'f_fsid' and 'f_flag' fields are ignored @@ -340,7 +305,7 @@ struct fuse_operations * * Introduced in version 2.3 */ - void (*destroy) (void *); + void (*destroy) (void); /** * Check file access permissions @@ -606,9 +571,6 @@ struct fuse_context /** Thread ID of the calling process */ pid_t pid; - /** Private filesystem data */ - void *private_data; - /** Umask of the calling process (introduced in version 2.8) */ mode_t umask; }; @@ -633,15 +595,13 @@ struct fuse_context * @param argc the argument counter passed to the main() function * @param argv the argument vector passed to the main() function * @param op the file system operation - * @param user_data user data supplied in the context during the init() method * @return 0 on success, nonzero on failure */ /* - int fuse_main(int argc, char *argv[], const struct fuse_operations *op, - void *user_data); + int fuse_main(int argc, char *argv[], const struct fuse_operations *op); */ -#define fuse_main(argc, argv, op, user_data) \ - fuse_main_real(argc, argv, op, sizeof(*(op)), user_data) +#define fuse_main(argc, argv, op) \ + fuse_main_real(argc, argv, op, sizeof(*(op))) /* ----------------------------------------------------------- * * More detailed API * @@ -654,12 +614,10 @@ struct fuse_context * @param args argument vector * @param op the filesystem operations * @param op_size the size of the fuse_operations structure - * @param user_data user data supplied in the context during the init() method * @return the created FUSE handle */ struct fuse *fuse_new(struct fuse_chan *ch, struct fuse_args *args, - const struct fuse_operations *op, size_t op_size, - void *user_data); + const struct fuse_operations *op, size_t op_size); /** * Destroy the FUSE handle. @@ -729,8 +687,7 @@ int fuse_is_lib_option(const char *opt); * * Do not call this directly, use fuse_main() */ -int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, - size_t op_size, void *user_data); +int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, size_t op_size); /** * Start the cleanup thread when using option "remember". @@ -813,8 +770,6 @@ int fuse_fs_read(struct fuse_fs *fs, char *buf, size_t size, int fuse_fs_read_buf(struct fuse_fs *fs, struct fuse_bufvec **bufp, size_t size, off_t off, fuse_file_info_t *fi); -int fuse_fs_write(struct fuse_fs *fs, const char *buf, - size_t size, off_t off, fuse_file_info_t *fi); int fuse_fs_write_buf(struct fuse_fs *fs, struct fuse_bufvec *buf, off_t off, fuse_file_info_t *fi); @@ -889,11 +844,9 @@ int fuse_notify_poll(fuse_pollhandle_t *ph); * * @param op the filesystem operations * @param op_size the size of the fuse_operations structure - * @param user_data user data supplied in the context during the init() method * @return a new filesystem object */ -struct fuse_fs *fuse_fs_new(const struct fuse_operations *op, size_t op_size, - void *user_data); +struct fuse_fs *fuse_fs_new(const struct fuse_operations *op, size_t op_size); /* ----------------------------------------------------------- * * Advanced API for event handling, don't worry about this... * @@ -908,8 +861,7 @@ typedef void (*fuse_processor_t)(struct fuse *, struct fuse_cmd *, void *); /** This is the part of fuse_main() before the event loop */ struct fuse *fuse_setup(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, - char **mountpoint, - void *user_data); + char **mountpoint); /** This is the part of fuse_main() after the event loop */ void fuse_teardown(struct fuse *fuse, char *mountpoint); diff --git a/libfuse/include/fuse_lowlevel.h b/libfuse/include/fuse_lowlevel.h index ee236713..a3014fbf 100644 --- a/libfuse/include/fuse_lowlevel.h +++ b/libfuse/include/fuse_lowlevel.h @@ -1482,36 +1482,6 @@ const struct fuse_ctx *fuse_req_ctx(fuse_req_t req); */ int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[]); -/** - * Callback function for an interrupt - * - * @param req interrupted request - * @param data user data - */ -typedef void (*fuse_interrupt_func_t)(fuse_req_t req, void *data); - -/** - * Register/unregister callback for an interrupt - * - * If an interrupt has already happened, then the callback function is - * called from within this function, hence it's not possible for - * interrupts to be lost. - * - * @param req request handle - * @param func the callback function or NULL for unregister - * @param data user data passed to the callback function - */ -void fuse_req_interrupt_func(fuse_req_t req, fuse_interrupt_func_t func, - void *data); - -/** - * Check if a request has already been interrupted - * - * @param req request handle - * @return 1 if the request has been interrupted, 0 otherwise - */ -int fuse_req_interrupted(fuse_req_t req); - /* ----------------------------------------------------------- * * Filesystem setup * * ----------------------------------------------------------- */ diff --git a/libfuse/lib/fuse.c b/libfuse/lib/fuse.c index b4c94040..13192668 100644 --- a/libfuse/lib/fuse.c +++ b/libfuse/lib/fuse.c @@ -67,8 +67,6 @@ struct fuse_config struct fuse_fs { struct fuse_operations op; - void *user_data; - int debug; }; struct lock_queue_element @@ -128,7 +126,6 @@ struct fuse unsigned int hidectr; pthread_mutex_t lock; struct fuse_config conf; - int intr_installed; struct fuse_fs *fs; struct lock_queue_element *lockq; int pagesize; @@ -797,9 +794,6 @@ void delete_node(struct fuse *f, struct node *node) { - if(f->conf.debug) - fprintf(stderr,"DELETE: %llu\n",(unsigned long long)node->nodeid); - assert(node->treelock == 0); unhash_name(f,node); if(lru_enabled(f)) @@ -1174,28 +1168,6 @@ wake_up_queued(struct fuse *f) queue_element_wakeup(f,qe); } -static -void -debug_path(struct fuse *f, - const char *msg, - fuse_ino_t nodeid, - const char *name, - bool wr) -{ - if(f->conf.debug) - { - struct node *wnode = NULL; - - if(wr) - wnode = lookup_node(f,nodeid,name); - - if(wnode) - fprintf(stderr,"%s %li (w)\n", msg,wnode->nodeid); - else - fprintf(stderr,"%s %li\n",msg,nodeid); - } -} - static void queue_path(struct fuse *f, @@ -1262,9 +1234,7 @@ get_path_common(struct fuse *f, qe.path1 = path; qe.wnode1 = wnode; - debug_path(f,"QUEUE PATH",nodeid,name,!!wnode); err = wait_path(f,&qe); - debug_path(f,"DEQUEUE PATH",nodeid,name,!!wnode); } pthread_mutex_unlock(&f->lock); @@ -1362,11 +1332,7 @@ get_path2(struct fuse *f, qe.path2 = path2; qe.wnode2 = wnode2; - debug_path(f,"QUEUE PATH1",nodeid1,name1,!!wnode1); - debug_path(f," PATH2",nodeid2,name2,!!wnode2); err = wait_path(f,&qe); - debug_path(f,"DEQUEUE PATH1",nodeid1,name1,!!wnode1); - debug_path(f," PATH2",nodeid2,name2,!!wnode2); } pthread_mutex_unlock(&f->lock); @@ -1441,7 +1407,6 @@ forget_node(struct fuse *f, qe.nodeid1 = nodeid; - debug_path(f,"QUEUE PATH (forget)",nodeid,NULL,false); queue_path(f,&qe); do @@ -1451,7 +1416,6 @@ forget_node(struct fuse *f, while((node->nlookup == nlookup) && node->treelock); dequeue_path(f,&qe); - debug_path(f,"DEQUEUE_PATH (forget)",nodeid,NULL,false); } assert(node->nlookup >= nlookup); @@ -1554,14 +1518,6 @@ fuse_fs_getattr(struct fuse_fs *fs, struct stat *buf, fuse_timeouts_t *timeout) { - if(fs->op.getattr == NULL) - return -ENOSYS; - - if(fs->debug) - fprintf(stderr,"getattr %s\n",path); - - fuse_get_context()->private_data = fs->user_data; - return fs->op.getattr(path,buf,timeout); } @@ -1571,13 +1527,6 @@ fuse_fs_fgetattr(struct fuse_fs *fs, fuse_file_info_t *fi, fuse_timeouts_t *timeout) { - if(fs->op.fgetattr == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - if(fs->debug) - fprintf(stderr,"fgetattr[%llu]\n",(unsigned long long)fi->fh); - return fs->op.fgetattr(fi,buf,timeout); } @@ -1586,11 +1535,6 @@ fuse_fs_rename(struct fuse_fs *fs, const char *oldpath, const char *newpath) { - if(fs->op.rename == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - return fs->op.rename(oldpath,newpath); } @@ -1599,11 +1543,6 @@ fuse_fs_prepare_hide(struct fuse_fs *fs_, const char *path_, uint64_t *fh_) { - if(fs_->op.prepare_hide == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs_->user_data; - return fs_->op.prepare_hide(path_,fh_); } @@ -1611,11 +1550,6 @@ int fuse_fs_free_hide(struct fuse_fs *fs_, uint64_t fh_) { - if(fs_->op.free_hide == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs_->user_data; - return fs_->op.free_hide(fh_); } @@ -1623,14 +1557,6 @@ int fuse_fs_unlink(struct fuse_fs *fs, const char *path) { - if(fs->op.unlink == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"unlink %s\n",path); - return fs->op.unlink(path); } @@ -1638,14 +1564,6 @@ int fuse_fs_rmdir(struct fuse_fs *fs, const char *path) { - if(fs->op.rmdir == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"rmdir %s\n",path); - return fs->op.rmdir(path); } @@ -1656,15 +1574,6 @@ fuse_fs_symlink(struct fuse_fs *fs_, struct stat *st_, fuse_timeouts_t *timeouts_) { - - if(fs_->op.symlink == NULL) - return -ENOSYS; - - if(fs_->debug) - fprintf(stderr,"symlink %s %s\n",linkname_,path_); - - fuse_get_context()->private_data = fs_->user_data; - return fs_->op.symlink(linkname_,path_,st_,timeouts_); } @@ -1675,14 +1584,6 @@ fuse_fs_link(struct fuse_fs *fs, struct stat *st_, fuse_timeouts_t *timeouts_) { - if(fs->op.link == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"link %s %s\n",oldpath,newpath); - return fs->op.link(oldpath,newpath,st_,timeouts_); } @@ -1690,16 +1591,6 @@ int fuse_fs_release(struct fuse_fs *fs, fuse_file_info_t *fi) { - if(fs->op.release == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"release%s[%llu] flags: 0x%x\n", - fi->flush ? "+flush" : "", - (unsigned long long)fi->fh,fi->flags); - return fs->op.release(fi); } @@ -1708,23 +1599,7 @@ fuse_fs_opendir(struct fuse_fs *fs, const char *path, fuse_file_info_t *fi) { - int err; - - if(fs->op.opendir == NULL) - return 0; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"opendir flags: 0x%x %s\n",fi->flags,path); - - err = fs->op.opendir(path,fi); - - if(fs->debug && !err) - fprintf(stderr," opendir[%lli] flags: 0x%x %s\n", - (unsigned long long)fi->fh,fi->flags,path); - - return err; + return fs->op.opendir(path,fi); } int @@ -1732,23 +1607,7 @@ fuse_fs_open(struct fuse_fs *fs, const char *path, fuse_file_info_t *fi) { - int err; - - if(fs->op.open == NULL) - return 0; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"open flags: 0x%x %s\n",fi->flags,path); - - err = fs->op.open(path,fi); - - if(fs->debug && !err) - fprintf(stderr," open[%lli] flags: 0x%x %s\n", - (unsigned long long)fi->fh,fi->flags,path); - - return err; + return fs->op.open(path,fi); } static @@ -1772,63 +1631,13 @@ fuse_fs_read_buf(struct fuse_fs *fs, off_t off, fuse_file_info_t *fi) { - fuse_get_context()->private_data = fs->user_data; - if(fs->op.read || fs->op.read_buf) - { - int res; - - if(fs->debug) - fprintf(stderr, - "read[%llu] %zu bytes from %llu flags: 0x%x\n", - (unsigned long long)fi->fh, - size,(unsigned long long)off,fi->flags); - - if(fs->op.read_buf) - { - res = fs->op.read_buf(fi,bufp,size,off); - } - else - { - struct fuse_bufvec *buf; - void *mem; - - buf = malloc(sizeof(struct fuse_bufvec)); - if(buf == NULL) - return -ENOMEM; - - mem = malloc(size); - if(mem == NULL) - { - free(buf); - return -ENOMEM; - } - - *buf = FUSE_BUFVEC_INIT(size); - buf->buf[0].mem = mem; - *bufp = buf; - - res = fs->op.read(fi,mem,size,off); - if(res >= 0) - buf->buf[0].size = res; - } - - if(fs->debug && res >= 0) - fprintf(stderr," read[%llu] %zu bytes from %llu\n", - (unsigned long long)fi->fh, - fuse_buf_size(*bufp), - (unsigned long long)off); - if(res >= 0 && fuse_buf_size(*bufp) > (int)size) - fprintf(stderr,"fuse: read too many bytes\n"); + int res; - if(res < 0) - return res; + res = fs->op.read_buf(fi,bufp,size,off); + if(res < 0) + return res; - return 0; - } - else - { - return -ENOSYS; - } + return 0; } int @@ -1860,85 +1669,7 @@ fuse_fs_write_buf(struct fuse_fs *fs, off_t off, fuse_file_info_t *fi) { - fuse_get_context()->private_data = fs->user_data; - if(fs->op.write_buf || fs->op.write) - { - int res; - size_t size = fuse_buf_size(buf); - - assert(buf->idx == 0 && buf->off == 0); - if(fs->debug) - fprintf(stderr, - "write%s[%llu] %zu bytes to %llu flags: 0x%x\n", - fi->writepage ? "page" : "", - (unsigned long long)fi->fh, - size, - (unsigned long long)off, - fi->flags); - - if(fs->op.write_buf) - { - res = fs->op.write_buf(fi,buf,off); - } - else - { - void *mem = NULL; - struct fuse_buf *flatbuf; - struct fuse_bufvec tmp = FUSE_BUFVEC_INIT(size); - - if(buf->count == 1 && !(buf->buf[0].flags & FUSE_BUF_IS_FD)) - { - flatbuf = &buf->buf[0]; - } - else - { - res = -ENOMEM; - mem = malloc(size); - if(mem == NULL) - goto out; - - tmp.buf[0].mem = mem; - res = fuse_buf_copy(&tmp,buf,0); - if(res <= 0) - goto out_free; - - tmp.buf[0].size = res; - flatbuf = &tmp.buf[0]; - } - - res = fs->op.write(fi,flatbuf->mem,flatbuf->size,off); - out_free: - free(mem); - } - out: - if(fs->debug && res >= 0) - fprintf(stderr," write%s[%llu] %u bytes to %llu\n", - fi->writepage ? "page" : "", - (unsigned long long)fi->fh,res, - (unsigned long long)off); - if(res > (int)size) - fprintf(stderr,"fuse: wrote too many bytes\n"); - - return res; - } - else - { - return -ENOSYS; - } -} - -int -fuse_fs_write(struct fuse_fs *fs, - const char *mem, - size_t size, - off_t off, - fuse_file_info_t *fi) -{ - struct fuse_bufvec bufv = FUSE_BUFVEC_INIT(size); - - bufv.buf[0].mem = (void *)mem; - - return fuse_fs_write_buf(fs,&bufv,off,fi); + return fs->op.write_buf(fi,buf,off); } int @@ -1946,15 +1677,6 @@ fuse_fs_fsync(struct fuse_fs *fs, int datasync, fuse_file_info_t *fi) { - if(fs->op.fsync == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"fsync[%llu] datasync: %i\n", - (unsigned long long)fi->fh,datasync); - return fs->op.fsync(fi,datasync); } @@ -1963,15 +1685,6 @@ fuse_fs_fsyncdir(struct fuse_fs *fs, int datasync, fuse_file_info_t *fi) { - if(fs->op.fsyncdir == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"fsyncdir[%llu] datasync: %i\n", - (unsigned long long)fi->fh,datasync); - return fs->op.fsyncdir(fi,datasync); } @@ -1979,15 +1692,6 @@ int fuse_fs_flush(struct fuse_fs *fs, fuse_file_info_t *fi) { - if(fs->op.flush == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"flush[%llu]\n", - (unsigned long long)fi->fh); - return fs->op.flush(fi); } @@ -1996,18 +1700,6 @@ fuse_fs_statfs(struct fuse_fs *fs, const char *path, struct statvfs *buf) { - if(fs->op.statfs == NULL) - { - buf->f_namemax = 255; - buf->f_bsize = 512; - return 0; - } - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"statfs %s\n",path); - return fs->op.statfs(path,buf); } @@ -2015,15 +1707,6 @@ int fuse_fs_releasedir(struct fuse_fs *fs, fuse_file_info_t *fi) { - if(fs->op.releasedir == NULL) - return 0; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"releasedir[%llu] flags: 0x%x\n", - (unsigned long long)fi->fh,fi->flags); - return fs->op.releasedir(fi); } @@ -2032,11 +1715,6 @@ fuse_fs_readdir(struct fuse_fs *fs, fuse_file_info_t *fi, fuse_dirents_t *buf) { - if(fs->op.readdir == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - return fs->op.readdir(fi,buf); } @@ -2045,11 +1723,6 @@ fuse_fs_readdir_plus(struct fuse_fs *fs_, fuse_file_info_t *ffi_, fuse_dirents_t *buf_) { - if(fs_->op.readdir_plus == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs_->user_data; - return fs_->op.readdir_plus(ffi_,buf_); } @@ -2059,26 +1732,7 @@ fuse_fs_create(struct fuse_fs *fs, mode_t mode, fuse_file_info_t *fi) { - int err; - - if(fs->op.create == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr, - "create flags: 0x%x %s 0%o umask=0%03o\n", - fi->flags,path,mode, - fuse_get_context()->umask); - - err = fs->op.create(path,mode,fi); - - if(fs->debug && !err) - fprintf(stderr," create[%llu] flags: 0x%x %s\n", - (unsigned long long)fi->fh,fi->flags,path); - - return err; + return fs->op.create(path,mode,fi); } int @@ -2087,25 +1741,6 @@ fuse_fs_lock(struct fuse_fs *fs, int cmd, struct flock *lock) { - if(fs->op.lock == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"lock[%llu] %s %s start: %llu len: %llu pid: %llu\n", - (unsigned long long)fi->fh, - (cmd == F_GETLK ? "F_GETLK" : - (cmd == F_SETLK ? "F_SETLK" : - (cmd == F_SETLKW ? "F_SETLKW" : "???"))), - (lock->l_type == F_RDLCK ? "F_RDLCK" : - (lock->l_type == F_WRLCK ? "F_WRLCK" : - (lock->l_type == F_UNLCK ? "F_UNLCK" : - "???"))), - (unsigned long long)lock->l_start, - (unsigned long long)lock->l_len, - (unsigned long long)lock->l_pid); - return fs->op.lock(fi,cmd,lock); } @@ -2114,23 +1749,6 @@ fuse_fs_flock(struct fuse_fs *fs, fuse_file_info_t *fi, int op) { - if(fs->op.flock == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - { - int xop = op & ~LOCK_NB; - - fprintf(stderr,"lock[%llu] %s%s\n", - (unsigned long long)fi->fh, - xop == LOCK_SH ? "LOCK_SH" : - (xop == LOCK_EX ? "LOCK_EX" : - (xop == LOCK_UN ? "LOCK_UN" : "???")), - (op & LOCK_NB) ? "|LOCK_NB" : ""); - } - return fs->op.flock(fi,op); } @@ -2140,15 +1758,6 @@ fuse_fs_chown(struct fuse_fs *fs, uid_t uid, gid_t gid) { - if(fs->op.chown == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"chown %s %lu %lu\n",path, - (unsigned long)uid,(unsigned long)gid); - return fs->op.chown(path,uid,gid); } @@ -2158,12 +1767,6 @@ fuse_fs_fchown(struct fuse_fs *fs_, const uid_t uid_, const gid_t gid_) { - if(fs_->op.fchown == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs_->user_data; - - return fs_->op.fchown(ffi_,uid_,gid_); } @@ -2172,15 +1775,6 @@ fuse_fs_truncate(struct fuse_fs *fs, const char *path, off_t size) { - if(fs->op.truncate == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"truncate %s %llu\n",path, - (unsigned long long)size); - return fs->op.truncate(path,size); } @@ -2189,16 +1783,6 @@ fuse_fs_ftruncate(struct fuse_fs *fs, off_t size, fuse_file_info_t *fi) { - if(fs->op.ftruncate == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"ftruncate[%llu] %llu\n", - (unsigned long long)fi->fh, - (unsigned long long)size); - return fs->op.ftruncate(fi,size); } @@ -2207,32 +1791,7 @@ fuse_fs_utimens(struct fuse_fs *fs, const char *path, const struct timespec tv[2]) { - fuse_get_context()->private_data = fs->user_data; - if(fs->op.utimens) - { - if(fs->debug) - fprintf(stderr,"utimens %s %li.%09lu %li.%09lu\n", - path,tv[0].tv_sec,tv[0].tv_nsec, - tv[1].tv_sec,tv[1].tv_nsec); - - return fs->op.utimens(path,tv); - } - else if(fs->op.utime) - { - struct utimbuf buf; - - if(fs->debug) - fprintf(stderr,"utime %s %li %li\n",path, - tv[0].tv_sec,tv[1].tv_sec); - - buf.actime = tv[0].tv_sec; - buf.modtime = tv[1].tv_sec; - return fs->op.utime(path,&buf); - } - else - { - return -ENOSYS; - } + return fs->op.utimens(path,tv); } int @@ -2240,11 +1799,6 @@ fuse_fs_futimens(struct fuse_fs *fs_, const fuse_file_info_t *ffi_, const struct timespec tv_[2]) { - if(fs_->op.futimens == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs_->user_data; - return fs_->op.futimens(ffi_,tv_); } @@ -2253,14 +1807,6 @@ fuse_fs_access(struct fuse_fs *fs, const char *path, int mask) { - if(fs->op.access == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"access %s 0%o\n",path,mask); - return fs->op.access(path,mask); } @@ -2270,15 +1816,6 @@ fuse_fs_readlink(struct fuse_fs *fs, char *buf, size_t len) { - if(fs->op.readlink == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"readlink %s %lu\n",path, - (unsigned long)len); - return fs->op.readlink(path,buf,len); } @@ -2288,16 +1825,6 @@ fuse_fs_mknod(struct fuse_fs *fs, mode_t mode, dev_t rdev) { - if(fs->op.mknod == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"mknod %s 0%o 0x%llx umask=0%03o\n", - path,mode,(unsigned long long)rdev, - fuse_get_context()->umask); - return fs->op.mknod(path,mode,rdev); } @@ -2306,15 +1833,6 @@ fuse_fs_mkdir(struct fuse_fs *fs, const char *path, mode_t mode) { - if(fs->op.mkdir == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"mkdir %s 0%o umask=0%03o\n", - path,mode,fuse_get_context()->umask); - return fs->op.mkdir(path,mode); } @@ -2326,15 +1844,6 @@ fuse_fs_setxattr(struct fuse_fs *fs, size_t size, int flags) { - if(fs->op.setxattr == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"setxattr %s %s %lu 0x%x\n", - path,name,(unsigned long)size,flags); - return fs->op.setxattr(path,name,value,size,flags); } @@ -2345,15 +1854,6 @@ fuse_fs_getxattr(struct fuse_fs *fs, char *value, size_t size) { - if(fs->op.getxattr == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"getxattr %s %s %lu\n", - path,name,(unsigned long)size); - return fs->op.getxattr(path,name,value,size); } @@ -2363,15 +1863,6 @@ fuse_fs_listxattr(struct fuse_fs *fs, char *list, size_t size) { - if(fs->op.listxattr == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"listxattr %s %lu\n", - path,(unsigned long)size); - return fs->op.listxattr(path,list,size); } @@ -2381,15 +1872,6 @@ fuse_fs_bmap(struct fuse_fs *fs, size_t blocksize, uint64_t *idx) { - if(fs->op.bmap == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - if(fs->debug) - fprintf(stderr,"bmap %s blocksize: %lu index: %llu\n", - path,(unsigned long)blocksize, - (unsigned long long)*idx); - return fs->op.bmap(path,blocksize,idx); } @@ -2398,14 +1880,6 @@ fuse_fs_removexattr(struct fuse_fs *fs, const char *path, const char *name) { - if(fs->op.removexattr == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"removexattr %s %s\n",path,name); - return fs->op.removexattr(path,name); } @@ -2418,15 +1892,6 @@ fuse_fs_ioctl(struct fuse_fs *fs, void *data, uint32_t *out_size) { - if(fs->op.ioctl == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"ioctl[%llu] 0x%lx flags: 0x%x\n", - (unsigned long long)fi->fh,cmd,flags); - return fs->op.ioctl(fi,cmd,arg,flags,data,out_size); } @@ -2436,24 +1901,7 @@ fuse_fs_poll(struct fuse_fs *fs, fuse_pollhandle_t *ph, unsigned *reventsp) { - int res; - - if(fs->op.poll == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"poll[%llu] ph: %p\n", - (unsigned long long)fi->fh,ph); - - res = fs->op.poll(fi,ph,reventsp); - - if(fs->debug && !res) - fprintf(stderr," poll[%llu] revents: 0x%x\n", - (unsigned long long)fi->fh,*reventsp); - - return res; + return fs->op.poll(fi,ph,reventsp); } int @@ -2463,17 +1911,6 @@ fuse_fs_fallocate(struct fuse_fs *fs, off_t length, fuse_file_info_t *fi) { - if(fs->op.fallocate == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - - if(fs->debug) - fprintf(stderr,"fallocate mode %x,offset: %llu,length: %llu\n", - mode, - (unsigned long long)offset, - (unsigned long long)length); - return fs->op.fallocate(fi,mode,offset,length); } @@ -2486,11 +1923,6 @@ fuse_fs_copy_file_range(struct fuse_fs *fs_, size_t len_, int flags_) { - if(fs_->op.copy_file_range == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs_->user_data; - return fs_->op.copy_file_range(ffi_in_, off_in_, ffi_out_, @@ -2567,12 +1999,6 @@ set_path_info(struct fuse *f, pthread_mutex_unlock(&f->lock); set_stat(f,e->ino,&e->attr); - if(f->conf.debug) - fprintf(stderr, - " NODEID: %llu\n" - " GEN: %llu\n", - (unsigned long long)e->ino, - (unsigned long long)e->generation); return 0; } @@ -2718,15 +2144,7 @@ void fuse_fs_init(struct fuse_fs *fs, struct fuse_conn_info *conn) { - fuse_get_context()->private_data = fs->user_data; - if(!fs->op.write_buf) - conn->want &= ~FUSE_CAP_SPLICE_READ; - if(!fs->op.lock) - conn->want &= ~FUSE_CAP_POSIX_LOCKS; - if(!fs->op.flock) - conn->want &= ~FUSE_CAP_FLOCK_LOCKS; - if(fs->op.init) - fs->user_data = fs->op.init(conn); + fs->op.init(conn); } static @@ -2746,9 +2164,7 @@ fuse_lib_init(void *data, void fuse_fs_destroy(struct fuse_fs *fs) { - fuse_get_context()->private_data = fs->user_data; - if(fs->op.destroy) - fs->op.destroy(fs->user_data); + fs->op.destroy(); free(fs); } @@ -2786,8 +2202,6 @@ fuse_lib_lookup(fuse_req_t req, pthread_mutex_lock(&f->lock); if(len == 1) { - if(f->conf.debug) - fprintf(stderr,"LOOKUP-DOT\n"); dot = get_node_nocheck(f,parent); if(dot == NULL) { @@ -2799,8 +2213,6 @@ fuse_lib_lookup(fuse_req_t req, } else { - if(f->conf.debug) - fprintf(stderr,"LOOKUP-DOTDOT\n"); parent = get_node(f,parent)->parent->nodeid; } pthread_mutex_unlock(&f->lock); @@ -2811,8 +2223,6 @@ fuse_lib_lookup(fuse_req_t req, err = get_path_name(f,parent,name,&path); if(!err) { - if(f->conf.debug) - fprintf(stderr,"LOOKUP %s\n",path); err = lookup_path(f,parent,name,path,&e,NULL); if(err == -ENOENT) { @@ -2836,11 +2246,6 @@ do_forget(struct fuse *f, const fuse_ino_t ino, const uint64_t nlookup) { - if(f->conf.debug) - fprintf(stderr, - "FORGET %llu/%llu\n", - (unsigned long long)ino, - (unsigned long long)nlookup); forget_node(f,ino,nlookup); } @@ -2902,7 +2307,7 @@ fuse_lib_getattr(fuse_req_t req, err = 0; path = NULL; - if((fi == NULL) || (f->fs->op.fgetattr == NULL)) + if(fi == NULL) err = get_path(f,ino,&path); if(!err) @@ -2934,11 +2339,6 @@ fuse_fs_chmod(struct fuse_fs *fs, const char *path, mode_t mode) { - if(fs->op.chmod == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs->user_data; - return fs->op.chmod(path,mode); } @@ -2947,11 +2347,6 @@ fuse_fs_fchmod(struct fuse_fs *fs_, const fuse_file_info_t *ffi_, const mode_t mode_) { - if(fs_->op.fchmod == NULL) - return -ENOSYS; - - fuse_get_context()->private_data = fs_->user_data; - return fs_->op.fchmod(ffi_,mode_); } @@ -3327,7 +2722,7 @@ fuse_lib_link(fuse_req_t req, f = req_fuse_prepare(req); rv = get_path2(f,ino,NULL,newparent,newname, - &oldpath,&newpath,NULL,NULL); + &oldpath,&newpath,NULL,NULL); if(!rv) { rv = fuse_fs_link(f->fs,oldpath,newpath,&e.attr,&e.timeout); @@ -3633,34 +3028,6 @@ fuse_lib_opendir(fuse_req_t req, free_path(f,ino,path); } -static -int -readdir_fill(struct fuse *f_, - fuse_req_t req_, - fuse_dirents_t *d_, - fuse_file_info_t *fi_) -{ - int rv; - - rv = fuse_fs_readdir(f_->fs,fi_,d_); - - return rv; -} - -static -int -readdir_plus_fill(struct fuse *f_, - fuse_req_t req_, - fuse_dirents_t *d_, - fuse_file_info_t *fi_) -{ - int rv; - - rv = fuse_fs_readdir_plus(f_->fs,fi_,d_); - - return rv; -} - static size_t readdir_buf_size(fuse_dirents_t *d_, @@ -3704,7 +3071,7 @@ fuse_lib_readdir(fuse_req_t req_, rv = 0; if((off_ == 0) || (d->data_len == 0)) - rv = readdir_fill(f,req_,d,&fi); + rv = fuse_fs_readdir(f->fs,&fi,d); if(rv) { @@ -3744,7 +3111,7 @@ fuse_lib_readdir_plus(fuse_req_t req_, rv = 0; if((off_ == 0) || (d->data_len == 0)) - rv = readdir_plus_fill(f,req_,d,&fi); + rv = fuse_fs_readdir_plus(f->fs,&fi,d); if(rv) { @@ -4460,26 +3827,26 @@ fuse_clean_cache(struct fuse *f) for(curr = f->lru_table.next; curr != &f->lru_table; curr = next) { - double age; + double age; - next = curr->next; - lnode = list_entry(curr,struct node_lru,lru); - node = &lnode->node; + next = curr->next; + lnode = list_entry(curr,struct node_lru,lru); + node = &lnode->node; - age = diff_timespec(&now,&lnode->forget_time); - if(age <= f->conf.remember) - break; + age = diff_timespec(&now,&lnode->forget_time); + if(age <= f->conf.remember) + break; - assert(node->nlookup == 1); + assert(node->nlookup == 1); - /* Don't forget active directories */ - if(node->refctr > 1) - continue; + /* Don't forget active directories */ + if(node->refctr > 1) + continue; - node->nlookup = 0; - unhash_name(f,node); - unref_node(f,node); - } + node->nlookup = 0; + unhash_name(f,node); + unref_node(f,node); + } pthread_mutex_unlock(&f->lock); return clean_delay(f); @@ -4487,47 +3854,48 @@ fuse_clean_cache(struct fuse *f) static struct fuse_lowlevel_ops fuse_path_ops = { - .init = fuse_lib_init, + .access = fuse_lib_access, + .bmap = fuse_lib_bmap, + .copy_file_range = fuse_lib_copy_file_range, + .create = fuse_lib_create, .destroy = fuse_lib_destroy, - .lookup = fuse_lib_lookup, + .fallocate = fuse_lib_fallocate, + .flock = fuse_lib_flock, + .flush = fuse_lib_flush, .forget = fuse_lib_forget, .forget_multi = fuse_lib_forget_multi, + .fsync = fuse_lib_fsync, + .fsyncdir = fuse_lib_fsyncdir, .getattr = fuse_lib_getattr, - .setattr = fuse_lib_setattr, - .access = fuse_lib_access, - .readlink = fuse_lib_readlink, - .mknod = fuse_lib_mknod, - .mkdir = fuse_lib_mkdir, - .unlink = fuse_lib_unlink, - .rmdir = fuse_lib_rmdir, - .symlink = fuse_lib_symlink, - .rename = fuse_lib_rename, + .getlk = fuse_lib_getlk, + .getxattr = fuse_lib_getxattr, + .init = fuse_lib_init, + .ioctl = fuse_lib_ioctl, .link = fuse_lib_link, - .create = fuse_lib_create, + .listxattr = fuse_lib_listxattr, + .lookup = fuse_lib_lookup, + .mkdir = fuse_lib_mkdir, + .mknod = fuse_lib_mknod, .open = fuse_lib_open, - .read = fuse_lib_read, - .write_buf = fuse_lib_write_buf, - .flush = fuse_lib_flush, - .release = fuse_lib_release, - .fsync = fuse_lib_fsync, .opendir = fuse_lib_opendir, + .poll = fuse_lib_poll, + .read = fuse_lib_read, .readdir = fuse_lib_readdir, .readdir_plus = fuse_lib_readdir_plus, + .readlink = fuse_lib_readlink, + .release = fuse_lib_release, .releasedir = fuse_lib_releasedir, - .fsyncdir = fuse_lib_fsyncdir, - .statfs = fuse_lib_statfs, - .setxattr = fuse_lib_setxattr, - .getxattr = fuse_lib_getxattr, - .listxattr = fuse_lib_listxattr, .removexattr = fuse_lib_removexattr, - .getlk = fuse_lib_getlk, + .rename = fuse_lib_rename, + .retrieve_reply = NULL, + .rmdir = fuse_lib_rmdir, + .setattr = fuse_lib_setattr, .setlk = fuse_lib_setlk, - .flock = fuse_lib_flock, - .bmap = fuse_lib_bmap, - .ioctl = fuse_lib_ioctl, - .poll = fuse_lib_poll, - .fallocate = fuse_lib_fallocate, - .copy_file_range = fuse_lib_copy_file_range, + .setxattr = fuse_lib_setxattr, + .statfs = fuse_lib_statfs, + .symlink = fuse_lib_symlink, + .unlink = fuse_lib_unlink, + .write_buf = fuse_lib_write_buf, }; int @@ -4632,20 +4000,20 @@ static const struct fuse_opt fuse_lib_opts[] = { FUSE_OPT_KEY("-h", KEY_HELP), FUSE_OPT_KEY("--help", KEY_HELP), - FUSE_OPT_KEY("debug", FUSE_OPT_KEY_KEEP), + FUSE_OPT_KEY("debug", FUSE_OPT_KEY_KEEP), FUSE_OPT_KEY("-d", FUSE_OPT_KEY_KEEP), - FUSE_LIB_OPT("debug", debug,1), + FUSE_LIB_OPT("debug", debug,1), FUSE_LIB_OPT("-d", debug,1), FUSE_LIB_OPT("umask=", set_mode,1), FUSE_LIB_OPT("umask=%o", umask,0), - FUSE_LIB_OPT("uid=", set_uid,1), + FUSE_LIB_OPT("uid=", set_uid,1), FUSE_LIB_OPT("uid=%d", uid,0), - FUSE_LIB_OPT("gid=", set_gid,1), + FUSE_LIB_OPT("gid=", set_gid,1), FUSE_LIB_OPT("gid=%d", gid,0), - FUSE_LIB_OPT("noforget", remember,-1), - FUSE_LIB_OPT("remember=%u", remember,0), - FUSE_LIB_OPT("threads=%d", threads,0), - FUSE_LIB_OPT("use_ino", use_ino,1), + FUSE_LIB_OPT("noforget", remember,-1), + FUSE_LIB_OPT("remember=%u", remember,0), + FUSE_LIB_OPT("threads=%d", threads,0), + FUSE_LIB_OPT("use_ino", use_ino,1), FUSE_OPT_END }; @@ -4690,8 +4058,7 @@ fuse_is_lib_option(const char *opt) struct fuse_fs* fuse_fs_new(const struct fuse_operations *op, - size_t op_size, - void *user_data) + size_t op_size) { struct fuse_fs *fs; @@ -4708,7 +4075,6 @@ fuse_fs_new(const struct fuse_operations *op, return NULL; } - fs->user_data = user_data; if(op) memcpy(&fs->op,op,op_size); @@ -4772,8 +4138,7 @@ struct fuse* fuse_new_common(struct fuse_chan *ch, struct fuse_args *args, const struct fuse_operations *op, - size_t op_size, - void *user_data) + size_t op_size) { struct fuse *f; struct node *root; @@ -4790,7 +4155,7 @@ fuse_new_common(struct fuse_chan *ch, goto out_delete_context_key; } - fs = fuse_fs_new(op,op_size,user_data); + fs = fuse_fs_new(op,op_size); if(!fs) goto out_free; @@ -4819,7 +4184,6 @@ fuse_new_common(struct fuse_chan *ch, /* Trace topmost layer by default */ srand(time(NULL)); - f->fs->debug = f->conf.debug; f->ctr = 0; f->generation = rand64(); if(node_table_init(&f->name_table) == -1) @@ -4876,10 +4240,9 @@ struct fuse* fuse_new(struct fuse_chan *ch, struct fuse_args *args, const struct fuse_operations *op, - size_t op_size, - void *user_data) + size_t op_size) { - return fuse_new_common(ch,args,op,op_size,user_data); + return fuse_new_common(ch,args,op,op_size); } void diff --git a/libfuse/lib/fuse_i.h b/libfuse/lib/fuse_i.h index af02847f..7ab1fcb9 100644 --- a/libfuse/lib/fuse_i.h +++ b/libfuse/lib/fuse_i.h @@ -35,23 +35,9 @@ struct fuse_req { struct fuse_ll *f; uint64_t unique; - int ctr; - pthread_mutex_t lock; struct fuse_ctx ctx; struct fuse_chan *ch; - int interrupted; unsigned int ioctl_64bit : 1; - union { - struct { - uint64_t unique; - } i; - struct { - fuse_interrupt_func_t func; - void *data; - } ni; - } u; - struct fuse_req *next; - struct fuse_req *prev; }; struct fuse_notify_req @@ -66,7 +52,6 @@ struct fuse_notify_req struct fuse_ll { int debug; - int allow_root; int no_remote_posix_lock; int no_remote_flock; int big_writes; @@ -81,8 +66,6 @@ struct fuse_ll void *userdata; uid_t owner; struct fuse_conn_info conn; - struct fuse_req list; - struct fuse_req interrupts; pthread_mutex_t lock; int got_destroy; pthread_key_t pipe_key; @@ -100,7 +83,7 @@ struct fuse_cmd struct fuse *fuse_new_common(struct fuse_chan *ch, struct fuse_args *args, const struct fuse_operations *op, - size_t op_size, void *user_data); + size_t op_size); struct fuse_chan *fuse_kern_chan_new(int fd); @@ -122,7 +105,6 @@ struct fuse *fuse_setup_common(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, char **mountpoint, - int *fd, - void *user_data); + int *fd); int fuse_start_thread(pthread_t *thread_id, void *(*func)(void *), void *arg); diff --git a/libfuse/lib/fuse_lowlevel.c b/libfuse/lib/fuse_lowlevel.c index 576021e3..0ad52d84 100644 --- a/libfuse/lib/fuse_lowlevel.c +++ b/libfuse/lib/fuse_lowlevel.c @@ -105,60 +105,13 @@ iov_length(const struct iovec *iov, return ret; } -static -void -list_init_req(struct fuse_req *req) -{ - req->next = req; - req->prev = req; -} - -static -void -list_del_req(struct fuse_req *req) -{ - struct fuse_req *prev = req->prev; - struct fuse_req *next = req->next; - prev->next = next; - next->prev = prev; -} - -static -void -list_add_req(struct fuse_req *req, - struct fuse_req *next) -{ - struct fuse_req *prev = next->prev; - req->next = next; - req->prev = prev; - prev->next = req; - next->prev = req; -} - static void destroy_req(fuse_req_t req) { - pthread_mutex_destroy(&req->lock); free(req); } -void -fuse_free_req(fuse_req_t req) -{ - int ctr; - struct fuse_ll *f = req->f; - - pthread_mutex_lock(&f->lock); - req->u.ni.func = NULL; - req->u.ni.data = NULL; - list_del_req(req); - ctr = --req->ctr; - pthread_mutex_unlock(&f->lock); - if(!ctr) - destroy_req(req); -} - static struct fuse_req* fuse_ll_alloc_req(struct fuse_ll *f) @@ -173,9 +126,6 @@ fuse_ll_alloc_req(struct fuse_ll *f) else { req->f = f; - req->ctr = 1; - list_init_req(req); - fuse_mutex_init(&req->lock); } return req; @@ -192,27 +142,6 @@ fuse_send_msg(struct fuse_ll *f, struct fuse_out_header *out = iov[0].iov_base; out->len = iov_length(iov, count); - if (f->debug) - { - if (out->unique == 0) - { - fprintf(stderr, "NOTIFY: code=%d length=%u\n", - out->error, out->len); - } - else if (out->error) - { - fprintf(stderr, - " unique: %llu, error: %i (%s), outsize: %i\n", - (unsigned long long) out->unique, out->error, - strerror(-out->error), out->len); - } - else - { - fprintf(stderr, - " unique: %llu, success, outsize: %i\n", - (unsigned long long) out->unique, out->len); - } - } return fuse_chan_send(ch, iov, count); } @@ -250,7 +179,7 @@ send_reply_iov(fuse_req_t req, int res; res = fuse_send_reply_iov_nofree(req, error, iov, count); - fuse_free_req(req); + destroy_req(req); return res; } @@ -295,52 +224,6 @@ fuse_reply_iov(fuse_req_t req, return res; } -size_t -fuse_dirent_size(size_t namelen) -{ - return FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + namelen); -} - -char* -fuse_add_dirent(char *buf, - const char *name, - const struct stat *stbuf, - off_t off) -{ - unsigned namelen = strlen(name); - unsigned entlen = FUSE_NAME_OFFSET + namelen; - unsigned entsize = fuse_dirent_size(namelen); - unsigned padlen = entsize - entlen; - struct fuse_dirent *dirent = (struct fuse_dirent *) buf; - - dirent->ino = stbuf->st_ino; - dirent->off = off; - dirent->namelen = namelen; - dirent->type = (stbuf->st_mode & 0170000) >> 12; - strncpy(dirent->name, name, namelen); - if (padlen) - memset(buf + entlen, 0, padlen); - - return buf + entsize; -} - -size_t -fuse_add_direntry(fuse_req_t req, - char *buf, - size_t bufsize, - const char *name, - const struct stat *stbuf, - off_t off) -{ - size_t entsize; - - (void) req; - entsize = fuse_dirent_size(strlen(name)); - if (entsize <= bufsize && buf) - fuse_add_dirent(buf, name, stbuf, off); - return entsize; -} - static void convert_statfs(const struct statvfs *stbuf, @@ -377,7 +260,7 @@ fuse_reply_none(fuse_req_t req) { if (req->ch) fuse_chan_send(req->ch, NULL, 0); - fuse_free_req(req); + destroy_req(req); } static @@ -414,7 +297,7 @@ int fuse_reply_entry(fuse_req_t req, const struct fuse_entry_param *e) { - struct fuse_entry_out arg; + struct fuse_entry_out arg = {0}; size_t size = req->f->conn.proto_minor < 9 ? FUSE_COMPAT_ENTRY_OUT_SIZE : sizeof(arg); @@ -423,7 +306,6 @@ fuse_reply_entry(fuse_req_t req, if (!e->ino && req->f->conn.proto_minor < 4) return fuse_reply_err(req, ENOENT); - memset(&arg, 0, sizeof(arg)); fill_entry(&arg, e); return send_reply_ok(req, &arg, size); @@ -434,13 +316,12 @@ fuse_reply_create(fuse_req_t req, const struct fuse_entry_param *e, const fuse_file_info_t *f) { - char buf[sizeof(struct fuse_entry_out) + sizeof(struct fuse_open_out)]; + char buf[sizeof(struct fuse_entry_out) + sizeof(struct fuse_open_out)] = {0}; size_t entrysize = req->f->conn.proto_minor < 9 ? FUSE_COMPAT_ENTRY_OUT_SIZE : sizeof(struct fuse_entry_out); struct fuse_entry_out *earg = (struct fuse_entry_out *) buf; struct fuse_open_out *oarg = (struct fuse_open_out *) (buf + entrysize); - memset(buf, 0, sizeof(buf)); fill_entry(earg, e); fill_open(oarg, f); @@ -452,11 +333,10 @@ fuse_reply_attr(fuse_req_t req, const struct stat *attr, const uint64_t timeout) { - struct fuse_attr_out arg; + struct fuse_attr_out arg = {0}; size_t size = req->f->conn.proto_minor < 9 ? FUSE_COMPAT_ATTR_OUT_SIZE : sizeof(arg); - memset(&arg,0,sizeof(arg)); arg.attr_valid = timeout; arg.attr_valid_nsec = 0; convert_stat(attr,&arg.attr); @@ -475,9 +355,8 @@ int fuse_reply_open(fuse_req_t req, const fuse_file_info_t *f) { - struct fuse_open_out arg; + struct fuse_open_out arg = {0}; - memset(&arg, 0, sizeof(arg)); fill_open(&arg, f); return send_reply_ok(req, &arg, sizeof(arg)); @@ -487,9 +366,8 @@ int fuse_reply_write(fuse_req_t req, size_t count) { - struct fuse_write_out arg; + struct fuse_write_out arg = {0}; - memset(&arg, 0, sizeof(arg)); arg.size = count; return send_reply_ok(req, &arg, sizeof(arg)); @@ -829,13 +707,6 @@ fuse_send_data_iov(struct fuse_ll *f, len = res; out->len = headerlen + len; - if (f->debug) - { - fprintf(stderr, - " unique: %llu, success, outsize: %i (splice)\n", - (unsigned long long) out->unique, out->len); - } - splice_flags = 0; if ((flags & FUSE_BUF_SPLICE_MOVE) && (f->conn.want & FUSE_CAP_SPLICE_MOVE)) @@ -901,7 +772,7 @@ fuse_reply_data(fuse_req_t req, res = fuse_send_data_iov(req->f, req->ch, iov, 1, bufv, flags); if (res <= 0) { - fuse_free_req(req); + destroy_req(req); return res; } else @@ -914,11 +785,10 @@ int fuse_reply_statfs(fuse_req_t req, const struct statvfs *stbuf) { - struct fuse_statfs_out arg; + struct fuse_statfs_out arg = {0}; size_t size = req->f->conn.proto_minor < 4 ? FUSE_COMPAT_STATFS_SIZE : sizeof(arg); - memset(&arg, 0, sizeof(arg)); convert_statfs(stbuf, &arg.st); return send_reply_ok(req, &arg, size); @@ -928,9 +798,8 @@ int fuse_reply_xattr(fuse_req_t req, size_t count) { - struct fuse_getxattr_out arg; + struct fuse_getxattr_out arg = {0}; - memset(&arg, 0, sizeof(arg)); arg.size = count; return send_reply_ok(req, &arg, sizeof(arg)); @@ -940,9 +809,8 @@ int fuse_reply_lock(fuse_req_t req, const struct flock *lock) { - struct fuse_lk_out arg; + struct fuse_lk_out arg = {0}; - memset(&arg, 0, sizeof(arg)); arg.lk.type = lock->l_type; if (lock->l_type != F_UNLCK) { @@ -961,9 +829,8 @@ int fuse_reply_bmap(fuse_req_t req, uint64_t idx) { - struct fuse_bmap_out arg; + struct fuse_bmap_out arg = {0}; - memset(&arg, 0, sizeof(arg)); arg.block = idx; return send_reply_ok(req, &arg, sizeof(arg)); @@ -997,14 +864,13 @@ fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *out_iov, size_t out_count) { - struct fuse_ioctl_out arg; + struct fuse_ioctl_out arg = {0}; struct fuse_ioctl_iovec *in_fiov = NULL; struct fuse_ioctl_iovec *out_fiov = NULL; struct iovec iov[4]; size_t count = 1; int res; - memset(&arg, 0, sizeof(arg)); arg.flags |= FUSE_IOCTL_RETRY; arg.in_iovs = in_count; arg.out_iovs = out_count; @@ -1031,7 +897,7 @@ fuse_reply_ioctl_retry(fuse_req_t req, else { /* Can't handle non-compat 64bit ioctls on 32bit */ - if (sizeof(void *) == 4 && req->ioctl_64bit) + if((sizeof(void *) == 4) && (req->ioctl_64bit)) { res = fuse_reply_err(req, EINVAL); goto out; @@ -1108,14 +974,13 @@ fuse_reply_ioctl_iov(fuse_req_t req, int count) { struct iovec *padded_iov; - struct fuse_ioctl_out arg; + struct fuse_ioctl_out arg = {0}; int res; padded_iov = malloc((count + 2) * sizeof(struct iovec)); if (padded_iov == NULL) return fuse_reply_err(req, ENOMEM); - memset(&arg, 0, sizeof(arg)); arg.result = result; padded_iov[1].iov_base = &arg; padded_iov[1].iov_len = sizeof(arg); @@ -1132,9 +997,8 @@ int fuse_reply_poll(fuse_req_t req, unsigned revents) { - struct fuse_poll_out arg; + struct fuse_poll_out arg = {0}; - memset(&arg, 0, sizeof(arg)); arg.revents = revents; return send_reply_ok(req, &arg, sizeof(arg)); @@ -1146,12 +1010,9 @@ do_lookup(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - char *name = (char *) inarg; + char *name = (char*)inarg; - if (req->f->op.lookup) - req->f->op.lookup(req, nodeid, name); - else - fuse_reply_err(req, ENOSYS); + req->f->op.lookup(req,nodeid,name); } static @@ -1160,12 +1021,9 @@ do_forget(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_forget_in *arg = (struct fuse_forget_in *) inarg; + struct fuse_forget_in *arg = (struct fuse_forget_in*)inarg; - if (req->f->op.forget) - req->f->op.forget(req, nodeid, arg->nlookup); - else - fuse_reply_none(req); + req->f->op.forget(req,nodeid,arg->nlookup); } static @@ -1176,38 +1034,12 @@ do_batch_forget(fuse_req_t req, { struct fuse_batch_forget_in *arg = (void *) inarg; struct fuse_forget_one *param = (void *) PARAM(arg); - unsigned int i; - - (void) nodeid; - - if (req->f->op.forget_multi) - { - req->f->op.forget_multi(req, arg->count, - (struct fuse_forget_data *) param); - } - else if (req->f->op.forget) - { - for (i = 0; i < arg->count; i++) - { - struct fuse_forget_one *forget = ¶m[i]; - struct fuse_req *dummy_req; - dummy_req = fuse_ll_alloc_req(req->f); - if (dummy_req == NULL) - break; + (void)nodeid; - dummy_req->unique = req->unique; - dummy_req->ctx = req->ctx; - dummy_req->ch = NULL; - - req->f->op.forget(dummy_req, forget->nodeid, forget->nlookup); - } - fuse_reply_none(req); - } - else - { - fuse_reply_none(req); - } + req->f->op.forget_multi(req, + arg->count, + (struct fuse_forget_data*)param); } static @@ -1217,24 +1049,20 @@ do_getattr(fuse_req_t req, const void *inarg) { fuse_file_info_t *fip = NULL; - fuse_file_info_t fi; + fuse_file_info_t fi = {0}; - if (req->f->conn.proto_minor >= 9) + if(req->f->conn.proto_minor >= 9) { - struct fuse_getattr_in *arg = (struct fuse_getattr_in *) inarg; + struct fuse_getattr_in *arg = (struct fuse_getattr_in*)inarg; - if (arg->getattr_flags & FUSE_GETATTR_FH) + if(arg->getattr_flags & FUSE_GETATTR_FH) { - memset(&fi, 0, sizeof(fi)); fi.fh = arg->fh; fip = &fi; } } - if (req->f->op.getattr) - req->f->op.getattr(req, nodeid, fip); - else - fuse_reply_err(req, ENOSYS); + req->f->op.getattr(req, nodeid, fip); } static @@ -1243,18 +1071,14 @@ do_setattr(fuse_req_t req_, fuse_ino_t nodeid_, const void *inarg_) { - struct stat stbuf; + struct stat stbuf = {0}; fuse_file_info_t *fi; fuse_file_info_t fi_store; struct fuse_setattr_in *arg; - if(req_->f->op.setattr == NULL) - return (void)fuse_reply_err(req_,ENOSYS); - fi = NULL; arg = (struct fuse_setattr_in*)inarg_; - memset(&stbuf,0,sizeof(stbuf)); convert_attr(arg,&stbuf); if(arg->valid & FATTR_FH) @@ -1285,12 +1109,9 @@ do_access(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_access_in *arg = (struct fuse_access_in *) inarg; + struct fuse_access_in *arg = (struct fuse_access_in *)inarg; - if (req->f->op.access) - req->f->op.access(req, nodeid, arg->mask); - else - fuse_reply_err(req, ENOSYS); + req->f->op.access(req, nodeid, arg->mask); } static @@ -1299,12 +1120,9 @@ do_readlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - (void) inarg; + (void)inarg; - if (req->f->op.readlink) - req->f->op.readlink(req, nodeid); - else - fuse_reply_err(req, ENOSYS); + req->f->op.readlink(req, nodeid); } static @@ -1319,12 +1137,9 @@ do_mknod(fuse_req_t req, if (req->f->conn.proto_minor >= 12) req->ctx.umask = arg->umask; else - name = (char *) inarg + FUSE_COMPAT_MKNOD_IN_SIZE; + name = (char*)inarg + FUSE_COMPAT_MKNOD_IN_SIZE; - if (req->f->op.mknod) - req->f->op.mknod(req, nodeid, name, arg->mode, arg->rdev); - else - fuse_reply_err(req, ENOSYS); + req->f->op.mknod(req, nodeid, name, arg->mode, arg->rdev); } static @@ -1335,13 +1150,10 @@ do_mkdir(fuse_req_t req, { struct fuse_mkdir_in *arg = (struct fuse_mkdir_in *) inarg; - if (req->f->conn.proto_minor >= 12) + if(req->f->conn.proto_minor >= 12) req->ctx.umask = arg->umask; - if (req->f->op.mkdir) - req->f->op.mkdir(req, nodeid, PARAM(arg), arg->mode); - else - fuse_reply_err(req, ENOSYS); + req->f->op.mkdir(req, nodeid, PARAM(arg), arg->mode); } static @@ -1350,12 +1162,9 @@ do_unlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - char *name = (char *) inarg; + char *name = (char*)inarg; - if (req->f->op.unlink) - req->f->op.unlink(req, nodeid, name); - else - fuse_reply_err(req, ENOSYS); + req->f->op.unlink(req,nodeid,name); } static @@ -1364,12 +1173,9 @@ do_rmdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - char *name = (char *) inarg; + char *name = (char*)inarg; - if (req->f->op.rmdir) - req->f->op.rmdir(req, nodeid, name); - else - fuse_reply_err(req, ENOSYS); + req->f->op.rmdir(req, nodeid, name); } static @@ -1378,13 +1184,10 @@ do_symlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - char *name = (char *) inarg; - char *linkname = ((char *) inarg) + strlen((char *) inarg) + 1; + char *name = (char*)inarg; + char *linkname = (name + strlen(name) + 1); - if (req->f->op.symlink) - req->f->op.symlink(req, linkname, nodeid, name); - else - fuse_reply_err(req, ENOSYS); + req->f->op.symlink(req, linkname, nodeid, name); } static @@ -1393,14 +1196,11 @@ do_rename(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_rename_in *arg = (struct fuse_rename_in *) inarg; + struct fuse_rename_in *arg = (struct fuse_rename_in*)inarg; char *oldname = PARAM(arg); char *newname = oldname + strlen(oldname) + 1; - if (req->f->op.rename) - req->f->op.rename(req, nodeid, oldname, arg->newdir, newname); - else - fuse_reply_err(req, ENOSYS); + req->f->op.rename(req, nodeid, oldname, arg->newdir, newname); } static @@ -1409,12 +1209,9 @@ do_link(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_link_in *arg = (struct fuse_link_in *) inarg; + struct fuse_link_in *arg = (struct fuse_link_in*)inarg; - if (req->f->op.link) - req->f->op.link(req, arg->oldnodeid, nodeid, PARAM(arg)); - else - fuse_reply_err(req, ENOSYS); + req->f->op.link(req,arg->oldnodeid,nodeid,PARAM(arg)); } static @@ -1423,27 +1220,18 @@ do_create(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_create_in *arg = (struct fuse_create_in *) inarg; - - if (req->f->op.create) - { - fuse_file_info_t fi; - char *name = PARAM(arg); - - memset(&fi, 0, sizeof(fi)); - fi.flags = arg->flags; + struct fuse_create_in *arg = (struct fuse_create_in*)inarg; + fuse_file_info_t fi = {0}; + char *name = PARAM(arg); - if (req->f->conn.proto_minor >= 12) - req->ctx.umask = arg->umask; - else - name = (char *) inarg + sizeof(struct fuse_open_in); + fi.flags = arg->flags; - req->f->op.create(req, nodeid, name, arg->mode, &fi); - } + if (req->f->conn.proto_minor >= 12) + req->ctx.umask = arg->umask; else - { - fuse_reply_err(req, ENOSYS); - } + name = (char*)inarg + sizeof(struct fuse_open_in); + + req->f->op.create(req, nodeid, name, arg->mode, &fi); } static @@ -1452,16 +1240,12 @@ do_open(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_open_in *arg = (struct fuse_open_in *) inarg; - fuse_file_info_t fi; + fuse_file_info_t fi = {0}; + struct fuse_open_in *arg = (struct fuse_open_in*)inarg; - memset(&fi, 0, sizeof(fi)); fi.flags = arg->flags; - if (req->f->op.open) - req->f->op.open(req, nodeid, &fi); - else - fuse_reply_open(req, &fi); + req->f->op.open(req, nodeid, &fi); } static @@ -1470,26 +1254,17 @@ do_read(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_read_in *arg = (struct fuse_read_in *) inarg; - - if (req->f->op.read) - { - fuse_file_info_t fi; + fuse_file_info_t fi = {0}; + struct fuse_read_in *arg = (struct fuse_read_in*)inarg; - memset(&fi, 0, sizeof(fi)); - fi.fh = arg->fh; - if (req->f->conn.proto_minor >= 9) - { - fi.lock_owner = arg->lock_owner; - fi.flags = arg->flags; - } - - req->f->op.read(req, nodeid, arg->size, arg->offset, &fi); - } - else + fi.fh = arg->fh; + if (req->f->conn.proto_minor >= 9) { - fuse_reply_err(req, ENOSYS); + fi.lock_owner = arg->lock_owner; + fi.flags = arg->flags; } + + req->f->op.read(req, nodeid, arg->size, arg->offset, &fi); } static @@ -1498,17 +1273,16 @@ do_write(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_write_in *arg = (struct fuse_write_in *) inarg; - fuse_file_info_t fi; char *param; + fuse_file_info_t fi = {0}; + struct fuse_write_in *arg = (struct fuse_write_in*)inarg; - memset(&fi, 0, sizeof(fi)); fi.fh = arg->fh; fi.writepage = arg->write_flags & 1; - if (req->f->conn.proto_minor < 9) + if(req->f->conn.proto_minor < 9) { - param = ((char *) arg) + FUSE_COMPAT_WRITE_IN_SIZE; + param = ((char*)arg) + FUSE_COMPAT_WRITE_IN_SIZE; } else { @@ -1517,10 +1291,7 @@ do_write(fuse_req_t req, param = PARAM(arg); } - if (req->f->op.write) - req->f->op.write(req, nodeid, param, arg->size, arg->offset, &fi); - else - fuse_reply_err(req, ENOSYS); + req->f->op.write(req,nodeid,param,arg->size,arg->offset,&fi); } static @@ -1535,10 +1306,9 @@ do_write_buf(fuse_req_t req, .buf[0] = *ibuf, .count = 1, }; + fuse_file_info_t fi = {0}; struct fuse_write_in *arg = (struct fuse_write_in *) inarg; - fuse_file_info_t fi; - memset(&fi, 0, sizeof(fi)); fi.fh = arg->fh; fi.writepage = arg->write_flags & 1; @@ -1582,19 +1352,15 @@ do_flush(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { + fuse_file_info_t fi = {0}; struct fuse_flush_in *arg = (struct fuse_flush_in *) inarg; - fuse_file_info_t fi; - memset(&fi, 0, sizeof(fi)); fi.fh = arg->fh; fi.flush = 1; - if (req->f->conn.proto_minor >= 7) + if(req->f->conn.proto_minor >= 7) fi.lock_owner = arg->lock_owner; - if (req->f->op.flush) - req->f->op.flush(req, nodeid, &fi); - else - fuse_reply_err(req, ENOSYS); + req->f->op.flush(req,nodeid,&fi); } static @@ -1603,28 +1369,24 @@ do_release(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_release_in *arg = (struct fuse_release_in *) inarg; - fuse_file_info_t fi; + fuse_file_info_t fi = {0}; + struct fuse_release_in *arg = (struct fuse_release_in*)inarg; - memset(&fi, 0, sizeof(fi)); fi.flags = arg->flags; fi.fh = arg->fh; - if (req->f->conn.proto_minor >= 8) + if(req->f->conn.proto_minor >= 8) { fi.flush = (arg->release_flags & FUSE_RELEASE_FLUSH) ? 1 : 0; fi.lock_owner = arg->lock_owner; } - if (arg->release_flags & FUSE_RELEASE_FLOCK_UNLOCK) + if(arg->release_flags & FUSE_RELEASE_FLOCK_UNLOCK) { fi.flock_release = 1; fi.lock_owner = arg->lock_owner; } - if (req->f->op.release) - req->f->op.release(req, nodeid, &fi); - else - fuse_reply_err(req, 0); + req->f->op.release(req,nodeid,&fi); } static @@ -1633,16 +1395,12 @@ do_fsync(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_fsync_in *arg = (struct fuse_fsync_in *) inarg; - fuse_file_info_t fi; + fuse_file_info_t fi = {0}; + struct fuse_fsync_in *arg = (struct fuse_fsync_in*)inarg; - memset(&fi, 0, sizeof(fi)); fi.fh = arg->fh; - if (req->f->op.fsync) - req->f->op.fsync(req, nodeid, arg->fsync_flags & 1, &fi); - else - fuse_reply_err(req, ENOSYS); + req->f->op.fsync(req,nodeid,arg->fsync_flags & 1, &fi); } static @@ -1651,16 +1409,12 @@ do_opendir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_open_in *arg = (struct fuse_open_in *) inarg; - fuse_file_info_t fi; + fuse_file_info_t fi = {0}; + struct fuse_open_in *arg = (struct fuse_open_in*)inarg; - memset(&fi, 0, sizeof(fi)); fi.flags = arg->flags; - if (req->f->op.opendir) - req->f->op.opendir(req, nodeid, &fi); - else - fuse_reply_open(req, &fi); + req->f->op.opendir(req,nodeid,&fi); } static @@ -1669,16 +1423,12 @@ do_readdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_read_in *arg = (struct fuse_read_in *) inarg; - fuse_file_info_t fi; + fuse_file_info_t fi = {0}; + struct fuse_read_in *arg = (struct fuse_read_in*)inarg; - memset(&fi, 0, sizeof(fi)); fi.fh = arg->fh; - if (req->f->op.readdir) - req->f->op.readdir(req, nodeid, arg->size, arg->offset, &fi); - else - fuse_reply_err(req, ENOSYS); + req->f->op.readdir(req,nodeid,arg->size,arg->offset,&fi); } static @@ -1693,10 +1443,7 @@ do_readdir_plus(fuse_req_t req_, arg = (struct fuse_read_in*)inarg_; ffi.fh = arg->fh; - if(req_->f->op.readdir_plus) - req_->f->op.readdir_plus(req_,nodeid_,arg->size,arg->offset,&ffi); - else - fuse_reply_err(req_,ENOSYS); + req_->f->op.readdir_plus(req_,nodeid_,arg->size,arg->offset,&ffi); } static @@ -1705,17 +1452,13 @@ do_releasedir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_release_in *arg = (struct fuse_release_in *) inarg; - fuse_file_info_t fi; + fuse_file_info_t fi = {0}; + struct fuse_release_in *arg = (struct fuse_release_in*)inarg; - memset(&fi, 0, sizeof(fi)); fi.flags = arg->flags; fi.fh = arg->fh; - if (req->f->op.releasedir) - req->f->op.releasedir(req, nodeid, &fi); - else - fuse_reply_err(req, 0); + req->f->op.releasedir(req,nodeid,&fi); } static @@ -1724,16 +1467,12 @@ do_fsyncdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_fsync_in *arg = (struct fuse_fsync_in *) inarg; - fuse_file_info_t fi; + fuse_file_info_t fi = {0}; + struct fuse_fsync_in *arg = (struct fuse_fsync_in*)inarg; - memset(&fi, 0, sizeof(fi)); fi.fh = arg->fh; - if (req->f->op.fsyncdir) - req->f->op.fsyncdir(req, nodeid, arg->fsync_flags & 1, &fi); - else - fuse_reply_err(req, ENOSYS); + req->f->op.fsyncdir(req,nodeid,arg->fsync_flags & 1,&fi); } static @@ -1742,22 +1481,10 @@ do_statfs(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - (void) nodeid; - (void) inarg; - - if (req->f->op.statfs) - { - req->f->op.statfs(req, nodeid); - } - else - { - struct statvfs buf = {0}; - - buf.f_namemax = 255; - buf.f_bsize = 512; + (void)nodeid; + (void)inarg; - fuse_reply_statfs(req, &buf); - } + req->f->op.statfs(req, nodeid); } static @@ -1766,14 +1493,11 @@ do_setxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_setxattr_in *arg = (struct fuse_setxattr_in *) inarg; - char *name = PARAM(arg); + struct fuse_setxattr_in *arg = (struct fuse_setxattr_in*)inarg; + char *name = PARAM(arg); char *value = name + strlen(name) + 1; - if (req->f->op.setxattr) - req->f->op.setxattr(req, nodeid, name, value, arg->size, arg->flags); - else - fuse_reply_err(req, ENOSYS); + req->f->op.setxattr(req, nodeid, name, value, arg->size, arg->flags); } static @@ -1782,12 +1506,9 @@ do_getxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_getxattr_in *arg = (struct fuse_getxattr_in *)inarg; + struct fuse_getxattr_in *arg = (struct fuse_getxattr_in*)inarg; - if (req->f->op.getxattr) - req->f->op.getxattr(req, nodeid, PARAM(arg), arg->size); - else - fuse_reply_err(req, ENOSYS); + req->f->op.getxattr(req, nodeid, PARAM(arg), arg->size); } static @@ -1796,12 +1517,9 @@ do_listxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_getxattr_in *arg = (struct fuse_getxattr_in *) inarg; + struct fuse_getxattr_in *arg = (struct fuse_getxattr_in*)inarg; - if (req->f->op.listxattr) - req->f->op.listxattr(req, nodeid, arg->size); - else - fuse_reply_err(req, ENOSYS); + req->f->op.listxattr(req, nodeid, arg->size); } static @@ -1812,10 +1530,7 @@ do_removexattr(fuse_req_t req, { char *name = (char *) inarg; - if (req->f->op.removexattr) - req->f->op.removexattr(req, nodeid, name); - else - fuse_reply_err(req, ENOSYS); + req->f->op.removexattr(req, nodeid, name); } static @@ -1840,19 +1555,16 @@ do_getlk(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_lk_in *arg = (struct fuse_lk_in *) inarg; - fuse_file_info_t fi; + fuse_file_info_t fi = {0}; struct flock flock; + struct fuse_lk_in *arg = (struct fuse_lk_in*)inarg; - memset(&fi, 0, sizeof(fi)); - fi.fh = arg->fh; + fi.fh = arg->fh; fi.lock_owner = arg->owner; convert_fuse_file_lock(&arg->lk, &flock); - if (req->f->op.getlk) - req->f->op.getlk(req, nodeid, &fi, &flock); - else - fuse_reply_err(req, ENOSYS); + + req->f->op.getlk(req, nodeid, &fi, &flock); } static @@ -1862,11 +1574,10 @@ do_setlk_common(fuse_req_t req, const void *inarg, int sleep) { - struct fuse_lk_in *arg = (struct fuse_lk_in *) inarg; - fuse_file_info_t fi; struct flock flock; + fuse_file_info_t fi = {0}; + struct fuse_lk_in *arg = (struct fuse_lk_in *) inarg; - memset(&fi, 0, sizeof(fi)); fi.fh = arg->fh; fi.lock_owner = arg->owner; @@ -1890,18 +1601,13 @@ do_setlk_common(fuse_req_t req, if (!sleep) op |= LOCK_NB; - if (req->f->op.flock) - req->f->op.flock(req, nodeid, &fi, op); - else - fuse_reply_err(req, ENOSYS); + req->f->op.flock(req,nodeid,&fi,op); } else { convert_fuse_file_lock(&arg->lk, &flock); - if (req->f->op.setlk) - req->f->op.setlk(req, nodeid, &fi, &flock, sleep); - else - fuse_reply_err(req, ENOSYS); + + req->f->op.setlk(req,nodeid,&fi,&flock,sleep); } } @@ -1923,107 +1629,15 @@ do_setlkw(fuse_req_t req, do_setlk_common(req, nodeid, inarg, 1); } -static -int -find_interrupted(struct fuse_ll *f, - struct fuse_req *req) -{ - struct fuse_req *curr; - - for (curr = f->list.next; curr != &f->list; curr = curr->next) - { - if (curr->unique == req->u.i.unique) - { - fuse_interrupt_func_t func; - void *data; - - curr->ctr++; - pthread_mutex_unlock(&f->lock); - - /* Ugh, ugly locking */ - pthread_mutex_lock(&curr->lock); - pthread_mutex_lock(&f->lock); - curr->interrupted = 1; - func = curr->u.ni.func; - data = curr->u.ni.data; - pthread_mutex_unlock(&f->lock); - if (func) - func(curr, data); - pthread_mutex_unlock(&curr->lock); - - pthread_mutex_lock(&f->lock); - curr->ctr--; - if (!curr->ctr) - destroy_req(curr); - - return 1; - } - } - - for (curr = f->interrupts.next; curr != &f->interrupts; - curr = curr->next) - { - if (curr->u.i.unique == req->u.i.unique) - return 1; - } - return 0; -} - static void do_interrupt(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_interrupt_in *arg = (struct fuse_interrupt_in *) inarg; - struct fuse_ll *f = req->f; - - (void) nodeid; - if (f->debug) - fprintf(stderr, "INTERRUPT: %llu\n", - (unsigned long long) arg->unique); - - req->u.i.unique = arg->unique; - - pthread_mutex_lock(&f->lock); - if(find_interrupted(f, req)) - destroy_req(req); - else - list_add_req(req, &f->interrupts); - pthread_mutex_unlock(&f->lock); -} - -static -struct -fuse_req* -check_interrupt(struct fuse_ll *f, - struct fuse_req *req) -{ - struct fuse_req *curr; - - for (curr = f->interrupts.next; curr != &f->interrupts; - curr = curr->next) - { - if (curr->u.i.unique == req->unique) - { - req->interrupted = 1; - list_del_req(curr); - free(curr); - return NULL; - } - } - - curr = f->interrupts.next; - if (curr != &f->interrupts) - { - list_del_req(curr); - list_init_req(curr); - return curr; - } - else - { - return NULL; - } + pthread_mutex_lock(&req->f->lock); + destroy_req(req); + pthread_mutex_unlock(&req->f->lock); } static @@ -2032,12 +1646,9 @@ do_bmap(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { - struct fuse_bmap_in *arg = (struct fuse_bmap_in *) inarg; + struct fuse_bmap_in *arg = (struct fuse_bmap_in*)inarg; - if (req->f->op.bmap) - req->f->op.bmap(req, nodeid, arg->blocksize, arg->block); - else - fuse_reply_err(req, ENOSYS); + req->f->op.bmap(req,nodeid,arg->blocksize,arg->block); } static @@ -2046,32 +1657,29 @@ do_ioctl(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { + fuse_file_info_t fi = {0}; struct fuse_ioctl_in *arg = (struct fuse_ioctl_in *) inarg; unsigned int flags = arg->flags; void *in_buf = arg->in_size ? PARAM(arg) : NULL; - fuse_file_info_t fi; - if (flags & FUSE_IOCTL_DIR && !(req->f->conn.want & FUSE_CAP_IOCTL_DIR)) + if((flags & FUSE_IOCTL_DIR) && !(req->f->conn.want & FUSE_CAP_IOCTL_DIR)) { - fuse_reply_err(req, ENOTTY); + fuse_reply_err(req,ENOTTY); return; } - memset(&fi, 0, sizeof(fi)); fi.fh = arg->fh; - if(sizeof(void *) == 4 && req->f->conn.proto_minor >= 16 && + if((sizeof(void *) == 4) && + (req->f->conn.proto_minor >= 16) && !(flags & FUSE_IOCTL_32BIT)) { req->ioctl_64bit = 1; } - if (req->f->op.ioctl) - req->f->op.ioctl(req, nodeid, (unsigned long)arg->cmd, - (void *)(uintptr_t)arg->arg, &fi, flags, - in_buf, arg->in_size, arg->out_size); - else - fuse_reply_err(req, ENOSYS); + req->f->op.ioctl(req, nodeid, (unsigned long)arg->cmd, + (void *)(uintptr_t)arg->arg, &fi, flags, + in_buf, arg->in_size, arg->out_size); } void @@ -2086,34 +1694,25 @@ do_poll(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { + fuse_file_info_t fi = {0}; + fuse_pollhandle_t *ph = NULL; struct fuse_poll_in *arg = (struct fuse_poll_in *) inarg; - fuse_file_info_t fi; - memset(&fi, 0, sizeof(fi)); fi.fh = arg->fh; - if (req->f->op.poll) - { - fuse_pollhandle_t *ph = NULL; - - if (arg->flags & FUSE_POLL_SCHEDULE_NOTIFY) - { - ph = malloc(sizeof(fuse_pollhandle_t)); - if (ph == NULL) { - fuse_reply_err(req, ENOMEM); - return; - } - ph->kh = arg->kh; - ph->ch = req->ch; - ph->f = req->f; - } - - req->f->op.poll(req, nodeid, &fi, ph); - } - else + if(arg->flags & FUSE_POLL_SCHEDULE_NOTIFY) { - fuse_reply_err(req, ENOSYS); + ph = malloc(sizeof(fuse_pollhandle_t)); + if (ph == NULL) { + fuse_reply_err(req, ENOMEM); + return; + } + ph->kh = arg->kh; + ph->ch = req->ch; + ph->f = req->f; } + + req->f->op.poll(req,nodeid,&fi,ph); } static @@ -2122,16 +1721,12 @@ do_fallocate(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { + fuse_file_info_t fi = {0}; struct fuse_fallocate_in *arg = (struct fuse_fallocate_in *) inarg; - fuse_file_info_t fi; - memset(&fi, 0, sizeof(fi)); fi.fh = arg->fh; - if (req->f->op.fallocate) - req->f->op.fallocate(req, nodeid, arg->mode, arg->offset, arg->length, &fi); - else - fuse_reply_err(req, ENOSYS); + req->f->op.fallocate(req, nodeid, arg->mode, arg->offset, arg->length, &fi); } static @@ -2140,30 +1735,18 @@ do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { + struct fuse_init_out outarg = {0}; struct fuse_init_in *arg = (struct fuse_init_in *) inarg; - struct fuse_init_out outarg; struct fuse_ll *f = req->f; size_t bufsize = fuse_chan_bufsize(req->ch); (void) nodeid; - if (f->debug) - { - fprintf(stderr, "INIT: %u.%u\n", arg->major, arg->minor); - if (arg->major == 7 && arg->minor >= 6) - { - fprintf(stderr, "flags=0x%08x\n", arg->flags); - fprintf(stderr, "max_readahead=0x%08x\n", - arg->max_readahead); - } - } f->conn.proto_major = arg->major; f->conn.proto_minor = arg->minor; f->conn.capable = 0; f->conn.want = 0; - memset(&outarg, 0, sizeof(outarg)); - outarg.major = FUSE_KERNEL_VERSION; outarg.minor = FUSE_KERNEL_MINOR_VERSION; outarg.max_pages = FUSE_DEFAULT_MAX_PAGES_PER_REQ; @@ -2322,20 +1905,6 @@ do_init(fuse_req_t req, outarg.congestion_threshold = f->conn.congestion_threshold; } - if (f->debug) - { - fprintf(stderr, " INIT: %u.%u\n", outarg.major, outarg.minor); - fprintf(stderr, " flags=0x%08x\n", outarg.flags); - fprintf(stderr, " max_readahead=0x%08x\n", - outarg.max_readahead); - fprintf(stderr, " max_write=0x%08x\n", outarg.max_write); - fprintf(stderr, " max_background=%i\n", - outarg.max_background); - fprintf(stderr, " congestion_threshold=%i\n", - outarg.congestion_threshold); - fprintf(stderr, " max_pages=%d\n",outarg.max_pages); - } - size_t outargsize; if(arg->minor < 5) outargsize = FUSE_COMPAT_INIT_OUT_SIZE; @@ -2359,10 +1928,9 @@ do_destroy(fuse_req_t req, (void) inarg; f->got_destroy = 1; - if (f->op.destroy) - f->op.destroy(f->userdata); + f->op.destroy(f->userdata); - send_reply_ok(req, NULL, 0); + send_reply_ok(req,NULL,0); } static @@ -2436,18 +2004,15 @@ do_copy_file_range(fuse_req_t req_, ffi_in.fh = arg->fh_in; ffi_out.fh = arg->fh_out; - if(req_->f->op.copy_file_range == NULL) - fuse_reply_err(req_,ENOSYS); - else - req_->f->op.copy_file_range(req_, - nodeid_in_, - arg->off_in, - &ffi_in, - arg->nodeid_out, - arg->off_out, - &ffi_out, - arg->len, - arg->flags); + req_->f->op.copy_file_range(req_, + nodeid_in_, + arg->off_in, + &ffi_in, + arg->nodeid_out, + arg->off_out, + &ffi_out, + arg->len, + arg->flags); } static @@ -2514,7 +2079,7 @@ fuse_lowlevel_notify_inval_inode(struct fuse_chan *ch, outarg.len = len; iov[1].iov_base = &outarg; - iov[1].iov_len = sizeof(outarg); + iov[1].iov_len = sizeof(outarg); return send_notify_iov(f, ch, FUSE_NOTIFY_INVAL_INODE, iov, 2); } @@ -2746,33 +2311,6 @@ fuse_req_ctx(fuse_req_t req) return &req->ctx; } -void -fuse_req_interrupt_func(fuse_req_t req, - fuse_interrupt_func_t func, - void *data) -{ - pthread_mutex_lock(&req->lock); - pthread_mutex_lock(&req->f->lock); - req->u.ni.func = func; - req->u.ni.data = data; - pthread_mutex_unlock(&req->f->lock); - if (req->interrupted && func) - func(req, data); - pthread_mutex_unlock(&req->lock); -} - -int -fuse_req_interrupted(fuse_req_t req) -{ - int interrupted; - - pthread_mutex_lock(&req->f->lock); - interrupted = req->interrupted; - pthread_mutex_unlock(&req->f->lock); - - return interrupted; -} - static struct { void (*func)(fuse_req_t, fuse_ino_t, const void *); const char *name; @@ -2825,16 +2363,6 @@ static struct { #define FUSE_MAXOP (sizeof(fuse_ll_ops) / sizeof(fuse_ll_ops[0])) -static -const char * -opname(enum fuse_opcode opcode) -{ - if (opcode >= FUSE_MAXOP || !fuse_ll_ops[opcode].name) - return "???"; - else - return fuse_ll_ops[opcode].name; -} - static int fuse_ll_copy_from_pipe(struct fuse_bufvec *dst, @@ -2898,15 +2426,6 @@ fuse_ll_process_buf(void *data, in = buf->mem; } - if (f->debug) - { - fprintf(stderr, - "unique: %llu, opcode: %s (%i), nodeid: %lu, insize: %zu, pid: %u\n", - (unsigned long long) in->unique, - opname((enum fuse_opcode) in->opcode), in->opcode, - (unsigned long) in->nodeid, buf->size, in->pid); - } - req = fuse_ll_alloc_req(f); if (req == NULL) { @@ -2943,34 +2462,9 @@ fuse_ll_process_buf(void *data, goto reply_err; } - err = EACCES; - if (f->allow_root && - in->uid != f->owner && - in->uid != 0 && - in->opcode != FUSE_INIT && - in->opcode != FUSE_READ && - in->opcode != FUSE_WRITE && - in->opcode != FUSE_FSYNC && - in->opcode != FUSE_RELEASE && - in->opcode != FUSE_READDIR && - in->opcode != FUSE_READDIRPLUS && - in->opcode != FUSE_FSYNCDIR && - in->opcode != FUSE_RELEASEDIR && - in->opcode != FUSE_NOTIFY_REPLY) - goto reply_err; - err = ENOSYS; if (in->opcode >= FUSE_MAXOP || !fuse_ll_ops[in->opcode].func) goto reply_err; - if (in->opcode != FUSE_INTERRUPT) { - struct fuse_req *intr; - pthread_mutex_lock(&f->lock); - intr = check_interrupt(f, req); - list_add_req(req, &f->list); - pthread_mutex_unlock(&f->lock); - if (intr) - fuse_reply_err(intr, EAGAIN); - } if ((buf->flags & FUSE_BUF_IS_FD) && write_header_size < buf->size && (in->opcode != FUSE_WRITE || !f->op.write_buf) && @@ -2996,7 +2490,7 @@ fuse_ll_process_buf(void *data, } inarg = (void *) &in[1]; - if (in->opcode == FUSE_WRITE && f->op.write_buf) + if (in->opcode == FUSE_WRITE) do_write_buf(req, in->nodeid, inarg, buf); else if (in->opcode == FUSE_NOTIFY_REPLY) do_notify_reply(req, in->nodeid, inarg, buf); @@ -3039,7 +2533,6 @@ static const struct fuse_opt fuse_ll_opts[] = { { "debug", offsetof(struct fuse_ll, debug), 1 }, { "-d", offsetof(struct fuse_ll, debug), 1 }, - { "allow_root", offsetof(struct fuse_ll, allow_root), 1 }, { "max_readahead=%u", offsetof(struct fuse_ll, conn.max_readahead), 0 }, { "max_background=%u", offsetof(struct fuse_ll, conn.max_background), 0 }, { "congestion_threshold=%u", @@ -3315,8 +2808,6 @@ fuse_lowlevel_new_common(struct fuse_args *args, f->conn.max_write = UINT_MAX; f->conn.max_readahead = UINT_MAX; - list_init_req(&f->list); - list_init_req(&f->interrupts); list_init_nreq(&f->notify_list); f->notify_ctr = 1; fuse_mutex_init(&f->lock); @@ -3332,9 +2823,6 @@ fuse_lowlevel_new_common(struct fuse_args *args, if (fuse_opt_parse(args, f, fuse_ll_opts, fuse_ll_opt_proc) == -1) goto out_key_destroy; - if (f->debug) - fprintf(stderr, "FUSE library version: %s\n", PACKAGE_VERSION); - memcpy(&f->op, op, op_size); f->owner = getuid(); f->userdata = userdata; diff --git a/libfuse/lib/helper.c b/libfuse/lib/helper.c index c9f0cc5f..949b9d09 100644 --- a/libfuse/lib/helper.c +++ b/libfuse/lib/helper.c @@ -290,8 +290,7 @@ struct fuse *fuse_setup_common(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, char **mountpoint, - int *fd, - void *user_data) + int *fd) { struct fuse_args args = FUSE_ARGS_INIT(argc, argv); struct fuse_chan *ch; @@ -309,7 +308,7 @@ struct fuse *fuse_setup_common(int argc, char *argv[], goto err_free; } - fuse = fuse_new_common(ch, &args, op, op_size, user_data); + fuse = fuse_new_common(ch, &args, op, op_size); fuse_opt_free_args(&args); if (fuse == NULL) goto err_unmount; @@ -338,10 +337,10 @@ struct fuse *fuse_setup_common(int argc, char *argv[], struct fuse *fuse_setup(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, - char **mountpoint, void *user_data) + char **mountpoint) { return fuse_setup_common(argc, argv, op, op_size, mountpoint, - NULL, user_data); + NULL); } static void fuse_teardown_common(struct fuse *fuse, char *mountpoint) @@ -360,8 +359,7 @@ void fuse_teardown(struct fuse *fuse, char *mountpoint) } static int fuse_main_common(int argc, char *argv[], - const struct fuse_operations *op, size_t op_size, - void *user_data) + const struct fuse_operations *op, size_t op_size) { struct fuse *fuse; char *mountpoint; @@ -369,7 +367,7 @@ static int fuse_main_common(int argc, char *argv[], fuse = fuse_setup_common(argc, argv, op, op_size, &mountpoint, - NULL, user_data); + NULL); if (fuse == NULL) return 1; @@ -382,10 +380,12 @@ static int fuse_main_common(int argc, char *argv[], return 0; } -int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, - size_t op_size, void *user_data) +int fuse_main_real(int argc, + char *argv[], + const struct fuse_operations *op, + size_t op_size) { - return fuse_main_common(argc, argv, op, op_size, user_data); + return fuse_main_common(argc, argv, op, op_size); } #undef fuse_main diff --git a/libfuse/lib/mount_bsd.c b/libfuse/lib/mount_bsd.c index 82e7b6c7..4890dacf 100644 --- a/libfuse/lib/mount_bsd.c +++ b/libfuse/lib/mount_bsd.c @@ -28,7 +28,6 @@ #define FUSE_DEV_TRUNK "/dev/fuse" enum { - KEY_ALLOW_ROOT, KEY_RO, KEY_HELP, KEY_VERSION, @@ -37,7 +36,6 @@ enum { struct mount_opts { int allow_other; - int allow_root; int ishelp; char *kernel_opts; }; @@ -47,8 +45,6 @@ struct mount_opts { static const struct fuse_opt fuse_mount_opts[] = { { "allow_other", offsetof(struct mount_opts, allow_other), 1 }, - { "allow_root", offsetof(struct mount_opts, allow_root), 1 }, - FUSE_OPT_KEY("allow_root", KEY_ALLOW_ROOT), FUSE_OPT_KEY("-r", KEY_RO), FUSE_OPT_KEY("-h", KEY_HELP), FUSE_OPT_KEY("--help", KEY_HELP), @@ -102,7 +98,6 @@ static const struct fuse_opt fuse_mount_opts[] = { static void mount_help(void) { fprintf(stderr, - " -o allow_root allow access to root\n" ); system(FUSERMOUNT_PROG " --help"); fputc('\n', stderr); @@ -119,12 +114,6 @@ static int fuse_mount_opt_proc(void *data, const char *arg, int key, struct mount_opts *mo = data; switch (key) { - case KEY_ALLOW_ROOT: - if (fuse_opt_add_opt(&mo->kernel_opts, "allow_other") == -1 || - fuse_opt_add_arg(outargs, "-oallow_root") == -1) - return -1; - return 0; - case KEY_RO: arg = "ro"; /* fall through */ @@ -328,10 +317,6 @@ int fuse_kern_mount(const char *mountpoint, struct fuse_args *args) fuse_opt_parse(args, &mo, fuse_mount_opts, fuse_mount_opt_proc) == -1) return -1; - if (mo.allow_other && mo.allow_root) { - fprintf(stderr, "fuse: 'allow_other' and 'allow_root' options are mutually exclusive\n"); - goto out; - } if (mo.ishelp) return 0; diff --git a/libfuse/lib/mount_generic.c b/libfuse/lib/mount_generic.c index 249ef74f..807f580f 100644 --- a/libfuse/lib/mount_generic.c +++ b/libfuse/lib/mount_generic.c @@ -55,7 +55,6 @@ enum { KEY_FUSERMOUNT_OPT, KEY_SUBTYPE_OPT, KEY_MTAB_OPT, - KEY_ALLOW_ROOT, KEY_RO, KEY_HELP, KEY_VERSION, @@ -63,7 +62,6 @@ enum { struct mount_opts { int allow_other; - int allow_root; int ishelp; int flags; int nonempty; @@ -81,14 +79,12 @@ struct mount_opts { static const struct fuse_opt fuse_mount_opts[] = { FUSE_MOUNT_OPT("allow_other", allow_other), - FUSE_MOUNT_OPT("allow_root", allow_root), FUSE_MOUNT_OPT("nonempty", nonempty), FUSE_MOUNT_OPT("blkdev", blkdev), FUSE_MOUNT_OPT("auto_unmount", auto_unmount), FUSE_MOUNT_OPT("fsname=%s", fsname), FUSE_MOUNT_OPT("subtype=%s", subtype), FUSE_OPT_KEY("allow_other", KEY_KERN_OPT), - FUSE_OPT_KEY("allow_root", KEY_ALLOW_ROOT), FUSE_OPT_KEY("nonempty", KEY_FUSERMOUNT_OPT), FUSE_OPT_KEY("auto_unmount", KEY_FUSERMOUNT_OPT), FUSE_OPT_KEY("blkdev", KEY_FUSERMOUNT_OPT), @@ -129,7 +125,6 @@ static void mount_help(void) { fprintf(stderr, " -o allow_other allow access to other users\n" - " -o allow_root allow access to root\n" " -o auto_unmount auto unmount on process termination\n" " -o nonempty allow mounts over non-empty file/dir\n" " -o default_permissions enable permission checking by kernel\n" @@ -208,12 +203,6 @@ static int fuse_mount_opt_proc(void *data, const char *arg, int key, struct mount_opts *mo = data; switch (key) { - case KEY_ALLOW_ROOT: - if (fuse_opt_add_opt(&mo->kernel_opts, "allow_other") == -1 || - fuse_opt_add_arg(outargs, "-oallow_root") == -1) - return -1; - return 0; - case KEY_RO: arg = "ro"; /* fall through */ @@ -575,10 +564,6 @@ int fuse_kern_mount(const char *mountpoint, struct fuse_args *args) fuse_opt_parse(args, &mo, fuse_mount_opts, fuse_mount_opt_proc) == -1) return -1; - if (mo.allow_other && mo.allow_root) { - fprintf(stderr, "fuse: 'allow_other' and 'allow_root' options are mutually exclusive\n"); - goto out; - } res = 0; if (mo.ishelp) goto out; diff --git a/libfuse/util/fusermount.c b/libfuse/util/fusermount.c index 5acdba7a..512e80de 100644 --- a/libfuse/util/fusermount.c +++ b/libfuse/util/fusermount.c @@ -782,9 +782,7 @@ static int do_mount(const char *mnt, char **typep, mode_t rootmode, skip_option = 1; } } - if (getuid() != 0 && !user_allow_other && - (opt_eq(s, len, "allow_other") || - opt_eq(s, len, "allow_root"))) { + if (getuid() != 0 && !user_allow_other && opt_eq(s, len, "allow_other")) { fprintf(stderr, "%s: option %.*s only allowed if 'user_allow_other' is set in /etc/fuse.conf\n", progname, len, s); goto err; } diff --git a/src/fuse_bmap.cpp b/src/fuse_bmap.cpp new file mode 100644 index 00000000..62359d42 --- /dev/null +++ b/src/fuse_bmap.cpp @@ -0,0 +1,39 @@ +/* + ISC License + + Copyright (c) 2021, Antonio SJ Musumeci + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include "errno.hpp" + +#include + +#include + + +namespace FUSE +{ + int + bmap(const char *fusepath_, + size_t blocksize_, + uint64_t *idx_) + { + (void)fusepath_; + (void)blocksize_; + (void)idx_; + + return -ENOSYS; + } +} diff --git a/src/fuse_bmap.hpp b/src/fuse_bmap.hpp new file mode 100644 index 00000000..35152674 --- /dev/null +++ b/src/fuse_bmap.hpp @@ -0,0 +1,29 @@ +/* + ISC License + + Copyright (c) 2021, Antonio SJ Musumeci + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#pragma once + +#include "fuse.h" + +namespace FUSE +{ + int + bmap(const char *fusepath, + size_t blocksize, + uint64_t *idx); +} diff --git a/src/fuse_destroy.cpp b/src/fuse_destroy.cpp index 90d1737d..d1c5632b 100644 --- a/src/fuse_destroy.cpp +++ b/src/fuse_destroy.cpp @@ -17,7 +17,7 @@ namespace FUSE { void - destroy(void *) + destroy(void) { } diff --git a/src/fuse_destroy.hpp b/src/fuse_destroy.hpp index 31410ee3..cb1cbeda 100644 --- a/src/fuse_destroy.hpp +++ b/src/fuse_destroy.hpp @@ -20,5 +20,5 @@ namespace FUSE { void - destroy(void *); + destroy(void); } diff --git a/src/fuse_lock.cpp b/src/fuse_lock.cpp new file mode 100644 index 00000000..9d09a81f --- /dev/null +++ b/src/fuse_lock.cpp @@ -0,0 +1,33 @@ +/* + ISC License + + Copyright (c) 2021, Antonio SJ Musumeci + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include "errno.hpp" + +#include "fuse.h" + + +namespace FUSE +{ + int + lock(const fuse_file_info_t *ffi, + int cmd, + struct flock *flock) + { + return -ENOSYS; + } +} diff --git a/src/fuse_lock.hpp b/src/fuse_lock.hpp new file mode 100644 index 00000000..f6c08c63 --- /dev/null +++ b/src/fuse_lock.hpp @@ -0,0 +1,29 @@ +/* + ISC License + + Copyright (c) 2021, Antonio SJ Musumeci + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#pragma once + +#include "fuse.h" + +namespace FUSE +{ + int + lock(const fuse_file_info_t *ffi, + int cmd, + struct flock *flock); +} diff --git a/src/fuse_poll.cpp b/src/fuse_poll.cpp new file mode 100644 index 00000000..ad5b0a64 --- /dev/null +++ b/src/fuse_poll.cpp @@ -0,0 +1,37 @@ +/* + ISC License + + Copyright (c) 2021, Antonio SJ Musumeci + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include "errno.hpp" + +#include "fuse.h" + + +namespace FUSE +{ + int + poll(const fuse_file_info_t *ffi_, + fuse_pollhandle_t *ph_, + unsigned *reventsp_) + { + (void)ffi_; + (void)ph_; + (void)reventsp_; + + return -ENOSYS; + } +} diff --git a/src/fuse_read.hpp b/src/fuse_poll.hpp similarity index 66% rename from src/fuse_read.hpp rename to src/fuse_poll.hpp index b15c8d27..37c1be2d 100644 --- a/src/fuse_read.hpp +++ b/src/fuse_poll.hpp @@ -1,5 +1,7 @@ /* - Copyright (c) 2016, Antonio SJ Musumeci + ISC License + + Copyright (c) 2021, Antonio SJ Musumeci Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -22,14 +24,7 @@ namespace FUSE { int - read(const fuse_file_info_t *ffi, - char *buf, - size_t count, - off_t offset); - - int - read_null(const fuse_file_info_t *ffi, - char *buf, - size_t count, - off_t offset); + poll(const fuse_file_info_t *ffi, + fuse_pollhandle_t *ph, + unsigned *reventsp); } diff --git a/src/fuse_read.cpp b/src/fuse_read.cpp deleted file mode 100644 index cc177de4..00000000 --- a/src/fuse_read.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (c) 2016, Antonio SJ Musumeci - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#include "errno.hpp" -#include "fileinfo.hpp" -#include "fs_read.hpp" - -#include "fuse.h" - - -namespace l -{ - static - inline - int - read_regular(const int fd_, - void *buf_, - const size_t count_, - const off_t offset_) - { - int rv; - - rv = fs::pread(fd_,buf_,count_,offset_); - if(rv == -1) - return -errno; - if(rv == 0) - return 0; - - return count_; - } - - static - inline - int - read_direct_io(const int fd_, - void *buf_, - const size_t count_, - const off_t offset_) - { - int rv; - - rv = fs::pread(fd_,buf_,count_,offset_); - if(rv == -1) - return -errno; - - return rv; - } -} - -namespace FUSE -{ - int - read(const fuse_file_info_t *ffi_, - char *buf_, - size_t count_, - off_t offset_) - { - FileInfo *fi; - - fi = reinterpret_cast(ffi_->fh); - - if(ffi_->direct_io) - return l::read_direct_io(fi->fd,buf_,count_,offset_); - return l::read_regular(fi->fd,buf_,count_,offset_); - } - - int - read_null(const fuse_file_info_t *ffi_, - char *buf_, - size_t count_, - off_t offset_) - { - return count_; - } -} diff --git a/src/fuse_read_buf.cpp b/src/fuse_read_buf.cpp index 733940f1..08a781b8 100644 --- a/src/fuse_read_buf.cpp +++ b/src/fuse_read_buf.cpp @@ -67,4 +67,32 @@ namespace FUSE size_, offset_); } + + int + read_buf_null(const fuse_file_info_t *ffi_, + fuse_bufvec **bufp_, + size_t size_, + off_t offset_) + { + void *mem; + struct fuse_bufvec *buf; + + buf = (struct fuse_bufvec*)malloc(sizeof(struct fuse_bufvec)); + if(buf == NULL) + return -ENOMEM; + + mem = (void*)calloc(1,size_); + if(mem == NULL) + { + free(buf); + return -ENOMEM; + } + + *buf = FUSE_BUFVEC_INIT(size_); + buf->buf[0].mem = mem; + + *bufp_ = buf; + + return 0; + } } diff --git a/src/fuse_read_buf.hpp b/src/fuse_read_buf.hpp index f614e916..cbd07cb4 100644 --- a/src/fuse_read_buf.hpp +++ b/src/fuse_read_buf.hpp @@ -28,4 +28,10 @@ namespace FUSE struct fuse_bufvec **buf, size_t size, off_t offset); + + int + read_buf_null(const fuse_file_info_t *ffi, + struct fuse_bufvec **buf, + size_t size, + off_t offset); } diff --git a/src/mergerfs.cpp b/src/mergerfs.cpp index 11c7fc67..56a52e8e 100644 --- a/src/mergerfs.cpp +++ b/src/mergerfs.cpp @@ -21,6 +21,7 @@ #include "strvec.hpp" #include "fuse_access.hpp" +#include "fuse_bmap.hpp" #include "fuse_chmod.hpp" #include "fuse_chown.hpp" #include "fuse_copy_file_range.hpp" @@ -43,12 +44,13 @@ #include "fuse_ioctl.hpp" #include "fuse_link.hpp" #include "fuse_listxattr.hpp" +#include "fuse_lock.hpp" #include "fuse_mkdir.hpp" #include "fuse_mknod.hpp" #include "fuse_open.hpp" #include "fuse_opendir.hpp" +#include "fuse_poll.hpp" #include "fuse_prepare_hide.hpp" -#include "fuse_read.hpp" #include "fuse_read_buf.hpp" #include "fuse_readdir.hpp" #include "fuse_readdir_plus.hpp" @@ -64,7 +66,6 @@ #include "fuse_truncate.hpp" #include "fuse_unlink.hpp" #include "fuse_utimens.hpp" -#include "fuse_write.hpp" #include "fuse_write_buf.hpp" #include "fuse.h" @@ -83,7 +84,7 @@ namespace l const bool nullrw_) { ops_.access = FUSE::access; - ops_.bmap = NULL; + ops_.bmap = FUSE::bmap; ops_.chmod = FUSE::chmod; ops_.chown = FUSE::chown; ops_.copy_file_range = FUSE::copy_file_range; @@ -93,7 +94,7 @@ namespace l ops_.fchmod = FUSE::fchmod; ops_.fchown = FUSE::fchown; ops_.fgetattr = FUSE::fgetattr; - ops_.flock = NULL; // FUSE::flock; + ops_.flock = FUSE::flock; ops_.flush = FUSE::flush; ops_.free_hide = FUSE::free_hide; ops_.fsync = FUSE::fsync; @@ -106,15 +107,14 @@ namespace l ops_.ioctl = FUSE::ioctl; ops_.link = FUSE::link; ops_.listxattr = FUSE::listxattr; - ops_.lock = NULL; + ops_.lock = FUSE::lock; ops_.mkdir = FUSE::mkdir; ops_.mknod = FUSE::mknod; ops_.open = FUSE::open; ops_.opendir = FUSE::opendir; - ops_.poll = NULL; + ops_.poll = FUSE::poll;; ops_.prepare_hide = FUSE::prepare_hide; - ops_.read = (nullrw_ ? FUSE::read_null : FUSE::read); - ops_.read_buf = (nullrw_ ? NULL : FUSE::read_buf); + ops_.read_buf = (nullrw_ ? FUSE::read_buf_null : FUSE::read_buf); ops_.readdir = FUSE::readdir; ops_.readdir_plus = FUSE::readdir_plus; ops_.readlink = FUSE::readlink; @@ -128,9 +128,7 @@ namespace l ops_.symlink = FUSE::symlink; ops_.truncate = FUSE::truncate; ops_.unlink = FUSE::unlink; - ops_.utime = NULL; /* deprecated; use utimens() */ ops_.utimens = FUSE::utimens; - ops_.write = (nullrw_ ? FUSE::write_null : FUSE::write); ops_.write_buf = (nullrw_ ? FUSE::write_buf_null : FUSE::write_buf); return; @@ -173,8 +171,7 @@ namespace l return fuse_main(args.argc, args.argv, - &ops, - NULL); + &ops); } }