Use new puffs features to provide correct caller info instead of

sometimes returning stale data.
This commit is contained in:
pooka 2007-10-21 14:36:35 +00:00
parent be98071c8c
commit a3e1355fe5
1 changed files with 24 additions and 22 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: refuse.c,v 1.75 2007/08/25 12:03:59 pooka Exp $ */
/* $NetBSD: refuse.c,v 1.76 2007/10/21 14:36:35 pooka Exp $ */
/*
* Copyright © 2007 Alistair Crooks. All rights reserved.
@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: refuse.c,v 1.75 2007/08/25 12:03:59 pooka Exp $");
__RCSID("$NetBSD: refuse.c,v 1.76 2007/10/21 14:36:35 pooka Exp $");
#endif /* !lint */
#include <assert.h>
@ -241,12 +241,12 @@ 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(const struct puffs_cid *pcid)
set_fuse_context_pid(struct puffs_cc *pcc)
{
struct fuse_context *fusectx;
fusectx = fuse_get_context();
puffs_cid_getpid(pcid, &fusectx->pid);
puffs_cc_getcaller(pcc, &fusectx->pid, NULL);
}
/***************** end of pthread context routines ************************/
@ -574,6 +574,7 @@ puffs_fuse_node_lookup(struct puffs_cc *pcc, void *opc,
fuse = puffs_getspecific(pu);
set_fuse_context_uid_gid(pcn->pcn_cred);
set_fuse_context_pid(pcc);
ret = fuse->op.getattr(path, &st);
@ -613,7 +614,7 @@ puffs_fuse_node_getattr(struct puffs_cc *pcc, void *opc, struct vattr *va,
fuse = puffs_getspecific(pu);
set_fuse_context_uid_gid(pcr);
set_fuse_context_pid(pcid);
set_fuse_context_pid(pcc);
return fuse_getattr(fuse, pn, path, va);
}
@ -636,6 +637,7 @@ puffs_fuse_node_readlink(struct puffs_cc *pcc, void *opc,
}
set_fuse_context_uid_gid(cred);
set_fuse_context_pid(pcc);
/* wrap up return code */
ret = (*fuse->op.readlink)(path, linkname, *linklen);
@ -670,7 +672,7 @@ puffs_fuse_node_mknod(struct puffs_cc *pcc, void *opc,
}
set_fuse_context_uid_gid(pcn->pcn_cred);
set_fuse_context_pid(pcn->pcn_cid);
set_fuse_context_pid(pcc);
/* wrap up return code */
mode = puffs_addvtype2mode(va->va_mode, va->va_type);
@ -699,7 +701,7 @@ puffs_fuse_node_mkdir(struct puffs_cc *pcc, void *opc,
fuse = puffs_getspecific(pu);
set_fuse_context_uid_gid(pcn->pcn_cred);
set_fuse_context_pid(pcn->pcn_cid);
set_fuse_context_pid(pcc);
if (fuse->op.mkdir == NULL) {
return ENOSYS;
@ -739,7 +741,7 @@ puffs_fuse_node_create(struct puffs_cc *pcc, void *opc,
fuse = puffs_getspecific(pu);
set_fuse_context_uid_gid(pcn->pcn_cred);
set_fuse_context_pid(pcn->pcn_cid);
set_fuse_context_pid(pcc);
created = 0;
if (fuse->op.create) {
@ -785,7 +787,7 @@ puffs_fuse_node_remove(struct puffs_cc *pcc, void *opc, void *targ,
fuse = puffs_getspecific(pu);
set_fuse_context_uid_gid(pcn->pcn_cred);
set_fuse_context_pid(pcn->pcn_cid);
set_fuse_context_pid(pcc);
if (fuse->op.unlink == NULL) {
return ENOSYS;
@ -812,7 +814,7 @@ puffs_fuse_node_rmdir(struct puffs_cc *pcc, void *opc, void *targ,
fuse = puffs_getspecific(pu);
set_fuse_context_uid_gid(pcn->pcn_cred);
set_fuse_context_pid(pcn->pcn_cid);
set_fuse_context_pid(pcc);
if (fuse->op.rmdir == NULL) {
return ENOSYS;
@ -839,7 +841,7 @@ puffs_fuse_node_symlink(struct puffs_cc *pcc, void *opc,
fuse = puffs_getspecific(pu);
set_fuse_context_uid_gid(pcn_src->pcn_cred);
set_fuse_context_pid(pcn_src->pcn_cid);
set_fuse_context_pid(pcc);
if (fuse->op.symlink == NULL) {
return ENOSYS;
@ -871,7 +873,7 @@ puffs_fuse_node_rename(struct puffs_cc *pcc, void *opc, void *src,
fuse = puffs_getspecific(pu);
set_fuse_context_uid_gid(pcn_targ->pcn_cred);
set_fuse_context_pid(pcn_targ->pcn_cid);
set_fuse_context_pid(pcc);
if (fuse->op.rename == NULL) {
return ENOSYS;
@ -899,7 +901,7 @@ puffs_fuse_node_link(struct puffs_cc *pcc, void *opc, void *targ,
fuse = puffs_getspecific(pu);
set_fuse_context_uid_gid(pcn->pcn_cred);
set_fuse_context_pid(pcn->pcn_cid);
set_fuse_context_pid(pcc);
if (fuse->op.link == NULL) {
return ENOSYS;
@ -930,7 +932,7 @@ puffs_fuse_node_setattr(struct puffs_cc *pcc, void *opc,
fuse = puffs_getspecific(pu);
set_fuse_context_uid_gid(pcr);
set_fuse_context_pid(pcid);
set_fuse_context_pid(pcc);
return fuse_setattr(fuse, pn, path, va);
}
@ -950,7 +952,7 @@ puffs_fuse_node_open(struct puffs_cc *pcc, void *opc, int mode,
fuse = puffs_getspecific(pu);
set_fuse_context_uid_gid(cred);
set_fuse_context_pid(pcid);
set_fuse_context_pid(pcc);
/* if open, don't open again, lest risk nuking file private info */
if (rn->flags & RN_OPEN) {
@ -993,7 +995,7 @@ puffs_fuse_node_close(struct puffs_cc *pcc, void *opc, int fflag,
ret = 0;
set_fuse_context_uid_gid(pcr);
set_fuse_context_pid(pcid);
set_fuse_context_pid(pcc);
if (rn->flags & RN_OPEN) {
if (pn->pn_va.va_type == VDIR) {
@ -1031,6 +1033,7 @@ puffs_fuse_node_read(struct puffs_cc *pcc, void *opc, uint8_t *buf,
}
set_fuse_context_uid_gid(pcr);
set_fuse_context_pid(pcc);
maxread = *resid;
if (maxread > pn->pn_va.va_size - offset) {
@ -1071,6 +1074,7 @@ puffs_fuse_node_write(struct puffs_cc *pcc, void *opc, uint8_t *buf,
}
set_fuse_context_uid_gid(pcr);
set_fuse_context_pid(pcc);
if (ioflag & PUFFS_IO_APPEND)
offset = pn->pn_va.va_size;
@ -1110,6 +1114,7 @@ puffs_fuse_node_readdir(struct puffs_cc *pcc, void *opc, struct dirent *dent,
}
set_fuse_context_uid_gid(pcr);
set_fuse_context_pid(pcc);
if (pn->pn_va.va_type != VDIR)
return ENOTDIR;
@ -1160,9 +1165,6 @@ puffs_fuse_node_reclaim(struct puffs_cc *pcc, void *opc,
struct puffs_node *pn = opc;
nukern(pn);
set_fuse_context_pid(pcid);
return 0;
}
@ -1175,7 +1177,7 @@ puffs_fuse_fs_unmount(struct puffs_cc *pcc, int flags,
struct fuse *fuse;
fuse = puffs_getspecific(pu);
set_fuse_context_pid(pcid);
set_fuse_context_pid(pcc);
if (fuse->op.destroy == NULL) {
return 0;
}
@ -1189,7 +1191,7 @@ puffs_fuse_fs_sync(struct puffs_cc *pcc, int flags,
const struct puffs_cred *cr, const struct puffs_cid *pcid)
{
set_fuse_context_uid_gid(cr);
set_fuse_context_pid(pcid);
set_fuse_context_pid(pcc);
return 0;
}
@ -1203,7 +1205,7 @@ puffs_fuse_fs_statvfs(struct puffs_cc *pcc, struct statvfs *svfsb,
int ret;
fuse = puffs_getspecific(pu);
set_fuse_context_pid(pcid);
set_fuse_context_pid(pcc);
if (fuse->op.statfs == NULL) {
if ((ret = statvfs(PNPATH(puffs_getroot(pu)), svfsb)) == -1) {
return errno;