summaryrefslogtreecommitdiff
path: root/lib/librefuse
diff options
context:
space:
mode:
authorpooka <pooka@NetBSD.org>2007-11-30 19:02:28 +0000
committerpooka <pooka@NetBSD.org>2007-11-30 19:02:28 +0000
commit21913eabe521da35940dfec3cf10d729a9f91c59 (patch)
treec91670569f537efa31edb3a5e27f80794109b6d0 /lib/librefuse
parentb3dec5572729a5f5c4b5c57ec857af1b5231fd24 (diff)
Rototill.
Ok, ok, a few more words about it: stop holding puffs_cc as a holy value and passing it around to almost every possible place (popquiz: which kernel variable does this remind you of?). Instead, pass the natural choice, puffs_usermount, and fetch puffs_cc via puffs_cc_getcc() only in routines which actually need it. This not only simplifies code, but (thanks to the introduction of puffs_cc_getcc()) enables constructs which weren't previously sanely possible, say layering as a curious example. There's still a little to do on this front, but this was the major fs interface blast.
Diffstat (limited to 'lib/librefuse')
-rw-r--r--lib/librefuse/refuse.c74
1 files changed, 29 insertions, 45 deletions
diff --git a/lib/librefuse/refuse.c b/lib/librefuse/refuse.c
index 294f10e2d60..457686ebb90 100644
--- a/lib/librefuse/refuse.c
+++ b/lib/librefuse/refuse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: refuse.c,v 1.84 2007/11/27 11:31:20 pooka Exp $ */
+/* $NetBSD: refuse.c,v 1.85 2007/11/30 19:02:29 pooka Exp $ */
/*
* Copyright © 2007 Alistair Crooks. All rights reserved.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: refuse.c,v 1.84 2007/11/27 11:31:20 pooka Exp $");
+__RCSID("$NetBSD: refuse.c,v 1.85 2007/11/30 19:02:29 pooka Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -252,8 +252,9 @@ set_fuse_context_uid_gid(const struct puffs_cred *cred)
/* set the pid of the calling process in the current fuse context */
static void
-set_fuse_context_pid(struct puffs_cc *pcc)
+set_fuse_context_pid(struct puffs_usermount *pu)
{
+ struct puffs_cc *pcc = puffs_cc_getcc(pu);
struct fuse_context *fusectx;
fusectx = fuse_get_context();
@@ -573,10 +574,9 @@ fuse_newnode(struct puffs_usermount *pu, const char *path,
/* lookup the path */
/* ARGSUSED1 */
static int
-puffs_fuse_node_lookup(struct puffs_cc *pcc, void *opc,
+puffs_fuse_node_lookup(struct puffs_usermount *pu, void *opc,
struct puffs_newinfo *pni, const struct puffs_cn *pcn)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct puffs_node *pn_res;
struct stat st;
struct fuse *fuse;
@@ -614,10 +614,9 @@ puffs_fuse_node_lookup(struct puffs_cc *pcc, void *opc,
/* get attributes for the path name */
/* ARGSUSED3 */
static int
-puffs_fuse_node_getattr(struct puffs_cc *pcc, void *opc, struct vattr *va,
+puffs_fuse_node_getattr(struct puffs_usermount *pu, void *opc, struct vattr *va,
const struct puffs_cred *pcr)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct puffs_node *pn = opc;
struct fuse *fuse;
const char *path = PNPATH(pn);
@@ -632,10 +631,9 @@ puffs_fuse_node_getattr(struct puffs_cc *pcc, void *opc, struct vattr *va,
/* read the contents of the symbolic link */
/* ARGSUSED2 */
static int
-puffs_fuse_node_readlink(struct puffs_cc *pcc, void *opc,
+puffs_fuse_node_readlink(struct puffs_usermount *pu, void *opc,
const struct puffs_cred *cred, char *linkname, size_t *linklen)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct puffs_node *pn = opc;
struct fuse *fuse;
const char *path = PNPATH(pn), *p;
@@ -665,11 +663,10 @@ puffs_fuse_node_readlink(struct puffs_cc *pcc, void *opc,
/* make the special node */
/* ARGSUSED1 */
static int
-puffs_fuse_node_mknod(struct puffs_cc *pcc, void *opc,
+puffs_fuse_node_mknod(struct puffs_usermount *pu, void *opc,
struct puffs_newinfo *pni, const struct puffs_cn *pcn,
const struct vattr *va)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct fuse *fuse;
mode_t mode;
const char *path = PCNPATH(pcn);
@@ -696,11 +693,10 @@ puffs_fuse_node_mknod(struct puffs_cc *pcc, void *opc,
/* make a directory */
/* ARGSUSED1 */
static int
-puffs_fuse_node_mkdir(struct puffs_cc *pcc, void *opc,
+puffs_fuse_node_mkdir(struct puffs_usermount *pu, void *opc,
struct puffs_newinfo *pni, const struct puffs_cn *pcn,
const struct vattr *va)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct fuse *fuse;
mode_t mode = va->va_mode;
const char *path = PCNPATH(pcn);
@@ -733,11 +729,10 @@ puffs_fuse_node_mkdir(struct puffs_cc *pcc, void *opc,
*/
/*ARGSUSED1*/
static int
-puffs_fuse_node_create(struct puffs_cc *pcc, void *opc,
+puffs_fuse_node_create(struct puffs_usermount *pu, void *opc,
struct puffs_newinfo *pni, const struct puffs_cn *pcn,
const struct vattr *va)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct fuse *fuse;
struct fuse_file_info fi;
struct puffs_node *pn;
@@ -781,10 +776,9 @@ puffs_fuse_node_create(struct puffs_cc *pcc, void *opc,
/* remove the directory entry */
/* ARGSUSED1 */
static int
-puffs_fuse_node_remove(struct puffs_cc *pcc, void *opc, void *targ,
+puffs_fuse_node_remove(struct puffs_usermount *pu, void *opc, void *targ,
const struct puffs_cn *pcn)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct puffs_node *pn_targ = targ;
struct fuse *fuse;
const char *path = PNPATH(pn_targ);
@@ -807,10 +801,9 @@ puffs_fuse_node_remove(struct puffs_cc *pcc, void *opc, void *targ,
/* remove the directory */
/* ARGSUSED1 */
static int
-puffs_fuse_node_rmdir(struct puffs_cc *pcc, void *opc, void *targ,
+puffs_fuse_node_rmdir(struct puffs_usermount *pu, void *opc, void *targ,
const struct puffs_cn *pcn)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct puffs_node *pn_targ = targ;
struct fuse *fuse;
const char *path = PNPATH(pn_targ);
@@ -833,11 +826,10 @@ puffs_fuse_node_rmdir(struct puffs_cc *pcc, void *opc, void *targ,
/* create a symbolic link */
/* ARGSUSED1 */
static int
-puffs_fuse_node_symlink(struct puffs_cc *pcc, void *opc,
+puffs_fuse_node_symlink(struct puffs_usermount *pu, void *opc,
struct puffs_newinfo *pni, const struct puffs_cn *pcn_src,
const struct vattr *va, const char *link_target)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct fuse *fuse;
const char *path = PCNPATH(pcn_src);
int ret;
@@ -863,11 +855,10 @@ puffs_fuse_node_symlink(struct puffs_cc *pcc, void *opc,
/* rename a directory entry */
/* ARGSUSED1 */
static int
-puffs_fuse_node_rename(struct puffs_cc *pcc, void *opc, void *src,
+puffs_fuse_node_rename(struct puffs_usermount *pu, void *opc, void *src,
const struct puffs_cn *pcn_src, void *targ_dir, void *targ,
const struct puffs_cn *pcn_targ)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct fuse *fuse;
const char *path_src = PCNPATH(pcn_src);
const char *path_dest = PCNPATH(pcn_targ);
@@ -892,10 +883,9 @@ puffs_fuse_node_rename(struct puffs_cc *pcc, void *opc, void *src,
/* create a link in the file system */
/* ARGSUSED1 */
static int
-puffs_fuse_node_link(struct puffs_cc *pcc, void *opc, void *targ,
+puffs_fuse_node_link(struct puffs_usermount *pu, void *opc, void *targ,
const struct puffs_cn *pcn)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct puffs_node *pn = targ;
struct fuse *fuse;
int ret;
@@ -921,10 +911,9 @@ puffs_fuse_node_link(struct puffs_cc *pcc, void *opc, void *targ,
*/
/* ARGSUSED3 */
static int
-puffs_fuse_node_setattr(struct puffs_cc *pcc, void *opc,
+puffs_fuse_node_setattr(struct puffs_usermount *pu, void *opc,
const struct vattr *va, const struct puffs_cred *pcr)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct puffs_node *pn = opc;
struct fuse *fuse;
const char *path = PNPATH(pn);
@@ -938,10 +927,9 @@ puffs_fuse_node_setattr(struct puffs_cc *pcc, void *opc,
/* ARGSUSED2 */
static int
-puffs_fuse_node_open(struct puffs_cc *pcc, void *opc, int mode,
+puffs_fuse_node_open(struct puffs_usermount *pu, void *opc, int mode,
const struct puffs_cred *cred)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct puffs_node *pn = opc;
struct refusenode *rn = pn->pn_data;
struct fuse_file_info *fi = &rn->file_info;
@@ -977,10 +965,9 @@ puffs_fuse_node_open(struct puffs_cc *pcc, void *opc, int mode,
/* ARGSUSED2 */
static int
-puffs_fuse_node_close(struct puffs_cc *pcc, void *opc, int fflag,
+puffs_fuse_node_close(struct puffs_usermount *pu, void *opc, int fflag,
const struct puffs_cred *pcr)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct puffs_node *pn = opc;
struct refusenode *rn = pn->pn_data;
struct fuse *fuse;
@@ -1012,11 +999,10 @@ puffs_fuse_node_close(struct puffs_cc *pcc, void *opc, int fflag,
/* read some more from the file */
/* ARGSUSED5 */
static int
-puffs_fuse_node_read(struct puffs_cc *pcc, void *opc, uint8_t *buf,
+puffs_fuse_node_read(struct puffs_usermount *pu, void *opc, uint8_t *buf,
off_t offset, size_t *resid, const struct puffs_cred *pcr,
int ioflag)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct puffs_node *pn = opc;
struct refusenode *rn = pn->pn_data;
struct fuse *fuse;
@@ -1053,11 +1039,10 @@ puffs_fuse_node_read(struct puffs_cc *pcc, void *opc, uint8_t *buf,
/* write to the file */
/* ARGSUSED0 */
static int
-puffs_fuse_node_write(struct puffs_cc *pcc, void *opc, uint8_t *buf,
+puffs_fuse_node_write(struct puffs_usermount *pu, void *opc, uint8_t *buf,
off_t offset, size_t *resid, const struct puffs_cred *pcr,
int ioflag)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct puffs_node *pn = opc;
struct refusenode *rn = pn->pn_data;
struct fuse *fuse;
@@ -1090,11 +1075,11 @@ puffs_fuse_node_write(struct puffs_cc *pcc, void *opc, uint8_t *buf,
/* ARGSUSED3 */
static int
-puffs_fuse_node_readdir(struct puffs_cc *pcc, void *opc, struct dirent *dent,
- off_t *readoff, size_t *reslen, const struct puffs_cred *pcr,
- int *eofflag, off_t *cookies, size_t *ncookies)
+puffs_fuse_node_readdir(struct puffs_usermount *pu, void *opc,
+ struct dirent *dent, off_t *readoff, size_t *reslen,
+ const struct puffs_cred *pcr, int *eofflag,
+ off_t *cookies, size_t *ncookies)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct puffs_node *pn = opc;
struct refusenode *rn = pn->pn_data;
struct puffs_fuse_dirh *dirh;
@@ -1153,7 +1138,7 @@ puffs_fuse_node_readdir(struct puffs_cc *pcc, void *opc, struct dirent *dent,
/* ARGSUSED */
static int
-puffs_fuse_node_reclaim(struct puffs_cc *pcc, void *opc)
+puffs_fuse_node_reclaim(struct puffs_usermount *pu, void *opc)
{
struct puffs_node *pn = opc;
@@ -1163,9 +1148,8 @@ puffs_fuse_node_reclaim(struct puffs_cc *pcc, void *opc)
/* ARGSUSED1 */
static int
-puffs_fuse_fs_unmount(struct puffs_cc *pcc, int flags)
+puffs_fuse_fs_unmount(struct puffs_usermount *pu, int flags)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct fuse *fuse;
fuse = puffs_getspecific(pu);
@@ -1178,7 +1162,7 @@ puffs_fuse_fs_unmount(struct puffs_cc *pcc, int flags)
/* ARGSUSED0 */
static int
-puffs_fuse_fs_sync(struct puffs_cc *pcc, int flags,
+puffs_fuse_fs_sync(struct puffs_usermount *pu, int flags,
const struct puffs_cred *cr)
{
set_fuse_context_uid_gid(cr);
@@ -1187,9 +1171,8 @@ puffs_fuse_fs_sync(struct puffs_cc *pcc, int flags,
/* ARGSUSED2 */
static int
-puffs_fuse_fs_statvfs(struct puffs_cc *pcc, struct statvfs *svfsb)
+puffs_fuse_fs_statvfs(struct puffs_usermount *pu, struct statvfs *svfsb)
{
- struct puffs_usermount *pu = puffs_cc_getusermount(pcc);
struct fuse *fuse;
int ret;
@@ -1331,6 +1314,7 @@ fuse_new(struct fuse_chan *fc, struct fuse_args *args,
pu = puffs_init(pops, _PATH_PUFFS, name, fuse,
PUFFS_FLAG_BUILDPATH
| PUFFS_FLAG_HASHPATH
+ | PUFFS_FLAG_OPDUMP
| PUFFS_KFLAG_NOCACHE);
if (pu == NULL) {
err(EXIT_FAILURE, "puffs_init");