diff --git a/lib/libpuffs/puffs.c b/lib/libpuffs/puffs.c index 37b6fdd535d3..e014c0851d85 100644 --- a/lib/libpuffs/puffs.c +++ b/lib/libpuffs/puffs.c @@ -1,4 +1,4 @@ -/* $NetBSD: puffs.c,v 1.48 2007/05/16 09:41:04 pooka Exp $ */ +/* $NetBSD: puffs.c,v 1.49 2007/05/17 14:03:13 pooka Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -34,7 +34,7 @@ #include #if !defined(lint) -__RCSID("$NetBSD: puffs.c,v 1.48 2007/05/16 09:41:04 pooka Exp $"); +__RCSID("$NetBSD: puffs.c,v 1.49 2007/05/17 14:03:13 pooka Exp $"); #endif /* !lint */ #include @@ -176,6 +176,21 @@ puffs_getroot(struct puffs_usermount *pu) return pu->pu_pn_root; } +void +puffs_setrootinfo(struct puffs_usermount *pu, enum vtype vt, + vsize_t vsize, dev_t rdev) +{ + struct puffs_kargs *pargs = &pu->pu_kargs; + + if (puffs_getstate(pu) != PUFFS_STATE_BEFOREMOUNT) + warnx("puffs_setrootinfo: call has effect only " + "before mount\n"); + + pargs->pa_root_vtype = vt; + pargs->pa_root_vsize = vsize; + pargs->pa_root_rdev = rdev; +} + void * puffs_getspecific(struct puffs_usermount *pu) { @@ -291,7 +306,8 @@ puffs_setback(struct puffs_cc *pcc, int whatback) } int -puffs_domount(struct puffs_usermount *pu, const char *dir, int mntflags) +puffs_mount(struct puffs_usermount *pu, const char *dir, int mntflags, + void *cookie) { #if 1 @@ -301,9 +317,10 @@ puffs_domount(struct puffs_usermount *pu, const char *dir, int mntflags) mntflags |= MNT_NOSUID | MNT_NODEV; #endif + pu->pu_kargs.pa_root_cookie = cookie; if (mount(MOUNT_PUFFS, dir, mntflags, &pu->pu_kargs) == -1) return -1; - PU_SETSTATE(pu, PUFFS_STATE_MOUNTING); + PU_SETSTATE(pu, PUFFS_STATE_RUNNING); return 0; } @@ -342,6 +359,12 @@ _puffs_init(int develv, struct puffs_ops *pops, const char *puffsname, fillvnopmask(pops, pargs->pa_vnopmask); (void)strlcpy(pargs->pa_name, puffsname, sizeof(pargs->pa_name)); + puffs_zerostatvfs(&pargs->pa_svfsb); + pargs->pa_root_cookie = NULL; + pargs->pa_root_vtype = VDIR; + pargs->pa_root_vsize = 0; + pargs->pa_root_rdev = 0; + pu->pu_flags = pflags; pu->pu_ops = *pops; free(pops); /* XXX */ @@ -372,45 +395,6 @@ _puffs_init(int develv, struct puffs_ops *pops, const char *puffsname, 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) -{ - struct puffs_startreq sreq; - - memset(&sreq, 0, sizeof(struct puffs_startreq)); - sreq.psr_cookie = rootcookie; - sreq.psr_sb = *sbp; - - /* tell kernel we're flying */ - if (ioctl(pu->pu_kargs.pa_fd, PUFFSSTARTOP, &sreq) == -1) - return -1; - - PU_SETSTATE(pu, PUFFS_STATE_RUNNING); - - return 0; -} - /* * XXX: there's currently no clean way to request unmount from * within the user server, so be very brutal about it. diff --git a/lib/libpuffs/puffs.h b/lib/libpuffs/puffs.h index e757a769b756..13296e0f5e4d 100644 --- a/lib/libpuffs/puffs.h +++ b/lib/libpuffs/puffs.h @@ -1,4 +1,4 @@ -/* $NetBSD: puffs.h,v 1.57 2007/05/16 10:04:08 pooka Exp $ */ +/* $NetBSD: puffs.h,v 1.58 2007/05/17 14:03:13 pooka Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -238,8 +238,7 @@ typedef int (*pu_namemod_fn)(struct puffs_usermount *, struct puffs_pathobj *, struct puffs_cn *); enum { - PUFFS_STATE_BEFOREMOUNT, - PUFFS_STATE_MOUNTING, PUFFS_STATE_RUNNING, + PUFFS_STATE_BEFOREMOUNT, PUFFS_STATE_RUNNING, PUFFS_STATE_UNMOUNTING, PUFFS_STATE_UNMOUNTED }; @@ -362,9 +361,7 @@ enum { #define PUFFSOP_SETFSNOP(ops, opname) \ (ops)->puffs_fs_##opname = puffs_fsnop_##opname -#define PUFFS_DEVEL_LIBVERSION 18 -#define puffs_mount(a,b,c,d,e,f) \ - _puffs_mount(PUFFS_DEVEL_LIBVERSION,a,b,c,d,e,f) +#define PUFFS_DEVEL_LIBVERSION 19 #define puffs_init(a,b,c,d) \ _puffs_init(PUFFS_DEVEL_LIBVERSION,a,b,c,d) @@ -407,12 +404,9 @@ typedef void (*puffs_framev_cb)(struct puffs_usermount *, __BEGIN_DECLS -struct puffs_usermount *_puffs_mount(int, struct puffs_ops *, const char *, int, - 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_mount(struct puffs_usermount *, const char *, int, void*); int puffs_exit(struct puffs_usermount *, int); int puffs_mainloop(struct puffs_usermount *, int); @@ -428,6 +422,9 @@ void puffs_ml_settimeout(struct puffs_usermount *, struct timespec *); void puffs_setroot(struct puffs_usermount *, struct puffs_node *); struct puffs_node *puffs_getroot(struct puffs_usermount *); +void puffs_setrootinfo(struct puffs_usermount *, + enum vtype, vsize_t, dev_t); + void *puffs_getspecific(struct puffs_usermount *); void puffs_setmaxreqlen(struct puffs_usermount *, size_t); size_t puffs_getmaxreqlen(struct puffs_usermount *);