diff options
author | syl <syl@cvs.openbsd.org> | 2013-06-14 20:49:07 +0000 |
---|---|---|
committer | syl <syl@cvs.openbsd.org> | 2013-06-14 20:49:07 +0000 |
commit | 940dd845d50e19c3b8045b4bde0ca5f6f94e6437 (patch) | |
tree | fc1a01a881c0c0167d89bb16feb332993983597b /lib | |
parent | 2a452811a20b55d5fb8b2b4ad59dd71e89c2e16b (diff) |
Add support for fuse_get_context(3) needed by ntfs-3g.
OK pirofti@ and beck@ "assuming I am getting to setting
the initial pid/gid/uid values correctly soon".
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libfuse/Makefile | 3 | ||||
-rw-r--r-- | lib/libfuse/fuse.3 | 11 | ||||
-rw-r--r-- | lib/libfuse/fuse.c | 19 | ||||
-rw-r--r-- | lib/libfuse/fuse.h | 12 | ||||
-rw-r--r-- | lib/libfuse/fuse_private.h | 3 |
5 files changed, 43 insertions, 5 deletions
diff --git a/lib/libfuse/Makefile b/lib/libfuse/Makefile index 97e90bea3d0..1b196fe3fdc 100644 --- a/lib/libfuse/Makefile +++ b/lib/libfuse/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.3 2013/06/14 20:40:41 syl Exp $ +# $OpenBSD: Makefile,v 1.4 2013/06/14 20:49:06 syl Exp $ LIB= fuse MAN= fuse.3 @@ -11,6 +11,7 @@ MLINKS= fuse.3 fuse_version.3 \ fuse.3 fuse_remove_signal_handlers.3 \ fuse.3 fuse_set_signal_handlers.3 \ fuse.3 fuse_get_session.3 \ + fuse.3 fuse_get_context.3 \ fuse.3 fuse_is_lib_option.3 \ fuse.3 fuse_loop.3 \ fuse.3 fuse_loop_mt.3 \ diff --git a/lib/libfuse/fuse.3 b/lib/libfuse/fuse.3 index e27da4a44c0..48816216776 100644 --- a/lib/libfuse/fuse.3 +++ b/lib/libfuse/fuse.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: fuse.3,v 1.6 2013/06/14 20:40:41 syl Exp $ +.\" $OpenBSD: fuse.3,v 1.7 2013/06/14 20:49:06 syl Exp $ .\" .\" Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> .\" @@ -27,6 +27,7 @@ .Nm fuse_remove_signal_handlers , .Nm fuse_set_signal_handlers , .Nm fuse_get_session , +.Nm fuse_get_context , .Nm fuse_is_lib_option , .Nm fuse_loop , .Nm fuse_loop_mt , @@ -55,6 +56,8 @@ .Fn fuse_set_signal_handlers "struct fuse_session *se" .Ft struct fuse_session * .Fn fuse_get_session "struct fuse *f" +.Ft struct fuse_context * +.Fn fuse_get_context "void" .Ft int .Fn fuse_is_lib_option "const char *opt" .Ft int @@ -121,6 +124,12 @@ returns a pointer to the structure contained in a .Fa struct fuse . .Pp +.Fn fuse_get_context +returns a pointer to the structure +.Fa fuse_context . +The returned fuse_context is only available during the lifetime of a fuse +operation. +.Pp .Fn fuse_is_lib_option checks if the string .Fa opt diff --git a/lib/libfuse/fuse.c b/lib/libfuse/fuse.c index 14d74ab1d9a..c2aa93b57fb 100644 --- a/lib/libfuse/fuse.c +++ b/lib/libfuse/fuse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse.c,v 1.5 2013/06/14 20:40:41 syl Exp $ */ +/* $OpenBSD: fuse.c,v 1.6 2013/06/14 20:49:06 syl Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -28,11 +28,13 @@ #include "debug.h" static struct fuse_session *sigse; +static struct fuse_context *ictx = NULL; int fuse_loop(struct fuse *fuse) { struct fusebuf fbuf; + struct fuse_context ctx; struct kevent ev; int error = 0; size_t len = 0; @@ -67,13 +69,22 @@ fuse_loop(struct fuse *fuse) } } + ctx.fuse = fuse; + ctx.uid = fuse->conf.uid; + ctx.gid = fuse->conf.gid; + ctx.pid = fuse->conf.pid; + ctx.umask = fuse->conf.umask; + ictx = &ctx; + ret = ifuse_exec_opcode(fuse, &fbuf); if (ret) { + ictx = NULL; return (ret); } len = sizeof(fbuf.fb_hdr) + fbuf.fb_len; ret = write(fuse->fc->fd, &fbuf, len); + ictx = NULL; if (ret != (int)len) { errno = EINVAL; @@ -307,6 +318,12 @@ fuse_parse_cmdline(struct fuse_args *args, char **mp, int *mt, unused int *fg) return (0); } +struct fuse_context * +fuse_get_context(void) +{ + return (ictx); +} + int fuse_version(void) { diff --git a/lib/libfuse/fuse.h b/lib/libfuse/fuse.h index c68cf10d34e..b4b83c2c96a 100644 --- a/lib/libfuse/fuse.h +++ b/lib/libfuse/fuse.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse.h,v 1.4 2013/06/14 20:40:41 syl Exp $ */ +/* $OpenBSD: fuse.h,v 1.5 2013/06/14 20:49:06 syl Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -54,6 +54,15 @@ struct fuse_conn_info { uint32_t reserved[27]; }; +struct fuse_context { + struct fuse * fuse; + uid_t uid; + gid_t gid; + pid_t pid; + void *private_data; + mode_t umask; +}; + typedef ino_t fuse_ino_t; typedef int (*fuse_fill_dir_t)(void *, const char *, const struct stat *, off_t); @@ -140,6 +149,7 @@ struct fuse_chan *fuse_mount(const char *, struct fuse_args *); void fuse_remove_signal_handlers(struct fuse_session *); int fuse_set_signal_handlers(struct fuse_session *); struct fuse_session *fuse_get_session(struct fuse *); +struct fuse_context *fuse_get_context(void); int fuse_is_lib_option(const char *); int fuse_loop(struct fuse *); int fuse_loop_mt(struct fuse *); diff --git a/lib/libfuse/fuse_private.h b/lib/libfuse/fuse_private.h index f0a24b35182..a455f48e577 100644 --- a/lib/libfuse/fuse_private.h +++ b/lib/libfuse/fuse_private.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse_private.h,v 1.3 2013/06/12 22:36:06 tedu Exp $ */ +/* $OpenBSD: fuse_private.h,v 1.4 2013/06/14 20:49:06 syl Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -63,6 +63,7 @@ struct fuse_chan { struct fuse_config { uid_t uid; gid_t gid; + pid_t pid; mode_t umask; int set_mode; int set_uid; |