summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorhelg <helg@cvs.openbsd.org>2018-05-22 12:52:15 +0000
committerhelg <helg@cvs.openbsd.org>2018-05-22 12:52:15 +0000
commitecdc03979598bf9cb38b3576ff9f7ce6812c4a23 (patch)
tree2780f4e9142d1a6461663b81dd706b878230c86a /lib
parent31e98e3aebe9952cb5ce409c9760d2898dbc2f56 (diff)
Implement support for libfuse use_ino option. This returns the file
system's ino for VOP_GETATTR(9) and VOP_READDIR(9) rather than the internally generated fuse ino. ok mpi@
Diffstat (limited to 'lib')
-rw-r--r--lib/libfuse/fuse.c4
-rw-r--r--lib/libfuse/fuse_ops.c38
-rw-r--r--lib/libfuse/fuse_private.h3
3 files changed, 26 insertions, 19 deletions
diff --git a/lib/libfuse/fuse.c b/lib/libfuse/fuse.c
index 065c38c0cb7..d0551a84f0d 100644
--- a/lib/libfuse/fuse.c
+++ b/lib/libfuse/fuse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fuse.c,v 1.44 2018/05/15 11:57:32 helg Exp $ */
+/* $OpenBSD: fuse.c,v 1.45 2018/05/22 12:52:14 helg Exp $ */
/*
* Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
@@ -86,7 +86,7 @@ static struct fuse_opt fuse_lib_opts[] = {
FUSE_OPT_KEY("subtype=", KEY_STUB),
FUSE_LIB_OPT("uid=", set_uid),
FUSE_LIB_OPT("uid=%u", uid),
- FUSE_OPT_KEY("use_ino", KEY_STUB),
+ FUSE_LIB_OPT("use_ino", use_ino),
FUSE_OPT_KEY("dmask=%o", KEY_STUB),
FUSE_OPT_KEY("fmask=%o", KEY_STUB),
FUSE_LIB_OPT("umask=", set_mode),
diff --git a/lib/libfuse/fuse_ops.c b/lib/libfuse/fuse_ops.c
index 55097112291..609ef7569c8 100644
--- a/lib/libfuse/fuse_ops.c
+++ b/lib/libfuse/fuse_ops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fuse_ops.c,v 1.32 2018/05/21 11:47:46 helg Exp $ */
+/* $OpenBSD: fuse_ops.c,v 1.33 2018/05/22 12:52:14 helg Exp $ */
/*
* Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
@@ -44,7 +44,8 @@ update_attr(struct fuse *f, struct stat *attr, const char *realname,
if (attr->st_blocks == 0)
attr->st_blocks = 4;
- attr->st_ino = vn->ino;
+ if (!f->conf.use_ino)
+ attr->st_ino = vn->ino;
if (f->conf.set_mode)
attr->st_mode = (attr->st_mode & S_IFMT) | (0777 & ~f->conf.umask);
@@ -248,20 +249,24 @@ ifuse_fill_readdir(void *dh, const char *name, const struct stat *stbuf,
dir = (struct dirent *) &fbuf->fb_dat[fbuf->fb_len];
- /*
- * This always behaves as if readdir_ino option is set so getcwd(3)
- * works.
- */
- v = get_vn_by_name_and_parent(f, (uint8_t *)name, fbuf->fb_ino);
- if (v == NULL) {
- if (strcmp(name, ".") == 0)
- dir->d_fileno = fbuf->fb_ino;
- else
- dir->d_fileno = 0xffffffff;
- } else
- dir->d_fileno = v->ino;
+ if (stbuf != NULL && f->conf.use_ino)
+ dir->d_fileno = stbuf->st_ino;
+ else {
+ /*
+ * This always behaves as if readdir_ino option is set so
+ * getcwd(3) works.
+ */
+ v = get_vn_by_name_and_parent(f, (uint8_t *)name, fbuf->fb_ino);
+ if (v == NULL) {
+ if (strcmp(name, ".") == 0)
+ dir->d_fileno = fbuf->fb_ino;
+ else
+ dir->d_fileno = 0xffffffff;
+ } else
+ dir->d_fileno = v->ino;
+ }
- if (stbuf)
+ if (stbuf != NULL)
dir->d_type = IFTODT(stbuf->st_mode);
else
dir->d_type = DT_UNKNOWN;
@@ -501,6 +506,7 @@ ifuse_ops_lookup(struct fuse *f, struct fusebuf *fbuf)
}
fbuf->fb_err = update_attr(f, &fbuf->fb_attr, realname, vn);
+ fbuf->fb_ino = vn->ino;
free(fbuf->fb_dat);
free(realname);
@@ -1034,7 +1040,7 @@ ifuse_ops_mknod(struct fuse *f, struct fusebuf *fbuf)
if (!fbuf->fb_err) {
fbuf->fb_err = update_attr(f, &fbuf->fb_attr, realname, vn);
fbuf->fb_io_mode = fbuf->fb_attr.st_mode;
- fbuf->fb_ino = fbuf->fb_attr.st_ino;
+ fbuf->fb_ino = vn->ino;
}
free(realname);
diff --git a/lib/libfuse/fuse_private.h b/lib/libfuse/fuse_private.h
index 7a5a3045893..7dc01b28394 100644
--- a/lib/libfuse/fuse_private.h
+++ b/lib/libfuse/fuse_private.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fuse_private.h,v 1.18 2018/05/16 13:09:17 helg Exp $ */
+/* $OpenBSD: fuse_private.h,v 1.19 2018/05/22 12:52:14 helg Exp $ */
/*
* Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
@@ -80,6 +80,7 @@ struct fuse_config {
int set_mode;
int set_uid;
int set_gid;
+ int use_ino;
};
struct fuse_core_opts {