Instead of keeping on adding parameters to puffs_mount(), make it

only take the bare essentials, which currently means removing
"maxreqlen" from the argument list (all current callers I'm aware
of set it as 0 anyway).  Introduce puffs_init(), which provides a
context for setting various parameters and puffs_domount(), which
can be used to mount the file system.  Keep puffs_mount() as a
shortcut for the above two for simple file systems.

Bump development ABI version to 13.  After all, it's Friday the 13th.
Watch out!  Bad things can happen on Friday the 13th. --No carrier--
This commit is contained in:
pooka 2007-04-13 13:35:46 +00:00
parent 4e4ce72bb3
commit 37dd7942fc
12 changed files with 115 additions and 81 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: flush.c,v 1.8 2007/04/12 15:09:00 pooka Exp $ */
/* $NetBSD: flush.c,v 1.9 2007/04/13 13:35:46 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: flush.c,v 1.8 2007/04/12 15:09:00 pooka Exp $");
__RCSID("$NetBSD: flush.c,v 1.9 2007/04/13 13:35:46 pooka Exp $");
#endif /* !lint */
/*
@ -64,7 +64,7 @@ puffs_inval_namecache_dir(struct puffs_usermount *pu, void *cookie)
pf.pf_op = PUFFS_INVAL_NAMECACHE_DIR;
pf.pf_cookie = cookie;
return ioctl(pu->pu_fd, PUFFSFLUSHOP, &pf);
return ioctl(pu->pu_kargs.pa_fd, PUFFSFLUSHOP, &pf);
}
int
@ -75,7 +75,7 @@ puffs_inval_namecache_all(struct puffs_usermount *pu)
pf.pf_op = PUFFS_INVAL_NAMECACHE_ALL;
pf.pf_cookie = NULL;
return ioctl(pu->pu_fd, PUFFSFLUSHOP, &pf);
return ioctl(pu->pu_kargs.pa_fd, PUFFSFLUSHOP, &pf);
}
int
@ -88,7 +88,7 @@ puffs_inval_pagecache_node(struct puffs_usermount *pu, void *cookie)
pf.pf_start = 0;
pf.pf_end = 0;
return ioctl(pu->pu_fd, PUFFSFLUSHOP, &pf);
return ioctl(pu->pu_kargs.pa_fd, PUFFSFLUSHOP, &pf);
}
int
@ -102,7 +102,7 @@ puffs_inval_pagecache_node_range(struct puffs_usermount *pu, void *cookie,
pf.pf_start = start;
pf.pf_end = end;
return ioctl(pu->pu_fd, PUFFSFLUSHOP, &pf);
return ioctl(pu->pu_kargs.pa_fd, PUFFSFLUSHOP, &pf);
}
int
@ -115,7 +115,7 @@ puffs_flush_pagecache_node(struct puffs_usermount *pu, void *cookie)
pf.pf_start = 0;
pf.pf_end = 0;
return ioctl(pu->pu_fd, PUFFSFLUSHOP, &pf);
return ioctl(pu->pu_kargs.pa_fd, PUFFSFLUSHOP, &pf);
}
int
@ -129,5 +129,5 @@ puffs_flush_pagecache_node_range(struct puffs_usermount *pu, void *cookie,
pf.pf_start = start;
pf.pf_end = end;
return ioctl(pu->pu_fd, PUFFSFLUSHOP, &pf);
return ioctl(pu->pu_kargs.pa_fd, PUFFSFLUSHOP, &pf);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs.c,v 1.35 2007/04/12 15:09:01 pooka Exp $ */
/* $NetBSD: puffs.c,v 1.36 2007/04/13 13:35:46 pooka Exp $ */
/*
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
@ -34,7 +34,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: puffs.c,v 1.35 2007/04/12 15:09:01 pooka Exp $");
__RCSID("$NetBSD: puffs.c,v 1.36 2007/04/13 13:35:46 pooka Exp $");
#endif /* !lint */
#include <sys/param.h>
@ -110,7 +110,7 @@ int
puffs_getselectable(struct puffs_usermount *pu)
{
return pu->pu_fd;
return pu->pu_kargs.pa_fd;
}
int
@ -119,7 +119,7 @@ puffs_setblockingmode(struct puffs_usermount *pu, int mode)
int x;
x = mode;
return ioctl(pu->pu_fd, FIONBIO, &x);
return ioctl(pu->pu_kargs.pa_fd, FIONBIO, &x);
}
int
@ -175,7 +175,7 @@ size_t
puffs_getmaxreqlen(struct puffs_usermount *pu)
{
return pu->pu_maxreqlen;
return pu->pu_kargs.pa_maxreqlen;
}
void
@ -213,15 +213,31 @@ puffs_set_namemod(struct puffs_usermount *pu, pu_namemod_fn fn)
pu->pu_namemod = fn;
}
enum {PUFFCALL_ANSWER, PUFFCALL_IGNORE, PUFFCALL_AGAIN};
int
puffs_domount(struct puffs_usermount *pu, const char *dir, int mntflags)
{
#if 1
/* XXXkludgehere */
/* kauth doesn't provide this service any longer */
if (geteuid() != 0)
mntflags |= MNT_NOSUID | MNT_NODEV;
#endif
if (mount(MOUNT_PUFFS, dir, mntflags, &pu->pu_kargs) == -1)
return -1;
pu->pu_state = PUFFS_STATE_MOUNTING;
return 0;
}
struct puffs_usermount *
_puffs_mount(int develv, struct puffs_ops *pops, const char *dir, int mntflags,
const char *puffsname, void *priv, uint32_t pflags, size_t maxreqlen)
_puffs_init(int develv, struct puffs_ops *pops, const char *puffsname,
void *priv, uint32_t pflags)
{
struct puffs_args pargs;
struct puffs_usermount *pu;
int fd = 0;
struct puffs_kargs *pargs;
int fd;
if (develv != PUFFS_DEVEL_LIBVERSION) {
warnx("puffs_mount: mounting with lib version %d, need %d",
@ -237,21 +253,22 @@ _puffs_mount(int develv, struct puffs_ops *pops, const char *dir, int mntflags,
warnx("puffs_mount: device fd %d (<= 2), sure this is "
"what you want?", fd);
pargs.pa_vers = PUFFSDEVELVERS | PUFFSVERSION;
pargs.pa_flags = PUFFS_FLAG_KERN(pflags);
pargs.pa_fd = fd;
pargs.pa_maxreqlen = maxreqlen;
fillvnopmask(pops, pargs.pa_vnopmask);
(void)strlcpy(pargs.pa_name, puffsname, sizeof(pargs.pa_name));
pu = malloc(sizeof(struct puffs_usermount));
if (!pu)
return NULL;
if (pu == NULL)
goto failfree;
pargs = &pu->pu_kargs;
memset(pargs, 0, sizeof(struct puffs_kargs));
pargs->pa_vers = PUFFSDEVELVERS | PUFFSVERSION;
pargs->pa_flags = PUFFS_FLAG_KERN(pflags);
pargs->pa_fd = fd;
fillvnopmask(pops, pargs->pa_vnopmask);
(void)strlcpy(pargs->pa_name, puffsname, sizeof(pargs->pa_name));
pu->pu_flags = pflags;
pu->pu_ops = *pops;
free(pops); /* XXX */
pu->pu_fd = fd;
pu->pu_privdata = priv;
pu->pu_cc_stacksize = PUFFS_CC_STACKSIZE_DEFAULT;
LIST_INIT(&pu->pu_pnodelst);
@ -265,29 +282,38 @@ _puffs_mount(int develv, struct puffs_ops *pops, const char *dir, int mntflags,
pu->pu_pathtransform = NULL;
pu->pu_namemod = NULL;
pu->pu_state = PUFFS_STATE_MOUNTING;
#if 1
/* XXXkludgehere */
/* kauth doesn't provide this service any longer */
if (geteuid() != 0)
mntflags |= MNT_NOSUID | MNT_NODEV;
#endif
if (mount(MOUNT_PUFFS, dir, mntflags, &pargs) == -1)
goto failfree;
pu->pu_maxreqlen = pargs.pa_maxreqlen;
pu->pu_state = PUFFS_STATE_BEFOREMOUNT;
return pu;
failfree:
/* can't unmount() from here for obvious reasons */
if (fd)
close(fd);
close(fd);
free(pu);
return NULL;
}
struct puffs_usermount *
_puffs_mount(int develv, struct puffs_ops *pops, const char *dir, int mntflags,
const char *puffsname, void *priv, uint32_t pflags)
{
struct puffs_usermount *pu;
int sverrno;
pu = _puffs_init(develv, pops, puffsname, priv, pflags);
if (pu == NULL)
return NULL;
if (puffs_domount(pu, dir, mntflags) == -1) {
sverrno = errno;
puffs_exit(pu, 1);
errno = sverrno;
return NULL;
}
return pu;
}
int
puffs_start(struct puffs_usermount *pu, void *rootcookie, struct statvfs *sbp)
{
@ -298,7 +324,7 @@ puffs_start(struct puffs_usermount *pu, void *rootcookie, struct statvfs *sbp)
sreq.psr_sb = *sbp;
/* tell kernel we're flying */
if (ioctl(pu->pu_fd, PUFFSSTARTOP, &sreq) == -1)
if (ioctl(pu->pu_kargs.pa_fd, PUFFSSTARTOP, &sreq) == -1)
return -1;
pu->pu_state = PUFFS_STATE_RUNNING;
@ -310,7 +336,7 @@ puffs_start(struct puffs_usermount *pu, void *rootcookie, struct statvfs *sbp)
* XXX: there's currently no clean way to request unmount from
* within the user server, so be very brutal about it.
*/
/*ARGSUSED*/
/*ARGSUSED1*/
int
puffs_exit(struct puffs_usermount *pu, int force)
{
@ -318,8 +344,8 @@ puffs_exit(struct puffs_usermount *pu, int force)
force = 1; /* currently */
if (pu->pu_fd)
close(pu->pu_fd);
if (pu->pu_kargs.pa_fd)
close(pu->pu_kargs.pa_fd);
pn = LIST_FIRST(&pu->pu_pnodelst);
while (pn) {
@ -340,7 +366,7 @@ puffs_mainloop(struct puffs_usermount *pu, int flags)
int rv;
rv = -1;
pgr = puffs_req_makeget(pu, pu->pu_maxreqlen, 0);
pgr = puffs_req_makeget(pu, puffs_getmaxreqlen(pu), 0);
if (pgr == NULL)
return -1;
@ -417,6 +443,8 @@ puffs_dopreq(struct puffs_usermount *pu, struct puffs_req *preq,
return rv;
}
enum {PUFFCALL_ANSWER, PUFFCALL_IGNORE, PUFFCALL_AGAIN};
int
puffs_docc(struct puffs_cc *pcc, struct puffs_putreq *ppr)
{
@ -1127,7 +1155,7 @@ puffs_calldispatcher(struct puffs_cc *pcc)
pop.pso_reqid = preq->preq_id;
/* let the kernel do it's intermediate duty */
error = ioctl(pu->pu_fd, PUFFSSIZEOP, &pop);
error = ioctl(pu->pu_kargs.pa_fd, PUFFSSIZEOP, &pop);
/*
* XXX: I don't actually know what the correct
* thing to do in case of an error is, so I'll
@ -1145,7 +1173,7 @@ puffs_calldispatcher(struct puffs_cc *pcc)
pop.pso_reqid = preq->preq_id;
/* let the kernel do it's intermediate duty */
error = ioctl(pu->pu_fd, PUFFSSIZEOP, &pop);
error = ioctl(pu->pu_kargs.pa_fd, PUFFSSIZEOP, &pop);
/*
* XXX: I don't actually know what the correct
* thing to do in case of an error is, so I'll

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs.h,v 1.42 2007/04/12 15:09:01 pooka Exp $ */
/* $NetBSD: puffs.h,v 1.43 2007/04/13 13:35:46 pooka Exp $ */
/*
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
@ -236,8 +236,9 @@ typedef int (*pu_namemod_fn)(struct puffs_usermount *,
struct puffs_pathobj *, struct puffs_cn *);
enum {
PUFFS_STATE_MOUNTING, PUFFS_STATE_RUNNING,
PUFFS_STATE_UNMOUNTING, PUFFS_STATE_UNMOUNTED
PUFFS_STATE_BEFOREMOUNT,
PUFFS_STATE_MOUNTING, PUFFS_STATE_RUNNING,
PUFFS_STATE_UNMOUNTING, PUFFS_STATE_UNMOUNTED
};
#define PUFFS_FLAG_KERN(a) ((a) & 0x0000ffff)
@ -357,9 +358,11 @@ enum {
#define PUFFSOP_SETFSNOP(ops, opname) \
(ops)->puffs_fs_##opname = puffs_fsnop_##opname
#define PUFFS_DEVEL_LIBVERSION 12
#define puffs_mount(a,b,c,d,e,f,g) \
_puffs_mount(PUFFS_DEVEL_LIBVERSION,a,b,c,d,e,f,g)
#define PUFFS_DEVEL_LIBVERSION 13
#define puffs_mount(a,b,c,d,e,f) \
_puffs_mount(PUFFS_DEVEL_LIBVERSION,a,b,c,d,e,f)
#define puffs_init(a,b,c,d) \
_puffs_init(PUFFS_DEVEL_LIBVERSION,a,b,c,d)
#define PNPATH(pnode) ((pnode)->pn_po.po_path)
@ -372,7 +375,10 @@ enum {
__BEGIN_DECLS
struct puffs_usermount *_puffs_mount(int, struct puffs_ops *, const char *, int,
const char *, void *, uint32_t, size_t);
const char *, void *, uint32_t);
struct puffs_usermount *_puffs_init(int, struct puffs_ops *pops, const char *,
void *, uint32_t);
int puffs_domount(struct puffs_usermount *, const char *, int);
int puffs_start(struct puffs_usermount *, void *, struct statvfs *);
int puffs_exit(struct puffs_usermount *, int);
int puffs_mainloop(struct puffs_usermount *, int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs_priv.h,v 1.5 2007/04/12 15:09:01 pooka Exp $ */
/* $NetBSD: puffs_priv.h,v 1.6 2007/04/13 13:35:46 pooka Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@ -44,10 +44,9 @@
*/
struct puffs_usermount {
struct puffs_ops pu_ops;
struct puffs_kargs pu_kargs;
int pu_fd;
uint32_t pu_flags;
size_t pu_maxreqlen;
size_t pu_cc_stacksize;
int pu_state;

View File

@ -1,4 +1,4 @@
/* $NetBSD: requests.c,v 1.4 2007/01/20 14:37:06 pooka Exp $ */
/* $NetBSD: requests.c,v 1.5 2007/04/13 13:35:46 pooka Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: requests.c,v 1.4 2007/01/20 14:37:06 pooka Exp $");
__RCSID("$NetBSD: requests.c,v 1.5 2007/04/13 13:35:46 pooka Exp $");
#endif /* !lint */
#include <sys/types.h>
@ -79,7 +79,8 @@ puffs_req_loadget(struct puffs_getreq *pgr)
/* reset */
pgr->pgr_phg = pgr->pgr_phg_orig;
if (ioctl(pgr->pgr_pu->pu_fd, PUFFSGETOP, &pgr->pgr_phg) == -1)
if (ioctl(pgr->pgr_pu->pu_kargs.pa_fd,
PUFFSGETOP, &pgr->pgr_phg) == -1)
return -1;
pgr->pgr_nextpreq = pgr->pgr_phg.phg_buf;
@ -185,7 +186,8 @@ puffs_req_putput(struct puffs_putreq *ppr)
{
if (ppr->ppr_php.php_nops)
if (ioctl(ppr->ppr_pu->pu_fd, PUFFSPUTOP, &ppr->ppr_php) == -1)
if (ioctl(ppr->ppr_pu->pu_kargs.pa_fd,
PUFFSPUTOP, &ppr->ppr_php) == -1)
return -1;
return 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: suspend.c,v 1.2 2007/04/12 15:09:01 pooka Exp $ */
/* $NetBSD: suspend.c,v 1.3 2007/04/13 13:35:46 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: suspend.c,v 1.2 2007/04/12 15:09:01 pooka Exp $");
__RCSID("$NetBSD: suspend.c,v 1.3 2007/04/13 13:35:46 pooka Exp $");
#endif /* !lint */
/*
@ -49,5 +49,5 @@ int
puffs_fs_suspend(struct puffs_usermount *pu)
{
return ioctl(pu->pu_fd, PUFFSSUSPENDOP);
return ioctl(pu->pu_kargs.pa_fd, PUFFSSUSPENDOP);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: refuse.c,v 1.46 2007/04/12 15:09:01 pooka Exp $ */
/* $NetBSD: refuse.c,v 1.47 2007/04/13 13:35:46 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.46 2007/04/12 15:09:01 pooka Exp $");
__RCSID("$NetBSD: refuse.c,v 1.47 2007/04/13 13:35:46 pooka Exp $");
#endif /* !lint */
#include <assert.h>
@ -1077,8 +1077,7 @@ fuse_new(struct fuse_chan *fc, struct fuse_args *args,
"refuse", fuse,
PUFFS_FLAG_BUILDPATH
| PUFFS_FLAG_OPDUMP
| PUFFS_KFLAG_NOCACHE,
0);
| PUFFS_KFLAG_NOCACHE);
if (pu == NULL) {
err(EXIT_FAILURE, "puffs_mount");
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: dtfs.c,v 1.17 2007/04/11 21:07:54 pooka Exp $ */
/* $NetBSD: dtfs.c,v 1.18 2007/04/13 13:35:46 pooka Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@ -149,7 +149,7 @@ main(int argc, char *argv[])
srandom(time(NULL)); /* for random generation numbers */
if ((pu = puffs_mount(pops, argv[0], mntflags, FSNAME, &dtm, pflags, 0))
if ((pu = puffs_mount(pops, argv[0], mntflags, FSNAME, &dtm, pflags))
== NULL)
err(1, "mount");

View File

@ -1,4 +1,4 @@
/* $NetBSD: pnullfs.c,v 1.6 2007/04/12 15:09:01 pooka Exp $ */
/* $NetBSD: pnullfs.c,v 1.7 2007/04/13 13:35:46 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -117,7 +117,7 @@ main(int argc, char *argv[])
PUFFSOP_SET(pops, puffs_null, node, reclaim);
if ((pu = puffs_mount(pops, argv[1], mntflags, "pnullfs", NULL,
pflags, 0)) == NULL)
pflags)) == NULL)
err(1, "mount");
if (statvfs(argv[0], &svfsb) == -1)

View File

@ -1,4 +1,4 @@
/* $NetBSD: rot13fs.c,v 1.4 2007/04/12 15:09:02 pooka Exp $ */
/* $NetBSD: rot13fs.c,v 1.5 2007/04/13 13:35:46 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -145,7 +145,7 @@ main(int argc, char *argv[])
PUFFSOP_SET(pops, puffs_null, node, reclaim);
if ((pu = puffs_mount(pops, argv[1], mntflags, "rot13", NULL,
pflags, 0)) == NULL)
pflags)) == NULL)
err(1, "mount");
if (statvfs(argv[0], &svfsb) == -1)

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysctlfs.c,v 1.17 2007/04/12 15:09:02 pooka Exp $ */
/* $NetBSD: sysctlfs.c,v 1.18 2007/04/13 13:35:47 pooka Exp $ */
/*
* Copyright (c) 2006, 2007 Antti Kantee. All Rights Reserved.
@ -263,7 +263,7 @@ main(int argc, char *argv[])
PUFFSOP_SET(pops, puffs_genfs, node, reclaim);
if ((pu = puffs_mount(pops, argv[0], mntflags, "sysctlfs", NULL,
pflags, 0)) == NULL)
pflags)) == NULL)
err(1, "mount");
puffs_set_pathbuild(pu, sysctlfs_pathbuild);

View File

@ -1,4 +1,4 @@
/* $NetBSD: psshfs.c,v 1.11 2007/04/12 20:42:46 pooka Exp $ */
/* $NetBSD: psshfs.c,v 1.12 2007/04/13 13:35:47 pooka Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@ -57,7 +57,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: psshfs.c,v 1.11 2007/04/12 20:42:46 pooka Exp $");
__RCSID("$NetBSD: psshfs.c,v 1.12 2007/04/13 13:35:47 pooka Exp $");
#endif /* !lint */
#include <sys/types.h>
@ -189,7 +189,7 @@ main(int argc, char *argv[])
sshargs[7] = 0;
if ((pu = puffs_mount(pops, argv[1], mntflags, "psshfs", &pctx,
PUFFS_FLAG_BUILDPATH | pflags, 0))==NULL)
PUFFS_FLAG_BUILDPATH | pflags)) == NULL)
err(1, "puffs_mount");
pssh_connect(&pctx, sshargs);