Turn fuse_operations.nopath_flag into fuse_config.nullpath_ok
authorNikolaus Rath <Nikolaus@rath.org>
Thu, 20 Oct 2016 22:45:32 +0000 (15:45 -0700)
committerNikolaus Rath <Nikolaus@rath.org>
Thu, 20 Oct 2016 22:45:32 +0000 (15:45 -0700)
Modifying struct fuse_config in the init() handler is the canonical way
to adjust file-system implementation specific settings. There is no need
to have flags in struct fuse_operations.

ChangeLog.rst
example/passthrough_fh.c
include/fuse.h
lib/fuse.c
lib/modules/iconv.c
lib/modules/subdir.c

index 7d32ba6e8a5ec70dd6f788009ad23c696604c9cd..e614e6b40c360d45c99837efce40f1fab5e8c55c 100644 (file)
@@ -5,6 +5,10 @@ Unreleased Changes
   fuse_config pointer that can be used to adjust high-level API
   specific configuration options.
 
+* The `nopath_flag` field of struct fuse_operations has been
+  removed. Instead, a new `nullpath_ok` flag can now be set
+  in struct fuse_config.
+
 * File systems that use the low-level API and support lookup requests
   for '.' and '..' should continue make sure to set the
   FUSE_CAP_EXPORT_SUPPORT bit in fuse_conn_info->want.
index f74940d93d513d56d480f6335085e5d771f40e63..781f717b61acc038bbb0aaa0604a088701cffd3d 100644 (file)
@@ -57,6 +57,7 @@ static void *xmp_init(struct fuse_conn_info *conn,
 {
        (void) conn;
        cfg->use_ino = 1;
+       cfg->nullpath_ok = 1;
        return NULL;
 }
 
index 3c13c14a46cd2474cb12a5c09f61872f68363890..e8ff9361ec61bcba03003b553405ecc58747e2e2 100644 (file)
@@ -243,6 +243,19 @@ struct fuse_config {
        int ac_attr_timeout_set;
        double ac_attr_timeout;
 
+       /**
+        * If this option is given the file-system handlers for the
+        * following operations will not receive path information:
+        * read, write, flush, release, fsync, readdir, releasedir,
+        * fsyncdir, lock, ioctl and poll.
+        *
+        * For the truncate, getattr, chmod, chown and utimens
+        * operations the path will be provided only if the file is
+        * not currently open (i.e., when the struct fuse_file_info
+        * argument is NULL).
+        */
+       int nullpath_ok;
+
        /**
         * The remaining options are used by libfuse internally and
         * should not be touched.
@@ -250,7 +263,6 @@ struct fuse_config {
        int show_help;
        char *modules;
        int debug;
-       int nopath;
 };
 
 
@@ -277,30 +289,6 @@ struct fuse_config {
  * is also a snapshot of the relevant wiki pages in the doc/ folder.
  */
 struct fuse_operations {
-       /**
-        * Flag indicating that the path need not be calculated for
-        * the following operations:
-        *
-        * read, write, flush, release, fsync, readdir, releasedir,
-        * fsyncdir, lock, ioctl and poll
-        *
-        * For the following operations, the path will not be
-        * calculated only if the file is currently open (i.e., the
-        * struct fuse_file_info argument is non-NULL):
-        *
-        * truncate, getattr, chmod, chown, utimens
-        *
-        * If this flag is set then the path will not be calculaged even if the
-        * file wasn't unlinked.  However the path can still be non-NULL if it
-        * needs to be calculated for some other reason.
-        */
-       unsigned int flag_nopath:1;
-
-       /**
-        * Reserved flags, don't set
-        */
-       unsigned int flag_reserved:31;
-
        /** Get file attributes.
         *
         * Similar to stat().  The 'st_dev' and 'st_blksize' fields are
index 1595cc86f427e7e07ea92f3060a6742ff0851ce0..df6e3a087b9d9e6bef61d40a758dbe70e601942d 100644 (file)
@@ -1193,7 +1193,7 @@ static int get_path_nullok(struct fuse *f, fuse_ino_t nodeid, char **path)
 {
        int err = 0;
 
-       if (f->conf.nopath) {
+       if (f->conf.nullpath_ok) {
                *path = NULL;
        } else {
                err = get_path_common(f, nodeid, NULL, path, NULL);
@@ -2958,7 +2958,7 @@ static void fuse_do_release(struct fuse *f, fuse_ino_t ino, const char *path,
        if(unlink_hidden) {
                if (path) {
                        fuse_fs_unlink(f->fs, path);
-               } else if (f->conf.nopath) {
+               } else if (f->conf.nullpath_ok) {
                        char *unlinkpath;
 
                        if (get_path(f, ino, &unlinkpath) == 0)
@@ -4480,7 +4480,6 @@ static int fuse_push_module(struct fuse *f, const char *module,
        }
        newfs->m = m;
        f->fs = newfs;
-       f->conf.nopath = newfs->op.flag_nopath && f->conf.nopath;
        return 0;
 }
 
@@ -4596,7 +4595,6 @@ struct fuse *fuse_new(struct fuse_args *args,
                goto out_delete_context_key;
 
        f->fs = fs;
-       f->conf.nopath = fs->op.flag_nopath;
 
        /* Oh f**k, this is ugly! */
        if (!fs->op.lock) {
@@ -4650,7 +4648,7 @@ struct fuse *fuse_new(struct fuse_args *args,
                goto out_free_fs;
 
        if (f->conf.debug) {
-               fprintf(stderr, "nopath: %i\n", f->conf.nopath);
+               fprintf(stderr, "nullpath_ok: %i\n", f->conf.nullpath_ok);
        }
 
        /* Trace topmost layer by default */
index b0453be4cdfbbf92448d7e6740bc7dd39fb431b4..5d1e9591734b0142047b9d601704b16a72380759 100644 (file)
@@ -561,6 +561,8 @@ static void *iconv_init(struct fuse_conn_info *conn,
 {
        struct iconv *ic = iconv_get();
        fuse_fs_init(ic->next, conn, cfg);
+       /* Don't touch cfg->nullpath_ok, we can work with
+          either */
        return ic;
 }
 
@@ -612,8 +614,6 @@ static const struct fuse_operations iconv_oper = {
        .lock           = iconv_lock,
        .flock          = iconv_flock,
        .bmap           = iconv_bmap,
-
-       .flag_nopath = 1,
 };
 
 static const struct fuse_opt iconv_opts[] = {
index 708edf3ad1466fa164a74ae6861bceec97331f92..9478e4e479e670e07e3ab9a76e90b9582f747da0 100644 (file)
@@ -547,6 +547,8 @@ static void *subdir_init(struct fuse_conn_info *conn,
 {
        struct subdir *d = subdir_get();
        fuse_fs_init(d->next, conn, cfg);
+       /* Don't touch cfg->nullpath_ok, we can work with
+          either */
        return d;
 }
 
@@ -594,8 +596,6 @@ static const struct fuse_operations subdir_oper = {
        .lock           = subdir_lock,
        .flock          = subdir_flock,
        .bmap           = subdir_bmap,
-
-       .flag_nopath = 1,
 };
 
 static const struct fuse_opt subdir_opts[] = {