Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)
- Fix for possible unset uid/gid in toproto
- Fix for default mtree style
- Update libelf
- Importing libexecinfo
- Resynchronize GCC, mpc, gmp, mpfr
- build.sh: Replace params with show-params.
This has been done as the make target has been renamed in the same
way, while a new target named params has been added. This new
target generates a file containing all the parameters, instead of
printing it on the console.
- Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
get getservbyport() out of the inner loop
Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# $NetBSD: Makefile,v 1.1 2006/10/22 22:43:23 pooka Exp $
|
||||
|
||||
INCSDIR= /usr/include/fs/puffs
|
||||
|
||||
INCS= puffs_msgif.h
|
||||
|
||||
.include <bsd.kinc.mk>
|
||||
@@ -0,0 +1,10 @@
|
||||
$NetBSD: TODO,v 1.1 2009/05/18 15:47:28 pooka Exp $
|
||||
|
||||
General:
|
||||
* reference counting fix (reclaim)
|
||||
|
||||
puffs_msgif:
|
||||
* do use of struct vattr (except maybe when negotiated to be safe)
|
||||
* do not use dev_t
|
||||
* get rid of extra types such as voff_t
|
||||
* do something sane with componentname
|
||||
@@ -0,0 +1,10 @@
|
||||
# $NetBSD: files.puffs,v 1.5 2010/07/06 16:13:57 pooka Exp $
|
||||
|
||||
deffs PUFFS
|
||||
|
||||
file fs/puffs/puffs_compat.c puffs
|
||||
file fs/puffs/puffs_msgif.c puffs
|
||||
file fs/puffs/puffs_node.c puffs
|
||||
file fs/puffs/puffs_subr.c puffs
|
||||
file fs/puffs/puffs_vfsops.c puffs
|
||||
file fs/puffs/puffs_vnops.c puffs
|
||||
@@ -0,0 +1,437 @@
|
||||
/* $NetBSD: puffs_compat.c,v 1.2 2010/07/11 11:17:27 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file handles puffs PDUs so that they are compatible between
|
||||
* 32bit<->64bit time_t/dev_t. It enables running a -current kernel
|
||||
* against a 5.0 userland (assuming the protocol otherwise matches!).
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: puffs_compat.c,v 1.2 2010/07/11 11:17:27 pooka Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/atomic.h>
|
||||
#include <sys/kmem.h>
|
||||
#include <sys/kthread.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/namei.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/atomic.h>
|
||||
|
||||
#include <dev/putter/putter_sys.h>
|
||||
|
||||
#include <fs/puffs/puffs_msgif.h>
|
||||
#include <fs/puffs/puffs_sys.h>
|
||||
|
||||
#include <compat/sys/time.h>
|
||||
|
||||
/*
|
||||
* compat types
|
||||
*/
|
||||
struct vattr50 {
|
||||
enum vtype va_type;
|
||||
mode_t va_mode;
|
||||
nlink_t va_nlink;
|
||||
uid_t va_uid;
|
||||
gid_t va_gid;
|
||||
uint32_t va_fsid;
|
||||
ino_t va_fileid;
|
||||
u_quad_t va_size;
|
||||
long va_blocksize;
|
||||
struct timespec50 va_atime;
|
||||
struct timespec50 va_mtime;
|
||||
struct timespec50 va_ctime;
|
||||
struct timespec50 va_birthtime;
|
||||
u_long va_gen;
|
||||
u_long va_flags;
|
||||
uint32_t va_rdev;
|
||||
u_quad_t va_bytes;
|
||||
u_quad_t va_filerev;
|
||||
u_int va_vaflags;
|
||||
long va_spare;
|
||||
};
|
||||
|
||||
struct puffs50_vfsmsg_fhtonode {
|
||||
struct puffs_req pvfsr_pr;
|
||||
|
||||
void *pvfsr_fhcookie; /* IN */
|
||||
enum vtype pvfsr_vtype; /* IN */
|
||||
voff_t pvfsr_size; /* IN */
|
||||
uint32_t pvfsr_rdev; /* IN */
|
||||
|
||||
size_t pvfsr_dsize; /* OUT */
|
||||
uint8_t pvfsr_data[0] /* OUT, XXX */
|
||||
__aligned(ALIGNBYTES+1);
|
||||
};
|
||||
|
||||
struct puffs50_vnmsg_lookup {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcn pvnr_cn; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_cred; /* OUT */
|
||||
|
||||
puffs_cookie_t pvnr_newnode; /* IN */
|
||||
enum vtype pvnr_vtype; /* IN */
|
||||
voff_t pvnr_size; /* IN */
|
||||
uint32_t pvnr_rdev; /* IN */
|
||||
};
|
||||
|
||||
struct puffs50_vnmsg_create {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcn pvnr_cn; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_cred; /* OUT */
|
||||
|
||||
struct vattr50 pvnr_va; /* OUT */
|
||||
puffs_cookie_t pvnr_newnode; /* IN */
|
||||
};
|
||||
|
||||
struct puffs50_vnmsg_mknod {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcn pvnr_cn; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_cred; /* OUT */
|
||||
|
||||
struct vattr50 pvnr_va; /* OUT */
|
||||
puffs_cookie_t pvnr_newnode; /* IN */
|
||||
};
|
||||
|
||||
#define puffs50_vnmsg_setattr puffs50_vnmsg_setgetattr
|
||||
#define puffs50_vnmsg_getattr puffs50_vnmsg_setgetattr
|
||||
struct puffs50_vnmsg_setgetattr {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcred pvnr_cred; /* OUT */
|
||||
struct vattr50 pvnr_va; /* IN/OUT (op depend) */
|
||||
};
|
||||
|
||||
struct puffs50_vnmsg_mkdir {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcn pvnr_cn; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_cred; /* OUT */
|
||||
|
||||
struct vattr50 pvnr_va; /* OUT */
|
||||
puffs_cookie_t pvnr_newnode; /* IN */
|
||||
};
|
||||
|
||||
struct puffs50_vnmsg_symlink {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcn pvnr_cn; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_cred; /* OUT */
|
||||
|
||||
struct vattr50 pvnr_va; /* OUT */
|
||||
puffs_cookie_t pvnr_newnode; /* IN */
|
||||
char pvnr_link[MAXPATHLEN]; /* OUT */
|
||||
};
|
||||
|
||||
/*
|
||||
* vattr translation routines
|
||||
*/
|
||||
|
||||
static void
|
||||
vattr_to_50(const struct vattr *va, struct vattr50 *va50)
|
||||
{
|
||||
|
||||
va50->va_type = va->va_type;
|
||||
va50->va_mode = va->va_mode;
|
||||
va50->va_nlink = va->va_nlink;
|
||||
va50->va_uid = va->va_uid;
|
||||
va50->va_gid = va->va_gid;
|
||||
va50->va_fsid = (uint64_t)va->va_fsid;
|
||||
va50->va_fileid = va->va_fileid;
|
||||
va50->va_size = va->va_size;
|
||||
va50->va_blocksize = va->va_blocksize;
|
||||
timespec_to_timespec50(&va->va_atime, &va50->va_atime);
|
||||
timespec_to_timespec50(&va->va_ctime, &va50->va_ctime);
|
||||
timespec_to_timespec50(&va->va_mtime, &va50->va_mtime);
|
||||
timespec_to_timespec50(&va->va_birthtime, &va50->va_birthtime);
|
||||
va50->va_gen = va->va_gen;
|
||||
va50->va_flags = va->va_flags;
|
||||
va50->va_rdev = (int32_t)va->va_rdev;
|
||||
va50->va_bytes = va->va_bytes;
|
||||
va50->va_filerev = va->va_filerev;
|
||||
va50->va_vaflags = va->va_flags;
|
||||
}
|
||||
|
||||
static void
|
||||
vattr_from_50(const struct vattr50 *va50, struct vattr *va)
|
||||
{
|
||||
|
||||
va->va_type = va50->va_type;
|
||||
va->va_mode = va50->va_mode;
|
||||
va->va_nlink = va50->va_nlink;
|
||||
va->va_uid = va50->va_uid;
|
||||
va->va_gid = va50->va_gid;
|
||||
va->va_fsid = (uint32_t)va50->va_fsid;
|
||||
va->va_fileid = va50->va_fileid;
|
||||
va->va_size = va50->va_size;
|
||||
va->va_blocksize = va50->va_blocksize;
|
||||
timespec50_to_timespec(&va50->va_atime, &va->va_atime);
|
||||
timespec50_to_timespec(&va50->va_ctime, &va->va_ctime);
|
||||
timespec50_to_timespec(&va50->va_mtime, &va->va_mtime);
|
||||
timespec50_to_timespec(&va50->va_birthtime, &va->va_birthtime);
|
||||
va->va_gen = va50->va_gen;
|
||||
va->va_flags = va50->va_flags;
|
||||
va->va_rdev = (uint32_t)va50->va_rdev;
|
||||
va->va_bytes = va50->va_bytes;
|
||||
va->va_filerev = va50->va_filerev;
|
||||
va->va_vaflags = va50->va_flags;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX: cannot assert that sleeping is possible
|
||||
* (this always a valid assumption for now)
|
||||
*/
|
||||
#define INIT(name, extra) \
|
||||
struct puffs50_##name *cmsg; \
|
||||
struct puffs_##name *omsg; \
|
||||
creq =kmem_zalloc(sizeof(struct puffs50_##name)+extra,KM_SLEEP);\
|
||||
cmsg = (struct puffs50_##name *)creq; \
|
||||
omsg = (struct puffs_##name *)oreq; \
|
||||
delta = sizeof(struct puffs50_##name)-sizeof(struct puffs_##name);
|
||||
#define ASSIGN(field) \
|
||||
cmsg->field = omsg->field;
|
||||
|
||||
bool
|
||||
puffs_compat_outgoing(struct puffs_req *oreq,
|
||||
struct puffs_req **creqp, ssize_t *deltap)
|
||||
{
|
||||
struct puffs_req *creq = NULL;
|
||||
ssize_t delta = 0;
|
||||
bool rv = false;
|
||||
|
||||
if (PUFFSOP_OPCLASS(oreq->preq_opclass) == PUFFSOP_VFS
|
||||
&& oreq->preq_optype == PUFFS_VFS_FHTOVP) {
|
||||
INIT(vfsmsg_fhtonode,
|
||||
((struct puffs_vfsmsg_fhtonode *)oreq)->pvfsr_dsize);
|
||||
|
||||
ASSIGN(pvfsr_pr);
|
||||
ASSIGN(pvfsr_dsize);
|
||||
memcpy(cmsg->pvfsr_data, omsg->pvfsr_data, cmsg->pvfsr_dsize);
|
||||
} else if (PUFFSOP_OPCLASS(oreq->preq_opclass) == PUFFSOP_VN) {
|
||||
switch (oreq->preq_optype) {
|
||||
case PUFFS_VN_LOOKUP:
|
||||
{
|
||||
INIT(vnmsg_lookup, 0);
|
||||
|
||||
ASSIGN(pvn_pr);
|
||||
ASSIGN(pvnr_cn);
|
||||
ASSIGN(pvnr_cn_cred);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PUFFS_VN_CREATE:
|
||||
{
|
||||
INIT(vnmsg_create, 0);
|
||||
|
||||
ASSIGN(pvn_pr);
|
||||
ASSIGN(pvnr_cn);
|
||||
ASSIGN(pvnr_cn_cred);
|
||||
vattr_to_50(&omsg->pvnr_va, &cmsg->pvnr_va);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PUFFS_VN_MKNOD:
|
||||
{
|
||||
INIT(vnmsg_mknod, 0);
|
||||
|
||||
ASSIGN(pvn_pr);
|
||||
ASSIGN(pvnr_cn);
|
||||
ASSIGN(pvnr_cn_cred);
|
||||
vattr_to_50(&omsg->pvnr_va, &cmsg->pvnr_va);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PUFFS_VN_MKDIR:
|
||||
{
|
||||
INIT(vnmsg_mkdir, 0);
|
||||
|
||||
ASSIGN(pvn_pr);
|
||||
ASSIGN(pvnr_cn);
|
||||
ASSIGN(pvnr_cn_cred);
|
||||
vattr_to_50(&omsg->pvnr_va, &cmsg->pvnr_va);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PUFFS_VN_SYMLINK:
|
||||
{
|
||||
INIT(vnmsg_symlink, 0);
|
||||
|
||||
ASSIGN(pvn_pr);
|
||||
ASSIGN(pvnr_cn);
|
||||
ASSIGN(pvnr_cn_cred);
|
||||
vattr_to_50(&omsg->pvnr_va, &cmsg->pvnr_va);
|
||||
memcpy(cmsg->pvnr_link, omsg->pvnr_link,
|
||||
sizeof(cmsg->pvnr_link));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PUFFS_VN_SETATTR:
|
||||
{
|
||||
INIT(vnmsg_setattr, 0);
|
||||
|
||||
ASSIGN(pvn_pr);
|
||||
ASSIGN(pvnr_cred);
|
||||
vattr_to_50(&omsg->pvnr_va, &cmsg->pvnr_va);
|
||||
|
||||
break;
|
||||
}
|
||||
case PUFFS_VN_GETATTR:
|
||||
{
|
||||
INIT(vnmsg_getattr, 0);
|
||||
|
||||
ASSIGN(pvn_pr);
|
||||
ASSIGN(pvnr_cred);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (creq) {
|
||||
*creqp = creq;
|
||||
*deltap = delta;
|
||||
rv = true;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
#undef INIT
|
||||
#undef ASSIGN
|
||||
|
||||
#define INIT(name) \
|
||||
struct puffs50_##name *cmsg = (void *)preq; \
|
||||
struct puffs_##name *omsg = (void *)creq;
|
||||
#define ASSIGN(field) \
|
||||
omsg->field = cmsg->field;
|
||||
|
||||
void
|
||||
puffs_compat_incoming(struct puffs_req *preq, struct puffs_req *creq)
|
||||
{
|
||||
|
||||
if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VFS
|
||||
&& preq->preq_optype == PUFFS_VFS_FHTOVP) {
|
||||
INIT(vfsmsg_fhtonode);
|
||||
|
||||
ASSIGN(pvfsr_pr);
|
||||
|
||||
ASSIGN(pvfsr_fhcookie);
|
||||
ASSIGN(pvfsr_vtype);
|
||||
ASSIGN(pvfsr_size);
|
||||
ASSIGN(pvfsr_rdev);
|
||||
} else if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN) {
|
||||
switch (preq->preq_optype) {
|
||||
case PUFFS_VN_LOOKUP:
|
||||
{
|
||||
INIT(vnmsg_lookup);
|
||||
|
||||
ASSIGN(pvn_pr);
|
||||
ASSIGN(pvnr_newnode);
|
||||
ASSIGN(pvnr_vtype);
|
||||
ASSIGN(pvnr_size);
|
||||
ASSIGN(pvnr_rdev);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PUFFS_VN_CREATE:
|
||||
{
|
||||
INIT(vnmsg_create);
|
||||
|
||||
ASSIGN(pvn_pr);
|
||||
ASSIGN(pvnr_newnode);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PUFFS_VN_MKNOD:
|
||||
{
|
||||
INIT(vnmsg_mknod);
|
||||
|
||||
ASSIGN(pvn_pr);
|
||||
ASSIGN(pvnr_newnode);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PUFFS_VN_MKDIR:
|
||||
{
|
||||
INIT(vnmsg_mkdir);
|
||||
|
||||
ASSIGN(pvn_pr);
|
||||
ASSIGN(pvnr_newnode);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PUFFS_VN_SYMLINK:
|
||||
{
|
||||
INIT(vnmsg_symlink);
|
||||
|
||||
ASSIGN(pvn_pr);
|
||||
ASSIGN(pvnr_newnode);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PUFFS_VN_SETATTR:
|
||||
{
|
||||
INIT(vnmsg_setattr);
|
||||
|
||||
ASSIGN(pvn_pr);
|
||||
|
||||
break;
|
||||
}
|
||||
case PUFFS_VN_GETATTR:
|
||||
{
|
||||
INIT(vnmsg_getattr);
|
||||
|
||||
ASSIGN(pvn_pr);
|
||||
vattr_from_50(&cmsg->pvnr_va, &omsg->pvnr_va);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
panic("puffs compat ops come in pairs");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,699 @@
|
||||
/* $NetBSD: puffs_msgif.h,v 1.80 2012/08/10 16:49:35 manu Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
|
||||
*
|
||||
* Development of this software was supported by the
|
||||
* Google Summer of Code program and the Ulla Tuominen Foundation.
|
||||
* The Google SoC project was mentored by Bill Studenmund.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _FS_PUFFS_PUFFS_MSGIF_H_
|
||||
#define _FS_PUFFS_PUFFS_MSGIF_H_
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/ioccom.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/ucred.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <sys/dirent.h>
|
||||
#include <sys/fcntl.h>
|
||||
|
||||
#if !defined(__minix)
|
||||
#include <dev/putter/putter.h>
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
#include <uvm/uvm_prot.h>
|
||||
|
||||
#define PUFFSOP_VFS 0x01 /* kernel-> */
|
||||
#define PUFFSOP_VN 0x02 /* kernel-> */
|
||||
#define PUFFSOP_CACHE 0x03 /* only kernel-> */
|
||||
#define PUFFSOP_ERROR 0x04 /* only kernel-> */
|
||||
#define PUFFSOP_FLUSH 0x05 /* ->kernel */
|
||||
#define PUFFSOP_SUSPEND 0x06 /* ->kernel */
|
||||
#define PUFFSOP_UNMOUNT 0x07 /* ->kernel */
|
||||
|
||||
#define PUFFSOPFLAG_FAF 0x10 /* fire-and-forget */
|
||||
#define PUFFSOPFLAG_ISRESPONSE 0x20 /* req is actually a resp */
|
||||
|
||||
#define PUFFSOP_OPCMASK 0x07
|
||||
#define PUFFSOP_OPCLASS(a) ((a) & PUFFSOP_OPCMASK)
|
||||
#define PUFFSOP_WANTREPLY(a) (((a) & PUFFSOPFLAG_FAF) == 0)
|
||||
|
||||
enum {
|
||||
PUFFS_VFS_MOUNT, PUFFS_VFS_START, PUFFS_VFS_UNMOUNT,
|
||||
PUFFS_VFS_ROOT, PUFFS_VFS_QUOTACTL, PUFFS_VFS_STATVFS,
|
||||
PUFFS_VFS_SYNC, PUFFS_VFS_VGET, PUFFS_VFS_FHTOVP,
|
||||
PUFFS_VFS_VPTOFH, PUFFS_VFS_INIT, PUFFS_VFS_DONE,
|
||||
PUFFS_VFS_SNAPSHOT, PUFFS_VFS_EXTATTRCTL, PUFFS_VFS_SUSPEND
|
||||
};
|
||||
#define PUFFS_VFS_MAX PUFFS_VFS_SUSPEND
|
||||
|
||||
enum {
|
||||
PUFFS_VN_LOOKUP, PUFFS_VN_CREATE, PUFFS_VN_MKNOD,
|
||||
PUFFS_VN_OPEN, PUFFS_VN_CLOSE, PUFFS_VN_ACCESS,
|
||||
PUFFS_VN_GETATTR, PUFFS_VN_SETATTR, PUFFS_VN_READ,
|
||||
PUFFS_VN_WRITE, PUFFS_VN_IOCTL, PUFFS_VN_FCNTL,
|
||||
PUFFS_VN_POLL, PUFFS_VN_KQFILTER, PUFFS_VN_REVOKE,
|
||||
PUFFS_VN_MMAP, PUFFS_VN_FSYNC, PUFFS_VN_SEEK,
|
||||
PUFFS_VN_REMOVE, PUFFS_VN_LINK, PUFFS_VN_RENAME,
|
||||
PUFFS_VN_MKDIR, PUFFS_VN_RMDIR, PUFFS_VN_SYMLINK,
|
||||
PUFFS_VN_READDIR, PUFFS_VN_READLINK, PUFFS_VN_ABORTOP,
|
||||
PUFFS_VN_INACTIVE, PUFFS_VN_RECLAIM, PUFFS_VN_LOCK,
|
||||
PUFFS_VN_UNLOCK, PUFFS_VN_BMAP, PUFFS_VN_STRATEGY,
|
||||
PUFFS_VN_PRINT, PUFFS_VN_ISLOCKED, PUFFS_VN_PATHCONF,
|
||||
PUFFS_VN_ADVLOCK, PUFFS_VN_LEASE, PUFFS_VN_WHITEOUT,
|
||||
PUFFS_VN_GETPAGES, PUFFS_VN_PUTPAGES, PUFFS_VN_GETEXTATTR,
|
||||
PUFFS_VN_LISTEXTATTR, PUFFS_VN_OPENEXTATTR, PUFFS_VN_DELETEEXTATTR,
|
||||
PUFFS_VN_SETEXTATTR, PUFFS_VN_CLOSEEXTATTR
|
||||
/* NOTE: If you add an op, decrement PUFFS_VN_SPARE accordingly */
|
||||
};
|
||||
#define PUFFS_VN_MAX PUFFS_VN_CLOSEEXTATTR
|
||||
#define PUFFS_VN_SPARE 32
|
||||
|
||||
/*
|
||||
* These signal invalid parameters the file system returned.
|
||||
*/
|
||||
enum {
|
||||
PUFFS_ERR_ERROR,
|
||||
PUFFS_ERR_MAKENODE, PUFFS_ERR_LOOKUP, PUFFS_ERR_READDIR,
|
||||
PUFFS_ERR_READLINK, PUFFS_ERR_READ, PUFFS_ERR_WRITE,
|
||||
PUFFS_ERR_VPTOFH, PUFFS_ERR_GETEXTATTR, PUFFS_ERR_LISTEXTATTR
|
||||
};
|
||||
#define PUFFS_ERR_MAX PUFFS_ERR_LISTEXTATTR
|
||||
|
||||
#define PUFFSVERSION 30
|
||||
#define PUFFSNAMESIZE 32
|
||||
|
||||
#define PUFFS_TYPEPREFIX "puffs|"
|
||||
|
||||
#define PUFFS_TYPELEN (_VFS_NAMELEN - (sizeof(PUFFS_TYPEPREFIX)+1))
|
||||
#define PUFFS_NAMELEN (_VFS_MNAMELEN-1)
|
||||
|
||||
/*
|
||||
* Just a weak typedef for code clarity. Additionally, we have a
|
||||
* more appropriate vanity type for puffs:
|
||||
* <uep> it should be croissant, not cookie.
|
||||
*/
|
||||
typedef void *puffs_cookie_t;
|
||||
typedef puffs_cookie_t puffs_croissant_t;
|
||||
|
||||
struct puffs_kargs {
|
||||
unsigned int pa_vers;
|
||||
int pa_fd;
|
||||
|
||||
uint32_t pa_flags;
|
||||
|
||||
size_t pa_maxmsglen;
|
||||
int pa_nhashbuckets;
|
||||
|
||||
size_t pa_fhsize;
|
||||
int pa_fhflags;
|
||||
|
||||
uint8_t pa_vnopmask[PUFFS_VN_MAX + PUFFS_VN_SPARE];
|
||||
|
||||
char pa_typename[_VFS_NAMELEN];
|
||||
char pa_mntfromname[_VFS_MNAMELEN];
|
||||
|
||||
puffs_cookie_t pa_root_cookie;
|
||||
enum vtype pa_root_vtype;
|
||||
voff_t pa_root_vsize;
|
||||
union {
|
||||
dev_t dev;
|
||||
uint64_t container;
|
||||
} devunion;
|
||||
|
||||
struct statvfs pa_svfsb;
|
||||
|
||||
uint32_t pa_time32;
|
||||
|
||||
uint32_t pa_spare[127];
|
||||
};
|
||||
#define pa_root_rdev devunion.dev
|
||||
|
||||
#define PUFFS_KFLAG_NOCACHE_NAME 0x001 /* don't use name cache */
|
||||
#define PUFFS_KFLAG_NOCACHE_PAGE 0x002 /* don't use page cache */
|
||||
#define PUFFS_KFLAG_NOCACHE 0x003 /* no cache whatsoever */
|
||||
#define PUFFS_KFLAG_ALLOPS 0x004 /* ignore pa_vnopmask */
|
||||
#define PUFFS_KFLAG_WTCACHE 0x008 /* write-through page cache */
|
||||
#define PUFFS_KFLAG_IAONDEMAND 0x010 /* inactive only on demand */
|
||||
#define PUFFS_KFLAG_LOOKUP_FULLPNBUF 0x020 /* full pnbuf in lookup */
|
||||
#define PUFFS_KFLAG_NOCACHE_ATTR 0x040 /* no attrib cache (unused) */
|
||||
#define PUFFS_KFLAG_CACHE_FS_TTL 0x080 /* cache use TTL from FS */
|
||||
#define PUFFS_KFLAG_CACHE_DOTDOT 0x100 /* don't send lookup for .. */
|
||||
#define PUFFS_KFLAG_MASK 0x1bf
|
||||
|
||||
#define PUFFS_FHFLAG_DYNAMIC 0x01
|
||||
#define PUFFS_FHFLAG_NFSV2 0x02
|
||||
#define PUFFS_FHFLAG_NFSV3 0x04
|
||||
#define PUFFS_FHFLAG_PROTOMASK 0x06
|
||||
#define PUFFS_FHFLAG_PASSTHROUGH 0x08
|
||||
#define PUFFS_FHFLAG_MASK 0x0f
|
||||
|
||||
#define PUFFS_FHSIZE_MAX 1020 /* FHANDLE_SIZE_MAX - 4 */
|
||||
|
||||
struct puffs_req {
|
||||
#if !defined(__minix)
|
||||
struct putter_hdr preq_pth;
|
||||
#endif /* ! defined(__minix) */
|
||||
|
||||
uint64_t preq_id;
|
||||
puffs_cookie_t preq_cookie;
|
||||
|
||||
uint16_t preq_opclass;
|
||||
uint16_t preq_optype;
|
||||
int preq_rv;
|
||||
|
||||
uint32_t preq_setbacks;
|
||||
|
||||
/* Who is making the call? Eventually host id is also needed. */
|
||||
pid_t preq_pid;
|
||||
lwpid_t preq_lid;
|
||||
|
||||
/*
|
||||
* the following helper pads the struct size to md alignment
|
||||
* multiple (should size_t not cut it). it makes sure that
|
||||
* whatever comes after this struct is aligned
|
||||
*/
|
||||
size_t preq_buflen;
|
||||
uint8_t preq_buf[0] __aligned(ALIGNBYTES+1);
|
||||
};
|
||||
|
||||
#define PUFFS_SETBACK_INACT_N1 0x01 /* set VOP_INACTIVE for node 1 */
|
||||
#define PUFFS_SETBACK_INACT_N2 0x02 /* set VOP_INACTIVE for node 2 */
|
||||
#define PUFFS_SETBACK_NOREF_N1 0x04 /* set pn PN_NOREFS for node 1 */
|
||||
#define PUFFS_SETBACK_NOREF_N2 0x08 /* set pn PN_NOREFS for node 2 */
|
||||
#define PUFFS_SETBACK_MASK 0x0f
|
||||
|
||||
/*
|
||||
* Flush operation. This can be used to invalidate:
|
||||
* 1) name cache for one node
|
||||
* 2) name cache for all children
|
||||
* 3) name cache for the entire mount
|
||||
* 4) page cache for a set of ranges in one node
|
||||
* 5) page cache for one entire node
|
||||
*
|
||||
* It can be used to flush:
|
||||
* 1) page cache for a set of ranges in one node
|
||||
* 2) page cache for one entire node
|
||||
*/
|
||||
|
||||
struct puffs_flush {
|
||||
struct puffs_req pf_req;
|
||||
|
||||
puffs_cookie_t pf_cookie;
|
||||
|
||||
int pf_op;
|
||||
off_t pf_start;
|
||||
off_t pf_end;
|
||||
};
|
||||
#define PUFFS_INVAL_NAMECACHE_NODE 0
|
||||
#define PUFFS_INVAL_NAMECACHE_DIR 1
|
||||
#define PUFFS_INVAL_NAMECACHE_ALL 2
|
||||
#define PUFFS_INVAL_PAGECACHE_NODE_RANGE 3
|
||||
#define PUFFS_FLUSH_PAGECACHE_NODE_RANGE 4
|
||||
|
||||
/*
|
||||
* Credentials for an operation. Can be either struct uucred for
|
||||
* ops called from a credential context or NOCRED/FSCRED for ops
|
||||
* called from within the kernel. It is up to the implementation
|
||||
* if it makes a difference between these two and the super-user.
|
||||
*/
|
||||
struct puffs_kcred {
|
||||
struct uucred pkcr_uuc;
|
||||
uint8_t pkcr_type;
|
||||
uint8_t pkcr_internal;
|
||||
};
|
||||
#define PUFFCRED_TYPE_UUC 1
|
||||
#define PUFFCRED_TYPE_INTERNAL 2
|
||||
#define PUFFCRED_CRED_NOCRED 1
|
||||
#define PUFFCRED_CRED_FSCRED 2
|
||||
|
||||
/*
|
||||
* 2*MAXPHYS is the max size the system will attempt to copy,
|
||||
* else treated as garbage
|
||||
*/
|
||||
#define PUFFS_MSG_MAXSIZE 2*MAXPHYS
|
||||
#define PUFFS_MSGSTRUCT_MAX 4096 /* approximate */
|
||||
|
||||
#define PUFFS_EXTNAMELEN KERNEL_NAME_MAX /* currently same as EXTATTR_MAXNAMELEN */
|
||||
|
||||
#define PUFFS_TOMOVE(a,b) (MIN((a), b->pmp_msg_maxsize - PUFFS_MSGSTRUCT_MAX))
|
||||
|
||||
/* puffs struct componentname built by kernel */
|
||||
struct puffs_kcn {
|
||||
/* args */
|
||||
uint32_t pkcn_nameiop; /* namei operation */
|
||||
uint32_t pkcn_flags; /* flags */
|
||||
|
||||
char pkcn_name[MAXPATHLEN]; /* nulterminated path component */
|
||||
size_t pkcn_namelen; /* current component length */
|
||||
size_t pkcn_consume; /* IN: extra chars server ate */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Next come the individual requests. They are all subclassed from
|
||||
* puffs_req and contain request-specific fields in addition. Note
|
||||
* that there are some requests which have to handle arbitrary-length
|
||||
* buffers.
|
||||
*
|
||||
* The division is the following: puffs_req is to be touched only
|
||||
* by generic routines while the other stuff is supposed to be
|
||||
* modified only by specific routines.
|
||||
*/
|
||||
|
||||
/*
|
||||
* aux structures for vfs operations.
|
||||
*/
|
||||
struct puffs_vfsmsg_unmount {
|
||||
struct puffs_req pvfsr_pr;
|
||||
|
||||
int pvfsr_flags;
|
||||
};
|
||||
|
||||
struct puffs_vfsmsg_statvfs {
|
||||
struct puffs_req pvfsr_pr;
|
||||
|
||||
struct statvfs pvfsr_sb;
|
||||
};
|
||||
|
||||
struct puffs_vfsmsg_sync {
|
||||
struct puffs_req pvfsr_pr;
|
||||
|
||||
struct puffs_kcred pvfsr_cred;
|
||||
int pvfsr_waitfor;
|
||||
};
|
||||
|
||||
struct puffs_vfsmsg_fhtonode {
|
||||
struct puffs_req pvfsr_pr;
|
||||
|
||||
void *pvfsr_fhcookie; /* IN */
|
||||
enum vtype pvfsr_vtype; /* IN */
|
||||
voff_t pvfsr_size; /* IN */
|
||||
dev_t pvfsr_rdev; /* IN */
|
||||
|
||||
size_t pvfsr_dsize; /* OUT */
|
||||
uint8_t pvfsr_data[0] /* OUT, XXX */
|
||||
__aligned(ALIGNBYTES+1);
|
||||
};
|
||||
|
||||
struct puffs_vfsmsg_nodetofh {
|
||||
struct puffs_req pvfsr_pr;
|
||||
|
||||
void *pvfsr_fhcookie; /* OUT */
|
||||
|
||||
size_t pvfsr_dsize; /* OUT/IN */
|
||||
uint8_t pvfsr_data[0] /* IN, XXX */
|
||||
__aligned(ALIGNBYTES+1);
|
||||
};
|
||||
|
||||
struct puffs_vfsmsg_suspend {
|
||||
struct puffs_req pvfsr_pr;
|
||||
|
||||
int pvfsr_status;
|
||||
};
|
||||
#define PUFFS_SUSPEND_START 0
|
||||
#define PUFFS_SUSPEND_SUSPENDED 1
|
||||
#define PUFFS_SUSPEND_RESUME 2
|
||||
#define PUFFS_SUSPEND_ERROR 3
|
||||
|
||||
#define PUFFS_EXTATTRCTL_HASNODE 0x01
|
||||
#define PUFFS_EXTATTRCTL_HASATTRNAME 0x02
|
||||
struct puffs_vfsmsg_extattrctl {
|
||||
struct puffs_req pvfsr_pr;
|
||||
|
||||
int pvfsr_cmd; /* OUT */
|
||||
int pvfsr_attrnamespace; /* OUT */
|
||||
int pvfsr_flags; /* OUT */
|
||||
char pvfsr_attrname[PUFFS_EXTNAMELEN]; /* OUT */
|
||||
};
|
||||
|
||||
/*
|
||||
* aux structures for vnode operations.
|
||||
*/
|
||||
|
||||
struct puffs_vnmsg_lookup {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcn pvnr_cn; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_cred; /* OUT */
|
||||
|
||||
puffs_cookie_t pvnr_newnode; /* IN */
|
||||
enum vtype pvnr_vtype; /* IN */
|
||||
voff_t pvnr_size; /* IN */
|
||||
dev_t pvnr_rdev; /* IN */
|
||||
/* Used only if PUFFS_KFLAG_CACHE_USE_TTL */
|
||||
struct vattr pvnr_va; /* IN */
|
||||
struct timespec pvnr_va_ttl; /* IN */
|
||||
struct timespec pvnr_cn_ttl; /* IN */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_create {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcn pvnr_cn; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_cred; /* OUT */
|
||||
|
||||
struct vattr pvnr_va; /* OUT */
|
||||
puffs_cookie_t pvnr_newnode; /* IN */
|
||||
/* Used only if PUFFS_KFLAG_CACHE_USE_TTL */
|
||||
struct timespec pvnr_va_ttl; /* IN */
|
||||
struct timespec pvnr_cn_ttl; /* IN */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_mknod {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcn pvnr_cn; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_cred; /* OUT */
|
||||
|
||||
struct vattr pvnr_va; /* OUT */
|
||||
puffs_cookie_t pvnr_newnode; /* IN */
|
||||
/* Used only if PUFFS_KFLAG_CACHE_USE_TTL */
|
||||
struct timespec pvnr_va_ttl; /* IN */
|
||||
struct timespec pvnr_cn_ttl; /* IN */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_open {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcred pvnr_cred; /* OUT */
|
||||
int pvnr_mode; /* OUT */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_close {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcred pvnr_cred; /* OUT */
|
||||
int pvnr_fflag; /* OUT */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_access {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcred pvnr_cred; /* OUT */
|
||||
int pvnr_mode; /* OUT */
|
||||
};
|
||||
|
||||
#define puffs_vnmsg_setattr puffs_vnmsg_setgetattr
|
||||
#define puffs_vnmsg_getattr puffs_vnmsg_setgetattr
|
||||
struct puffs_vnmsg_setgetattr {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcred pvnr_cred; /* OUT */
|
||||
struct vattr pvnr_va; /* IN/OUT (op depend) */
|
||||
/* Used only if PUFFS_KFLAG_CACHE_USE_TTL */
|
||||
struct timespec pvnr_va_ttl; /* IN */
|
||||
};
|
||||
|
||||
#define puffs_vnmsg_read puffs_vnmsg_rw
|
||||
#define puffs_vnmsg_write puffs_vnmsg_rw
|
||||
struct puffs_vnmsg_rw {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcred pvnr_cred; /* OUT */
|
||||
off_t pvnr_offset; /* OUT */
|
||||
size_t pvnr_resid; /* IN/OUT */
|
||||
int pvnr_ioflag; /* OUT */
|
||||
|
||||
uint8_t pvnr_data[0]; /* IN/OUT (wr/rd) */
|
||||
};
|
||||
|
||||
#define puffs_vnmsg_ioctl puffs_vnreq_fcnioctl
|
||||
#define puffs_vnmsg_fcntl puffs_vnreq_fcnioctl
|
||||
struct puffs_vnmsg_fcnioctl {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcred pvnr_cred;
|
||||
u_long pvnr_command;
|
||||
pid_t pvnr_pid;
|
||||
int pvnr_fflag;
|
||||
|
||||
void *pvnr_data;
|
||||
size_t pvnr_datalen;
|
||||
int pvnr_copyback;
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_poll {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
int pvnr_events; /* IN/OUT */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_fsync {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcred pvnr_cred; /* OUT */
|
||||
off_t pvnr_offlo; /* OUT */
|
||||
off_t pvnr_offhi; /* OUT */
|
||||
int pvnr_flags; /* OUT */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_seek {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcred pvnr_cred; /* OUT */
|
||||
off_t pvnr_oldoff; /* OUT */
|
||||
off_t pvnr_newoff; /* OUT */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_remove {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcn pvnr_cn; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_cred; /* OUT */
|
||||
|
||||
puffs_cookie_t pvnr_cookie_targ; /* OUT */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_mkdir {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcn pvnr_cn; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_cred; /* OUT */
|
||||
|
||||
struct vattr pvnr_va; /* OUT */
|
||||
puffs_cookie_t pvnr_newnode; /* IN */
|
||||
/* Used only if PUFFS_KFLAG_CACHE_USE_TTL */
|
||||
struct timespec pvnr_va_ttl; /* IN */
|
||||
struct timespec pvnr_cn_ttl; /* IN */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_rmdir {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcn pvnr_cn; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_cred; /* OUT */
|
||||
|
||||
puffs_cookie_t pvnr_cookie_targ; /* OUT */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_link {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcn pvnr_cn; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_cred; /* OUT */
|
||||
|
||||
puffs_cookie_t pvnr_cookie_targ; /* OUT */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_rename {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcn pvnr_cn_src; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_src_cred; /* OUT */
|
||||
struct puffs_kcn pvnr_cn_targ; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_targ_cred; /* OUT */
|
||||
|
||||
puffs_cookie_t pvnr_cookie_src; /* OUT */
|
||||
puffs_cookie_t pvnr_cookie_targ; /* OUT */
|
||||
puffs_cookie_t pvnr_cookie_targdir; /* OUT */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_symlink {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcn pvnr_cn; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_cred; /* OUT */
|
||||
|
||||
struct vattr pvnr_va; /* OUT */
|
||||
puffs_cookie_t pvnr_newnode; /* IN */
|
||||
char pvnr_link[MAXPATHLEN]; /* OUT */
|
||||
/* Used only if PUFFS_KFLAG_CACHE_USE_TTL */
|
||||
struct timespec pvnr_va_ttl; /* IN */
|
||||
struct timespec pvnr_cn_ttl; /* IN */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_readdir {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcred pvnr_cred; /* OUT */
|
||||
off_t pvnr_offset; /* IN/OUT */
|
||||
size_t pvnr_resid; /* IN/OUT */
|
||||
size_t pvnr_ncookies; /* IN/OUT */
|
||||
int pvnr_eofflag; /* IN */
|
||||
|
||||
size_t pvnr_dentoff; /* OUT */
|
||||
uint8_t pvnr_data[0] /* IN */
|
||||
__aligned(ALIGNBYTES+1);
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_readlink {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcred pvnr_cred; /* OUT */
|
||||
size_t pvnr_linklen; /* IN */
|
||||
char pvnr_link[MAXPATHLEN]; /* IN */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_reclaim {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
int pvnr_nlookup; /* OUT */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_inactive {
|
||||
struct puffs_req pvn_pr;
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_print {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
/* empty */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_pathconf {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
int pvnr_name; /* OUT */
|
||||
register_t pvnr_retval; /* IN */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_advlock {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct flock pvnr_fl; /* OUT */
|
||||
void *pvnr_id; /* OUT */
|
||||
int pvnr_op; /* OUT */
|
||||
int pvnr_flags; /* OUT */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_mmap {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
vm_prot_t pvnr_prot; /* OUT */
|
||||
struct puffs_kcred pvnr_cred; /* OUT */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_abortop {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
struct puffs_kcn pvnr_cn; /* OUT */
|
||||
struct puffs_kcred pvnr_cn_cred; /* OUT */
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_getextattr {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
int pvnr_attrnamespace; /* OUT */
|
||||
char pvnr_attrname[PUFFS_EXTNAMELEN];/* OUT */
|
||||
|
||||
struct puffs_kcred pvnr_cred; /* OUT */
|
||||
size_t pvnr_datasize; /* IN */
|
||||
|
||||
size_t pvnr_resid; /* IN/OUT */
|
||||
uint8_t pvnr_data[0] /* IN */
|
||||
__aligned(ALIGNBYTES+1);
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_setextattr {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
int pvnr_attrnamespace; /* OUT */
|
||||
char pvnr_attrname[PUFFS_EXTNAMELEN];/* OUT */
|
||||
|
||||
struct puffs_kcred pvnr_cred; /* OUT */
|
||||
|
||||
size_t pvnr_resid; /* IN/OUT */
|
||||
uint8_t pvnr_data[0] /* OUT */
|
||||
__aligned(ALIGNBYTES+1);
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_listextattr {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
int pvnr_attrnamespace; /* OUT */
|
||||
|
||||
struct puffs_kcred pvnr_cred; /* OUT */
|
||||
size_t pvnr_datasize; /* IN */
|
||||
|
||||
size_t pvnr_resid; /* IN/OUT */
|
||||
int pvnr_flag; /* OUT */
|
||||
uint8_t pvnr_data[0] /* IN */
|
||||
__aligned(ALIGNBYTES+1);
|
||||
};
|
||||
|
||||
struct puffs_vnmsg_deleteextattr {
|
||||
struct puffs_req pvn_pr;
|
||||
|
||||
int pvnr_attrnamespace; /* OUT */
|
||||
char pvnr_attrname[PUFFS_EXTNAMELEN];/* OUT */
|
||||
|
||||
struct puffs_kcred pvnr_cred; /* OUT */
|
||||
};
|
||||
|
||||
/*
|
||||
* For cache reports. Everything is always out-out-out, no replies
|
||||
*/
|
||||
|
||||
struct puffs_cacherun {
|
||||
off_t pcache_runstart;
|
||||
off_t pcache_runend;
|
||||
};
|
||||
|
||||
/* cache info. old used for write now */
|
||||
struct puffs_cacheinfo {
|
||||
struct puffs_req pcache_pr;
|
||||
|
||||
int pcache_type;
|
||||
size_t pcache_nruns;
|
||||
struct puffs_cacherun pcache_runs[0];
|
||||
};
|
||||
#define PCACHE_TYPE_READ 0
|
||||
#define PCACHE_TYPE_WRITE 1
|
||||
|
||||
/*
|
||||
* Error notification. Always outgoing, no response, no remorse.
|
||||
*/
|
||||
struct puffs_error {
|
||||
struct puffs_req perr_pr;
|
||||
|
||||
int perr_error;
|
||||
char perr_str[256];
|
||||
};
|
||||
|
||||
#endif /* _FS_PUFFS_PUFFS_MSGIF_H_ */
|
||||
@@ -0,0 +1,499 @@
|
||||
/* $NetBSD: puffs_node.c,v 1.30 2013/10/17 21:03:27 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
|
||||
*
|
||||
* Development of this software was supported by the
|
||||
* Google Summer of Code program, the Ulla Tuominen Foundation
|
||||
* and the Finnish Cultural Foundation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: puffs_node.c,v 1.30 2013/10/17 21:03:27 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/hash.h>
|
||||
#include <sys/kmem.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/namei.h>
|
||||
#include <sys/vnode.h>
|
||||
|
||||
#include <uvm/uvm.h>
|
||||
|
||||
#include <fs/puffs/puffs_msgif.h>
|
||||
#include <fs/puffs/puffs_sys.h>
|
||||
|
||||
#include <miscfs/genfs/genfs_node.h>
|
||||
#include <miscfs/specfs/specdev.h>
|
||||
|
||||
static const struct genfs_ops puffs_genfsops = {
|
||||
.gop_size = puffs_gop_size,
|
||||
.gop_write = genfs_gop_write,
|
||||
.gop_markupdate = puffs_gop_markupdate,
|
||||
#if 0
|
||||
.gop_alloc, should ask userspace
|
||||
#endif
|
||||
};
|
||||
|
||||
static __inline struct puffs_node_hashlist
|
||||
*puffs_cookie2hashlist(struct puffs_mount *, puffs_cookie_t);
|
||||
static struct puffs_node *puffs_cookie2pnode(struct puffs_mount *,
|
||||
puffs_cookie_t);
|
||||
|
||||
struct pool puffs_pnpool;
|
||||
struct pool puffs_vapool;
|
||||
|
||||
/*
|
||||
* Grab a vnode, intialize all the puffs-dependent stuff.
|
||||
*/
|
||||
int
|
||||
puffs_getvnode(struct mount *mp, puffs_cookie_t ck, enum vtype type,
|
||||
voff_t vsize, dev_t rdev, struct vnode **vpp)
|
||||
{
|
||||
struct puffs_mount *pmp;
|
||||
struct puffs_newcookie *pnc;
|
||||
struct vnode *vp;
|
||||
struct puffs_node *pnode;
|
||||
struct puffs_node_hashlist *plist;
|
||||
int error;
|
||||
|
||||
pmp = MPTOPUFFSMP(mp);
|
||||
|
||||
error = EPROTO;
|
||||
if (type <= VNON || type >= VBAD) {
|
||||
puffs_senderr(pmp, PUFFS_ERR_MAKENODE, EINVAL,
|
||||
"bad node type", ck);
|
||||
goto bad;
|
||||
}
|
||||
if (vsize == VSIZENOTSET) {
|
||||
puffs_senderr(pmp, PUFFS_ERR_MAKENODE, EINVAL,
|
||||
"VSIZENOTSET is not a valid size", ck);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
error = getnewvnode(VT_PUFFS, mp, puffs_vnodeop_p, NULL, &vp);
|
||||
if (error) {
|
||||
goto bad;
|
||||
}
|
||||
vp->v_type = type;
|
||||
|
||||
/*
|
||||
* Creation should not fail after this point. Or if it does,
|
||||
* care must be taken so that VOP_INACTIVE() isn't called.
|
||||
*/
|
||||
|
||||
/* default size */
|
||||
uvm_vnp_setsize(vp, 0);
|
||||
|
||||
/* dances based on vnode type. almost ufs_vinit(), but not quite */
|
||||
switch (type) {
|
||||
case VCHR:
|
||||
case VBLK:
|
||||
/*
|
||||
* replace vnode operation vector with the specops vector.
|
||||
* our user server has very little control over the node
|
||||
* if it decides its a character or block special file
|
||||
*/
|
||||
vp->v_op = puffs_specop_p;
|
||||
spec_node_init(vp, rdev);
|
||||
break;
|
||||
|
||||
case VFIFO:
|
||||
vp->v_op = puffs_fifoop_p;
|
||||
break;
|
||||
|
||||
case VREG:
|
||||
uvm_vnp_setsize(vp, vsize);
|
||||
break;
|
||||
|
||||
case VDIR:
|
||||
case VLNK:
|
||||
case VSOCK:
|
||||
break;
|
||||
default:
|
||||
panic("puffs_getvnode: invalid vtype %d", type);
|
||||
}
|
||||
|
||||
pnode = pool_get(&puffs_pnpool, PR_WAITOK);
|
||||
memset(pnode, 0, sizeof(struct puffs_node));
|
||||
|
||||
pnode->pn_cookie = ck;
|
||||
pnode->pn_refcount = 1;
|
||||
|
||||
/* insert cookie on list, take off of interlock list */
|
||||
mutex_init(&pnode->pn_mtx, MUTEX_DEFAULT, IPL_NONE);
|
||||
selinit(&pnode->pn_sel);
|
||||
plist = puffs_cookie2hashlist(pmp, ck);
|
||||
mutex_enter(&pmp->pmp_lock);
|
||||
LIST_INSERT_HEAD(plist, pnode, pn_hashent);
|
||||
if (ck != pmp->pmp_root_cookie) {
|
||||
LIST_FOREACH(pnc, &pmp->pmp_newcookie, pnc_entries) {
|
||||
if (pnc->pnc_cookie == ck) {
|
||||
LIST_REMOVE(pnc, pnc_entries);
|
||||
kmem_free(pnc, sizeof(struct puffs_newcookie));
|
||||
break;
|
||||
}
|
||||
}
|
||||
KASSERT(pnc != NULL);
|
||||
}
|
||||
mutex_init(&pnode->pn_sizemtx, MUTEX_DEFAULT, IPL_NONE);
|
||||
mutex_exit(&pmp->pmp_lock);
|
||||
|
||||
vp->v_data = pnode;
|
||||
vp->v_type = type;
|
||||
pnode->pn_vp = vp;
|
||||
pnode->pn_serversize = vsize;
|
||||
|
||||
genfs_node_init(vp, &puffs_genfsops);
|
||||
*vpp = vp;
|
||||
|
||||
DPRINTF(("new vnode at %p, pnode %p, cookie %p\n", vp,
|
||||
pnode, pnode->pn_cookie));
|
||||
|
||||
return 0;
|
||||
|
||||
bad:
|
||||
/* remove staging cookie from list */
|
||||
if (ck != pmp->pmp_root_cookie) {
|
||||
mutex_enter(&pmp->pmp_lock);
|
||||
LIST_FOREACH(pnc, &pmp->pmp_newcookie, pnc_entries) {
|
||||
if (pnc->pnc_cookie == ck) {
|
||||
LIST_REMOVE(pnc, pnc_entries);
|
||||
kmem_free(pnc, sizeof(struct puffs_newcookie));
|
||||
break;
|
||||
}
|
||||
}
|
||||
KASSERT(pnc != NULL);
|
||||
mutex_exit(&pmp->pmp_lock);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/* new node creating for creative vop ops (create, symlink, mkdir, mknod) */
|
||||
int
|
||||
puffs_newnode(struct mount *mp, struct vnode *dvp, struct vnode **vpp,
|
||||
puffs_cookie_t ck, struct componentname *cnp,
|
||||
enum vtype type, dev_t rdev)
|
||||
{
|
||||
struct puffs_mount *pmp = MPTOPUFFSMP(mp);
|
||||
struct puffs_newcookie *pnc;
|
||||
struct vnode *vp;
|
||||
int error;
|
||||
|
||||
/* userspace probably has this as a NULL op */
|
||||
if (ck == NULL) {
|
||||
error = EOPNOTSUPP;
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for previous node with the same designation.
|
||||
* Explicitly check the root node cookie, since it might be
|
||||
* reclaimed from the kernel when this check is made.
|
||||
*/
|
||||
mutex_enter(&pmp->pmp_lock);
|
||||
if (ck == pmp->pmp_root_cookie
|
||||
|| puffs_cookie2pnode(pmp, ck) != NULL) {
|
||||
mutex_exit(&pmp->pmp_lock);
|
||||
puffs_senderr(pmp, PUFFS_ERR_MAKENODE, EEXIST,
|
||||
"cookie exists", ck);
|
||||
return EPROTO;
|
||||
}
|
||||
|
||||
LIST_FOREACH(pnc, &pmp->pmp_newcookie, pnc_entries) {
|
||||
if (pnc->pnc_cookie == ck) {
|
||||
mutex_exit(&pmp->pmp_lock);
|
||||
puffs_senderr(pmp, PUFFS_ERR_MAKENODE, EEXIST,
|
||||
"newcookie exists", ck);
|
||||
return EPROTO;
|
||||
}
|
||||
}
|
||||
|
||||
KASSERT(curlwp != uvm.pagedaemon_lwp);
|
||||
pnc = kmem_alloc(sizeof(struct puffs_newcookie), KM_SLEEP);
|
||||
pnc->pnc_cookie = ck;
|
||||
LIST_INSERT_HEAD(&pmp->pmp_newcookie, pnc, pnc_entries);
|
||||
mutex_exit(&pmp->pmp_lock);
|
||||
|
||||
error = puffs_getvnode(dvp->v_mount, ck, type, 0, rdev, &vp);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
vp->v_type = type;
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
*vpp = vp;
|
||||
|
||||
if (PUFFS_USE_NAMECACHE(pmp))
|
||||
cache_enter(dvp, vp, cnp->cn_nameptr, cnp->cn_namelen,
|
||||
cnp->cn_flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
puffs_putvnode(struct vnode *vp)
|
||||
{
|
||||
struct puffs_node *pnode;
|
||||
|
||||
pnode = VPTOPP(vp);
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (vp->v_tag != VT_PUFFS)
|
||||
panic("puffs_putvnode: %p not a puffs vnode", vp);
|
||||
#endif
|
||||
|
||||
genfs_node_destroy(vp);
|
||||
puffs_releasenode(pnode);
|
||||
vp->v_data = NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static __inline struct puffs_node_hashlist *
|
||||
puffs_cookie2hashlist(struct puffs_mount *pmp, puffs_cookie_t ck)
|
||||
{
|
||||
uint32_t hash;
|
||||
|
||||
hash = hash32_buf(&ck, sizeof(ck), HASH32_BUF_INIT);
|
||||
return &pmp->pmp_pnodehash[hash % pmp->pmp_npnodehash];
|
||||
}
|
||||
|
||||
/*
|
||||
* Translate cookie to puffs_node. Caller must hold pmp_lock
|
||||
* and it will be held upon return.
|
||||
*/
|
||||
static struct puffs_node *
|
||||
puffs_cookie2pnode(struct puffs_mount *pmp, puffs_cookie_t ck)
|
||||
{
|
||||
struct puffs_node_hashlist *plist;
|
||||
struct puffs_node *pnode;
|
||||
|
||||
plist = puffs_cookie2hashlist(pmp, ck);
|
||||
LIST_FOREACH(pnode, plist, pn_hashent) {
|
||||
if (pnode->pn_cookie == ck)
|
||||
break;
|
||||
}
|
||||
|
||||
return pnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure root vnode exists and reference it. Does NOT lock.
|
||||
*/
|
||||
static int
|
||||
puffs_makeroot(struct puffs_mount *pmp)
|
||||
{
|
||||
struct vnode *vp;
|
||||
int rv;
|
||||
|
||||
/*
|
||||
* pmp_lock must be held if vref()'ing or vrele()'ing the
|
||||
* root vnode. the latter is controlled by puffs_inactive().
|
||||
*
|
||||
* pmp_root is set here and cleared in puffs_reclaim().
|
||||
*/
|
||||
retry:
|
||||
mutex_enter(&pmp->pmp_lock);
|
||||
vp = pmp->pmp_root;
|
||||
if (vp) {
|
||||
mutex_enter(vp->v_interlock);
|
||||
mutex_exit(&pmp->pmp_lock);
|
||||
switch (vget(vp, 0)) {
|
||||
case ENOENT:
|
||||
goto retry;
|
||||
case 0:
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else
|
||||
mutex_exit(&pmp->pmp_lock);
|
||||
|
||||
/*
|
||||
* So, didn't have the magic root vnode available.
|
||||
* No matter, grab another and stuff it with the cookie.
|
||||
*/
|
||||
if ((rv = puffs_getvnode(pmp->pmp_mp, pmp->pmp_root_cookie,
|
||||
pmp->pmp_root_vtype, pmp->pmp_root_vsize, pmp->pmp_root_rdev, &vp)))
|
||||
return rv;
|
||||
|
||||
/*
|
||||
* Someone magically managed to race us into puffs_getvnode?
|
||||
* Put our previous new vnode back and retry.
|
||||
*/
|
||||
mutex_enter(&pmp->pmp_lock);
|
||||
if (pmp->pmp_root) {
|
||||
struct puffs_node *pnode = vp->v_data;
|
||||
|
||||
LIST_REMOVE(pnode, pn_hashent);
|
||||
mutex_exit(&pmp->pmp_lock);
|
||||
puffs_putvnode(vp);
|
||||
goto retry;
|
||||
}
|
||||
|
||||
/* store cache */
|
||||
vp->v_vflag |= VV_ROOT;
|
||||
pmp->pmp_root = vp;
|
||||
mutex_exit(&pmp->pmp_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Locate the in-kernel vnode based on the cookie received given
|
||||
* from userspace.
|
||||
* The parameter "lock" control whether to lock the possible or
|
||||
* not. Locking always might cause us to lock against ourselves
|
||||
* in situations where we want the vnode but don't care for the
|
||||
* vnode lock, e.g. file server issued putpages.
|
||||
*
|
||||
* returns 0 on success. otherwise returns an errno or PUFFS_NOSUCHCOOKIE.
|
||||
*
|
||||
* returns PUFFS_NOSUCHCOOKIE if no vnode for the cookie is found.
|
||||
* in that case, if willcreate=true, the pmp_newcookie list is populated with
|
||||
* the given cookie. it's the caller's responsibility to consume the entry
|
||||
* with calling puffs_getvnode.
|
||||
*/
|
||||
int
|
||||
puffs_cookie2vnode(struct puffs_mount *pmp, puffs_cookie_t ck, int lock,
|
||||
int willcreate, struct vnode **vpp)
|
||||
{
|
||||
struct puffs_node *pnode;
|
||||
struct puffs_newcookie *pnc;
|
||||
struct vnode *vp;
|
||||
int vgetflags, rv;
|
||||
|
||||
/*
|
||||
* Handle root in a special manner, since we want to make sure
|
||||
* pmp_root is properly set.
|
||||
*/
|
||||
if (ck == pmp->pmp_root_cookie) {
|
||||
if ((rv = puffs_makeroot(pmp)))
|
||||
return rv;
|
||||
if (lock)
|
||||
vn_lock(pmp->pmp_root, LK_EXCLUSIVE | LK_RETRY);
|
||||
|
||||
*vpp = pmp->pmp_root;
|
||||
return 0;
|
||||
}
|
||||
|
||||
retry:
|
||||
mutex_enter(&pmp->pmp_lock);
|
||||
pnode = puffs_cookie2pnode(pmp, ck);
|
||||
if (pnode == NULL) {
|
||||
if (willcreate) {
|
||||
pnc = kmem_alloc(sizeof(struct puffs_newcookie),
|
||||
KM_SLEEP);
|
||||
pnc->pnc_cookie = ck;
|
||||
LIST_INSERT_HEAD(&pmp->pmp_newcookie, pnc, pnc_entries);
|
||||
}
|
||||
mutex_exit(&pmp->pmp_lock);
|
||||
return PUFFS_NOSUCHCOOKIE;
|
||||
}
|
||||
vp = pnode->pn_vp;
|
||||
mutex_enter(vp->v_interlock);
|
||||
mutex_exit(&pmp->pmp_lock);
|
||||
|
||||
vgetflags = 0;
|
||||
if (lock)
|
||||
vgetflags |= LK_EXCLUSIVE;
|
||||
switch (rv = vget(vp, vgetflags)) {
|
||||
case ENOENT:
|
||||
goto retry;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
return rv;
|
||||
}
|
||||
|
||||
*vpp = vp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
puffs_updatenode(struct puffs_node *pn, int flags, voff_t size)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
if (flags == 0)
|
||||
return;
|
||||
|
||||
nanotime(&ts);
|
||||
|
||||
if (flags & PUFFS_UPDATEATIME) {
|
||||
pn->pn_mc_atime = ts;
|
||||
pn->pn_stat |= PNODE_METACACHE_ATIME;
|
||||
}
|
||||
if (flags & PUFFS_UPDATECTIME) {
|
||||
pn->pn_mc_ctime = ts;
|
||||
pn->pn_stat |= PNODE_METACACHE_CTIME;
|
||||
}
|
||||
if (flags & PUFFS_UPDATEMTIME) {
|
||||
pn->pn_mc_mtime = ts;
|
||||
pn->pn_stat |= PNODE_METACACHE_MTIME;
|
||||
}
|
||||
if (flags & PUFFS_UPDATESIZE) {
|
||||
pn->pn_mc_size = size;
|
||||
pn->pn_stat |= PNODE_METACACHE_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add reference to node.
|
||||
* mutex held on entry and return
|
||||
*/
|
||||
void
|
||||
puffs_referencenode(struct puffs_node *pn)
|
||||
{
|
||||
|
||||
KASSERT(mutex_owned(&pn->pn_mtx));
|
||||
pn->pn_refcount++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Release pnode structure which dealing with references to the
|
||||
* puffs_node instead of the vnode. Can't use vref()/vrele() on
|
||||
* the vnode there, since that causes the lovely VOP_INACTIVE(),
|
||||
* which in turn causes the lovely deadlock when called by the one
|
||||
* who is supposed to handle it.
|
||||
*/
|
||||
void
|
||||
puffs_releasenode(struct puffs_node *pn)
|
||||
{
|
||||
|
||||
mutex_enter(&pn->pn_mtx);
|
||||
if (--pn->pn_refcount == 0) {
|
||||
mutex_exit(&pn->pn_mtx);
|
||||
mutex_destroy(&pn->pn_mtx);
|
||||
mutex_destroy(&pn->pn_sizemtx);
|
||||
seldestroy(&pn->pn_sel);
|
||||
if (pn->pn_va_cache != NULL)
|
||||
pool_put(&puffs_vapool, pn->pn_va_cache);
|
||||
pool_put(&puffs_pnpool, pn);
|
||||
} else {
|
||||
mutex_exit(&pn->pn_mtx);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
/* $NetBSD: puffs_subr.c,v 1.66 2008/11/16 19:34:30 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006, 2007 Antti Kantee. All Rights Reserved.
|
||||
*
|
||||
* Development of this software was supported by the
|
||||
* Ulla Tuominen Foundation and the Finnish Cultural Foundation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: puffs_subr.c,v 1.66 2008/11/16 19:34:30 pooka Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/namei.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sys/proc.h>
|
||||
|
||||
#include <fs/puffs/puffs_msgif.h>
|
||||
#include <fs/puffs/puffs_sys.h>
|
||||
|
||||
#ifdef PUFFSDEBUG
|
||||
int puffsdebug;
|
||||
#endif
|
||||
|
||||
void
|
||||
puffs_makecn(struct puffs_kcn *pkcn, struct puffs_kcred *pkcr,
|
||||
const struct componentname *cn, int full)
|
||||
{
|
||||
|
||||
pkcn->pkcn_nameiop = cn->cn_nameiop;
|
||||
pkcn->pkcn_flags = cn->cn_flags;
|
||||
|
||||
if (full) {
|
||||
(void)strcpy(pkcn->pkcn_name, cn->cn_nameptr);
|
||||
} else {
|
||||
(void)memcpy(pkcn->pkcn_name, cn->cn_nameptr, cn->cn_namelen);
|
||||
pkcn->pkcn_name[cn->cn_namelen] = '\0';
|
||||
}
|
||||
pkcn->pkcn_namelen = cn->cn_namelen;
|
||||
pkcn->pkcn_consume = 0;
|
||||
|
||||
puffs_credcvt(pkcr, cn->cn_cred);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert given credentials to struct puffs_kcred for userspace.
|
||||
*/
|
||||
void
|
||||
puffs_credcvt(struct puffs_kcred *pkcr, const kauth_cred_t cred)
|
||||
{
|
||||
|
||||
memset(pkcr, 0, sizeof(struct puffs_kcred));
|
||||
|
||||
if (cred == NOCRED || cred == FSCRED) {
|
||||
pkcr->pkcr_type = PUFFCRED_TYPE_INTERNAL;
|
||||
if (cred == NOCRED)
|
||||
pkcr->pkcr_internal = PUFFCRED_CRED_NOCRED;
|
||||
if (cred == FSCRED)
|
||||
pkcr->pkcr_internal = PUFFCRED_CRED_FSCRED;
|
||||
} else {
|
||||
pkcr->pkcr_type = PUFFCRED_TYPE_UUC;
|
||||
kauth_cred_to_uucred(&pkcr->pkcr_uuc, cred);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
puffs_parkdone_asyncbioread(struct puffs_mount *pmp,
|
||||
struct puffs_req *preq, void *arg)
|
||||
{
|
||||
struct puffs_vnmsg_read *read_msg = (void *)preq;
|
||||
struct buf *bp = arg;
|
||||
size_t moved;
|
||||
|
||||
DPRINTF(("%s\n", __func__));
|
||||
|
||||
bp->b_error = checkerr(pmp, preq->preq_rv, __func__);
|
||||
if (bp->b_error == 0) {
|
||||
if (read_msg->pvnr_resid > bp->b_bcount) {
|
||||
puffs_senderr(pmp, PUFFS_ERR_READ, E2BIG,
|
||||
"resid grew", preq->preq_cookie);
|
||||
bp->b_error = E2BIG;
|
||||
} else {
|
||||
moved = bp->b_bcount - read_msg->pvnr_resid;
|
||||
bp->b_resid = read_msg->pvnr_resid;
|
||||
|
||||
memcpy(bp->b_data, read_msg->pvnr_data, moved);
|
||||
}
|
||||
}
|
||||
|
||||
biodone(bp);
|
||||
}
|
||||
|
||||
void
|
||||
puffs_parkdone_asyncbiowrite(struct puffs_mount *pmp,
|
||||
struct puffs_req *preq, void *arg)
|
||||
{
|
||||
struct puffs_vnmsg_write *write_msg = (void *)preq;
|
||||
struct buf *bp = arg;
|
||||
|
||||
DPRINTF(("%s\n", __func__));
|
||||
|
||||
bp->b_error = checkerr(pmp, preq->preq_rv, __func__);
|
||||
if (bp->b_error == 0) {
|
||||
if (write_msg->pvnr_resid > bp->b_bcount) {
|
||||
puffs_senderr(pmp, PUFFS_ERR_WRITE, E2BIG,
|
||||
"resid grew", preq->preq_cookie);
|
||||
bp->b_error = E2BIG;
|
||||
} else {
|
||||
bp->b_resid = write_msg->pvnr_resid;
|
||||
}
|
||||
}
|
||||
|
||||
biodone(bp);
|
||||
}
|
||||
|
||||
/* XXX: userspace can leak kernel resources */
|
||||
void
|
||||
puffs_parkdone_poll(struct puffs_mount *pmp, struct puffs_req *preq, void *arg)
|
||||
{
|
||||
struct puffs_vnmsg_poll *poll_msg = (void *)preq;
|
||||
struct puffs_node *pn = arg;
|
||||
int revents, error;
|
||||
|
||||
error = checkerr(pmp, preq->preq_rv, __func__);
|
||||
if (error)
|
||||
revents = poll_msg->pvnr_events;
|
||||
else
|
||||
revents = POLLERR;
|
||||
|
||||
mutex_enter(&pn->pn_mtx);
|
||||
pn->pn_revents |= revents;
|
||||
mutex_exit(&pn->pn_mtx);
|
||||
|
||||
selnotify(&pn->pn_sel, revents, 0);
|
||||
|
||||
puffs_releasenode(pn);
|
||||
}
|
||||
|
||||
void
|
||||
puffs_mp_reference(struct puffs_mount *pmp)
|
||||
{
|
||||
|
||||
KASSERT(mutex_owned(&pmp->pmp_lock));
|
||||
pmp->pmp_refcount++;
|
||||
}
|
||||
|
||||
void
|
||||
puffs_mp_release(struct puffs_mount *pmp)
|
||||
{
|
||||
|
||||
KASSERT(mutex_owned(&pmp->pmp_lock));
|
||||
if (--pmp->pmp_refcount == 0)
|
||||
cv_broadcast(&pmp->pmp_refcount_cv);
|
||||
}
|
||||
|
||||
void
|
||||
puffs_gop_size(struct vnode *vp, off_t size, off_t *eobp,
|
||||
int flags)
|
||||
{
|
||||
|
||||
*eobp = size;
|
||||
}
|
||||
|
||||
void
|
||||
puffs_gop_markupdate(struct vnode *vp, int flags)
|
||||
{
|
||||
int uflags = 0;
|
||||
|
||||
if (flags & GOP_UPDATE_ACCESSED)
|
||||
uflags |= PUFFS_UPDATEATIME;
|
||||
if (flags & GOP_UPDATE_MODIFIED)
|
||||
uflags |= PUFFS_UPDATEMTIME;
|
||||
|
||||
puffs_updatenode(VPTOPP(vp), uflags, 0);
|
||||
}
|
||||
|
||||
void
|
||||
puffs_senderr(struct puffs_mount *pmp, int type, int error,
|
||||
const char *str, puffs_cookie_t ck)
|
||||
{
|
||||
struct puffs_msgpark *park;
|
||||
struct puffs_error *perr;
|
||||
|
||||
puffs_msgmem_alloc(sizeof(struct puffs_error), &park, (void *)&perr, 1);
|
||||
puffs_msg_setfaf(park);
|
||||
puffs_msg_setinfo(park, PUFFSOP_ERROR, type, ck);
|
||||
|
||||
perr->perr_error = error;
|
||||
strlcpy(perr->perr_str, str, sizeof(perr->perr_str));
|
||||
|
||||
puffs_msg_enqueue(pmp, park);
|
||||
puffs_msgmem_release(park);
|
||||
}
|
||||
@@ -0,0 +1,365 @@
|
||||
/* $NetBSD: puffs_sys.h,v 1.84 2013/10/17 21:03:27 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
|
||||
*
|
||||
* Development of this software was supported by the
|
||||
* Google Summer of Code program and the Ulla Tuominen Foundation.
|
||||
* The Google SoC project was mentored by Bill Studenmund.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _PUFFS_SYS_H_
|
||||
#define _PUFFS_SYS_H_
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/kauth.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/pool.h>
|
||||
|
||||
#include <fs/puffs/puffs_msgif.h>
|
||||
|
||||
#include <miscfs/genfs/genfs_node.h>
|
||||
|
||||
extern int (**puffs_vnodeop_p)(void *);
|
||||
extern int (**puffs_specop_p)(void *);
|
||||
extern int (**puffs_fifoop_p)(void *);
|
||||
|
||||
extern const struct vnodeopv_desc puffs_vnodeop_opv_desc;
|
||||
extern const struct vnodeopv_desc puffs_specop_opv_desc;
|
||||
extern const struct vnodeopv_desc puffs_fifoop_opv_desc;
|
||||
extern const struct vnodeopv_desc puffs_msgop_opv_desc;
|
||||
|
||||
extern struct pool puffs_pnpool;
|
||||
extern struct pool puffs_vapool;
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifndef PUFFSDEBUG
|
||||
#define PUFFSDEBUG
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PUFFSDEBUG
|
||||
extern int puffsdebug; /* puffs_subr.c */
|
||||
#define DPRINTF(x) if (puffsdebug > 0) printf x
|
||||
#define DPRINTF_VERBOSE(x) if (puffsdebug > 1) printf x
|
||||
#else
|
||||
#define DPRINTF(x)
|
||||
#define DPRINTF_VERBOSE(x)
|
||||
#endif
|
||||
|
||||
#define MPTOPUFFSMP(mp) ((struct puffs_mount *)((mp)->mnt_data))
|
||||
#define PMPTOMP(pmp) (pmp->pmp_mp)
|
||||
#define VPTOPP(vp) ((struct puffs_node *)(vp)->v_data)
|
||||
#define VPTOPNC(vp) (((struct puffs_node *)(vp)->v_data)->pn_cookie)
|
||||
#define VPTOPUFFSMP(vp) ((struct puffs_mount*)((struct puffs_node*)vp->v_data))
|
||||
|
||||
/* we don't pass the kernel overlay to userspace */
|
||||
#define PUFFS_TOFHSIZE(s) ((s)==0 ? (s) : (s)+4)
|
||||
#define PUFFS_FROMFHSIZE(s) ((s)==0 ? (s) : (s)-4)
|
||||
|
||||
#define ALLOPS(pmp) (pmp->pmp_flags & PUFFS_KFLAG_ALLOPS)
|
||||
#define EXISTSOP(pmp, op) \
|
||||
(ALLOPS(pmp) || ((pmp)->pmp_vnopmask[PUFFS_VN_##op]))
|
||||
|
||||
#define PUFFS_USE_NAMECACHE(pmp) \
|
||||
(((pmp)->pmp_flags & PUFFS_KFLAG_NOCACHE_NAME) == 0)
|
||||
#define PUFFS_USE_PAGECACHE(pmp) \
|
||||
(((pmp)->pmp_flags & PUFFS_KFLAG_NOCACHE_PAGE) == 0)
|
||||
#define PUFFS_USE_FULLPNBUF(pmp) \
|
||||
((pmp)->pmp_flags & PUFFS_KFLAG_LOOKUP_FULLPNBUF)
|
||||
#define PUFFS_USE_FS_TTL(pmp) \
|
||||
((pmp)->pmp_flags & PUFFS_KFLAG_CACHE_FS_TTL)
|
||||
#define PUFFS_USE_DOTDOTCACHE(pmp) \
|
||||
((pmp)->pmp_flags & PUFFS_KFLAG_CACHE_DOTDOT)
|
||||
|
||||
#define PUFFS_WCACHEINFO(pmp) (__USE(pmp), 0)
|
||||
|
||||
struct puffs_newcookie {
|
||||
puffs_cookie_t pnc_cookie;
|
||||
|
||||
LIST_ENTRY(puffs_newcookie) pnc_entries;
|
||||
};
|
||||
|
||||
#define PUFFS_SOPREQ_EXPIRE_TIMEOUT 1000
|
||||
extern int puffs_sopreq_expire_timeout;
|
||||
|
||||
enum puffs_sopreqtype {
|
||||
PUFFS_SOPREQSYS_EXIT,
|
||||
PUFFS_SOPREQ_FLUSH,
|
||||
PUFFS_SOPREQ_UNMOUNT,
|
||||
PUFFS_SOPREQ_EXPIRE,
|
||||
};
|
||||
|
||||
struct puffs_sopreq {
|
||||
union {
|
||||
struct puffs_req preq;
|
||||
struct puffs_flush pf;
|
||||
puffs_cookie_t ck;
|
||||
} psopr_u;
|
||||
|
||||
enum puffs_sopreqtype psopr_sopreq;
|
||||
TAILQ_ENTRY(puffs_sopreq) psopr_entries;
|
||||
int psopr_at;
|
||||
};
|
||||
#define psopr_preq psopr_u.preq
|
||||
#define psopr_pf psopr_u.pf
|
||||
#define psopr_ck psopr_u.ck
|
||||
|
||||
TAILQ_HEAD(puffs_wq, puffs_msgpark);
|
||||
LIST_HEAD(puffs_node_hashlist, puffs_node);
|
||||
struct puffs_mount {
|
||||
kmutex_t pmp_lock;
|
||||
|
||||
struct puffs_kargs pmp_args;
|
||||
#define pmp_flags pmp_args.pa_flags
|
||||
#define pmp_vnopmask pmp_args.pa_vnopmask
|
||||
|
||||
struct puffs_wq pmp_msg_touser;
|
||||
int pmp_msg_touser_count;
|
||||
kcondvar_t pmp_msg_waiter_cv;
|
||||
size_t pmp_msg_maxsize;
|
||||
|
||||
struct puffs_wq pmp_msg_replywait;
|
||||
|
||||
struct puffs_node_hashlist *pmp_pnodehash;
|
||||
int pmp_npnodehash;
|
||||
|
||||
/*
|
||||
* a list of cookies which is going to be puffs_getvnode'd.
|
||||
* this is merely a loose attempt to prevent races.
|
||||
*/
|
||||
LIST_HEAD(, puffs_newcookie) pmp_newcookie;
|
||||
|
||||
struct mount *pmp_mp;
|
||||
|
||||
struct vnode *pmp_root;
|
||||
puffs_cookie_t pmp_root_cookie;
|
||||
enum vtype pmp_root_vtype;
|
||||
vsize_t pmp_root_vsize;
|
||||
dev_t pmp_root_rdev;
|
||||
|
||||
struct putter_instance *pmp_pi;
|
||||
|
||||
unsigned int pmp_refcount;
|
||||
kcondvar_t pmp_refcount_cv;
|
||||
|
||||
kcondvar_t pmp_unmounting_cv;
|
||||
uint8_t pmp_unmounting;
|
||||
|
||||
uint8_t pmp_status;
|
||||
uint8_t pmp_suspend;
|
||||
|
||||
uint8_t *pmp_curput;
|
||||
size_t pmp_curres;
|
||||
void *pmp_curopaq;
|
||||
|
||||
uint64_t pmp_nextmsgid;
|
||||
|
||||
kmutex_t pmp_sopmtx;
|
||||
kcondvar_t pmp_sopcv;
|
||||
int pmp_sopthrcount;
|
||||
TAILQ_HEAD(, puffs_sopreq) pmp_sopfastreqs;
|
||||
TAILQ_HEAD(, puffs_sopreq) pmp_sopnodereqs;
|
||||
bool pmp_docompat;
|
||||
};
|
||||
|
||||
#define PUFFSTAT_BEFOREINIT 0
|
||||
#define PUFFSTAT_MOUNTING 1
|
||||
#define PUFFSTAT_RUNNING 2
|
||||
#define PUFFSTAT_DYING 3 /* Do you want your possessions identified? */
|
||||
|
||||
|
||||
#define PNODE_NOREFS 0x001 /* no backend reference */
|
||||
#define PNODE_DYING 0x002 /* NOREFS + inactive */
|
||||
#define PNODE_FAF 0x004 /* issue all operations as FAF */
|
||||
#define PNODE_DOINACT 0x008 /* if inactive-on-demand, call inactive */
|
||||
#define PNODE_SOPEXP 0x100 /* Node reclaim postponed in sop thread */
|
||||
|
||||
#define PNODE_METACACHE_ATIME 0x10 /* cache atime metadata */
|
||||
#define PNODE_METACACHE_CTIME 0x20 /* cache atime metadata */
|
||||
#define PNODE_METACACHE_MTIME 0x40 /* cache atime metadata */
|
||||
#define PNODE_METACACHE_SIZE 0x80 /* cache atime metadata */
|
||||
#define PNODE_METACACHE_MASK 0xf0
|
||||
|
||||
struct puffs_node {
|
||||
struct genfs_node pn_gnode; /* genfs glue */
|
||||
|
||||
kmutex_t pn_mtx;
|
||||
int pn_refcount;
|
||||
int pn_nlookup;
|
||||
|
||||
puffs_cookie_t pn_cookie; /* userspace pnode cookie */
|
||||
struct vnode *pn_vp; /* backpointer to vnode */
|
||||
uint32_t pn_stat; /* node status */
|
||||
|
||||
struct selinfo pn_sel; /* for selecting on the node */
|
||||
short pn_revents; /* available events */
|
||||
|
||||
/* metacache */
|
||||
struct timespec pn_mc_atime;
|
||||
struct timespec pn_mc_ctime;
|
||||
struct timespec pn_mc_mtime;
|
||||
u_quad_t pn_mc_size;
|
||||
|
||||
voff_t pn_serversize;
|
||||
|
||||
struct lockf * pn_lockf;
|
||||
|
||||
kmutex_t pn_sizemtx; /* size modification mutex */
|
||||
|
||||
int pn_cn_timeout; /* path cache */
|
||||
int pn_cn_grace; /* grace time before reclaim */
|
||||
int pn_va_timeout; /* attribute cache */
|
||||
struct vattr * pn_va_cache; /* attribute cache */
|
||||
struct vnode * pn_parent; /* parent cache */
|
||||
|
||||
LIST_ENTRY(puffs_node) pn_hashent;
|
||||
};
|
||||
|
||||
typedef void (*parkdone_fn)(struct puffs_mount *, struct puffs_req *, void *);
|
||||
|
||||
struct puffs_msgpark;
|
||||
void puffs_msgif_init(void);
|
||||
void puffs_msgif_destroy(void);
|
||||
int puffs_msgmem_alloc(size_t, struct puffs_msgpark **, void **, int);
|
||||
void puffs_msgmem_release(struct puffs_msgpark *);
|
||||
|
||||
void puffs_sop_thread(void *);
|
||||
|
||||
void puffs_msg_setfaf(struct puffs_msgpark *);
|
||||
void puffs_msg_setdelta(struct puffs_msgpark *, size_t);
|
||||
void puffs_msg_setinfo(struct puffs_msgpark *, int, int, puffs_cookie_t);
|
||||
void puffs_msg_setcall(struct puffs_msgpark *, parkdone_fn, void *);
|
||||
|
||||
void puffs_msg_enqueue(struct puffs_mount *, struct puffs_msgpark *);
|
||||
int puffs_msg_wait(struct puffs_mount *, struct puffs_msgpark *);
|
||||
int puffs_msg_wait2(struct puffs_mount *, struct puffs_msgpark *,
|
||||
struct puffs_node *, struct puffs_node *);
|
||||
|
||||
void puffs_msg_sendresp(struct puffs_mount *, struct puffs_req *, int);
|
||||
|
||||
int puffs_getvnode(struct mount *, puffs_cookie_t, enum vtype,
|
||||
voff_t, dev_t, struct vnode **);
|
||||
int puffs_newnode(struct mount *, struct vnode *, struct vnode **,
|
||||
puffs_cookie_t, struct componentname *,
|
||||
enum vtype, dev_t);
|
||||
void puffs_putvnode(struct vnode *);
|
||||
|
||||
void puffs_releasenode(struct puffs_node *);
|
||||
void puffs_referencenode(struct puffs_node *);
|
||||
|
||||
#define PUFFS_NOSUCHCOOKIE (-1)
|
||||
int puffs_cookie2vnode(struct puffs_mount *, puffs_cookie_t, int, int,
|
||||
struct vnode **);
|
||||
void puffs_makecn(struct puffs_kcn *, struct puffs_kcred *,
|
||||
const struct componentname *, int);
|
||||
void puffs_credcvt(struct puffs_kcred *, kauth_cred_t);
|
||||
|
||||
void puffs_parkdone_asyncbioread(struct puffs_mount *,
|
||||
struct puffs_req *, void *);
|
||||
void puffs_parkdone_asyncbiowrite(struct puffs_mount *,
|
||||
struct puffs_req *, void *);
|
||||
void puffs_parkdone_poll(struct puffs_mount *, struct puffs_req *, void *);
|
||||
|
||||
void puffs_mp_reference(struct puffs_mount *);
|
||||
void puffs_mp_release(struct puffs_mount *);
|
||||
|
||||
void puffs_gop_size(struct vnode *, off_t, off_t *, int);
|
||||
void puffs_gop_markupdate(struct vnode *, int);
|
||||
|
||||
void puffs_senderr(struct puffs_mount *, int, int, const char *,
|
||||
puffs_cookie_t);
|
||||
|
||||
bool puffs_compat_outgoing(struct puffs_req *, struct puffs_req**, ssize_t*);
|
||||
void puffs_compat_incoming(struct puffs_req *, struct puffs_req *);
|
||||
|
||||
void puffs_updatenode(struct puffs_node *, int, voff_t);
|
||||
#define PUFFS_UPDATEATIME 0x01
|
||||
#define PUFFS_UPDATECTIME 0x02
|
||||
#define PUFFS_UPDATEMTIME 0x04
|
||||
#define PUFFS_UPDATESIZE 0x08
|
||||
|
||||
void puffs_userdead(struct puffs_mount *);
|
||||
|
||||
extern int (**puffs_vnodeop_p)(void *);
|
||||
|
||||
/* for putter */
|
||||
int puffs_msgif_getout(void *, size_t, int, uint8_t **, size_t *, void **);
|
||||
void puffs_msgif_releaseout(void *, void *, int);
|
||||
int puffs_msgif_dispatch(void *, struct putter_hdr *);
|
||||
size_t puffs_msgif_waitcount(void *);
|
||||
int puffs_msgif_close(void *);
|
||||
|
||||
static __inline int
|
||||
checkerr(struct puffs_mount *pmp, int error, const char *str)
|
||||
{
|
||||
|
||||
if (error < 0 || error > ELAST) {
|
||||
puffs_senderr(pmp, PUFFS_ERR_ERROR, error, str, NULL);
|
||||
error = EPROTO;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
#define PUFFS_MSG_VARS(type, a) \
|
||||
struct puffs_##type##msg_##a *a##_msg; \
|
||||
struct puffs_msgpark *park_##a = NULL
|
||||
|
||||
#define PUFFS_MSG_ALLOC(type, a) \
|
||||
puffs_msgmem_alloc(sizeof(struct puffs_##type##msg_##a), \
|
||||
&park_##a, (void *)& a##_msg, 1)
|
||||
|
||||
#define PUFFS_MSG_RELEASE(a) \
|
||||
do { \
|
||||
if (park_##a) puffs_msgmem_release(park_##a); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define PUFFS_MSG_ENQUEUEWAIT_NOERROR(pmp, park) \
|
||||
do { \
|
||||
puffs_msg_enqueue(pmp, park); \
|
||||
puffs_msg_wait(pmp, park); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define PUFFS_MSG_ENQUEUEWAIT2_NOERROR(pmp, park, vp1, vp2) \
|
||||
do { \
|
||||
puffs_msg_enqueue(pmp, park); \
|
||||
puffs_msg_wait2(pmp, park, vp1, vp2); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define PUFFS_MSG_ENQUEUEWAIT(pmp, park, var) \
|
||||
do { \
|
||||
puffs_msg_enqueue(pmp, park); \
|
||||
var = puffs_msg_wait(pmp, park); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define PUFFS_MSG_ENQUEUEWAIT2(pmp, park, vp1, vp2, var) \
|
||||
do { \
|
||||
puffs_msg_enqueue(pmp, park); \
|
||||
var = puffs_msg_wait2(pmp, park, vp1, vp2); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#endif /* _PUFFS_SYS_H_ */
|
||||
@@ -0,0 +1,887 @@
|
||||
/* $NetBSD: puffs_vfsops.c,v 1.107 2013/01/16 21:10:14 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
|
||||
*
|
||||
* Development of this software was supported by the
|
||||
* Google Summer of Code program and the Ulla Tuominen Foundation.
|
||||
* The Google SoC project was mentored by Bill Studenmund.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.107 2013/01/16 21:10:14 pooka Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/extattr.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/dirent.h>
|
||||
#include <sys/kauth.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/kthread.h>
|
||||
|
||||
#include <uvm/uvm.h>
|
||||
|
||||
#include <dev/putter/putter_sys.h>
|
||||
|
||||
#include <miscfs/genfs/genfs.h>
|
||||
|
||||
#include <fs/puffs/puffs_msgif.h>
|
||||
#include <fs/puffs/puffs_sys.h>
|
||||
|
||||
#include <lib/libkern/libkern.h>
|
||||
|
||||
#include <nfs/nfsproto.h> /* for fh sizes */
|
||||
|
||||
MODULE(MODULE_CLASS_VFS, puffs, "putter");
|
||||
|
||||
VFS_PROTOS(puffs_vfsop);
|
||||
|
||||
#ifndef PUFFS_PNODEBUCKETS
|
||||
#define PUFFS_PNODEBUCKETS 256
|
||||
#endif
|
||||
#ifndef PUFFS_MAXPNODEBUCKETS
|
||||
#define PUFFS_MAXPNODEBUCKETS 8192
|
||||
#endif
|
||||
int puffs_pnodebuckets_default = PUFFS_PNODEBUCKETS;
|
||||
int puffs_maxpnodebuckets = PUFFS_MAXPNODEBUCKETS;
|
||||
|
||||
#define BUCKETALLOC(a) (sizeof(struct puffs_pnode_hashlist *) * (a))
|
||||
|
||||
static struct putter_ops puffs_putter = {
|
||||
.pop_getout = puffs_msgif_getout,
|
||||
.pop_releaseout = puffs_msgif_releaseout,
|
||||
.pop_waitcount = puffs_msgif_waitcount,
|
||||
.pop_dispatch = puffs_msgif_dispatch,
|
||||
.pop_close = puffs_msgif_close,
|
||||
};
|
||||
|
||||
/*
|
||||
* Try to ensure data structures used by the puffs protocol
|
||||
* do not unexpectedly change.
|
||||
*/
|
||||
#if defined(__i386__) && defined(__ELF__)
|
||||
CTASSERT(sizeof(struct puffs_kargs) == 3928);
|
||||
CTASSERT(sizeof(struct vattr) == 136);
|
||||
CTASSERT(sizeof(struct puffs_req) == 44);
|
||||
#endif
|
||||
|
||||
int
|
||||
puffs_vfsop_mount(struct mount *mp, const char *path, void *data,
|
||||
size_t *data_len)
|
||||
{
|
||||
struct puffs_mount *pmp = NULL;
|
||||
struct puffs_kargs *args;
|
||||
char fstype[_VFS_NAMELEN];
|
||||
char *p;
|
||||
int error = 0, i;
|
||||
pid_t mntpid = curlwp->l_proc->p_pid;
|
||||
|
||||
if (*data_len < sizeof *args)
|
||||
return EINVAL;
|
||||
|
||||
if (mp->mnt_flag & MNT_GETARGS) {
|
||||
pmp = MPTOPUFFSMP(mp);
|
||||
*(struct puffs_kargs *)data = pmp->pmp_args;
|
||||
*data_len = sizeof *args;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* update is not supported currently */
|
||||
if (mp->mnt_flag & MNT_UPDATE)
|
||||
return EOPNOTSUPP;
|
||||
|
||||
/*
|
||||
* We need the file system name
|
||||
*/
|
||||
if (!data)
|
||||
return EINVAL;
|
||||
|
||||
args = (struct puffs_kargs *)data;
|
||||
|
||||
if (args->pa_vers != PUFFSVERSION) {
|
||||
printf("puffs_mount: development version mismatch: "
|
||||
"kernel %d, lib %d\n", PUFFSVERSION, args->pa_vers);
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((args->pa_flags & ~PUFFS_KFLAG_MASK) != 0) {
|
||||
printf("puffs_mount: invalid KFLAGs 0x%x\n", args->pa_flags);
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if ((args->pa_fhflags & ~PUFFS_FHFLAG_MASK) != 0) {
|
||||
printf("puffs_mount: invalid FHFLAGs 0x%x\n", args->pa_fhflags);
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (i = 0; i < __arraycount(args->pa_spare); i++) {
|
||||
if (args->pa_spare[i] != 0) {
|
||||
printf("puffs_mount: pa_spare[%d] = 0x%x\n",
|
||||
i, args->pa_spare[i]);
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* use dummy value for passthrough */
|
||||
if (args->pa_fhflags & PUFFS_FHFLAG_PASSTHROUGH)
|
||||
args->pa_fhsize = sizeof(struct fid);
|
||||
|
||||
/* sanitize file handle length */
|
||||
if (PUFFS_TOFHSIZE(args->pa_fhsize) > FHANDLE_SIZE_MAX) {
|
||||
printf("puffs_mount: handle size %zu too large\n",
|
||||
args->pa_fhsize);
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
/* sanity check file handle max sizes */
|
||||
if (args->pa_fhsize && args->pa_fhflags & PUFFS_FHFLAG_PROTOMASK) {
|
||||
size_t kfhsize = PUFFS_TOFHSIZE(args->pa_fhsize);
|
||||
|
||||
if (args->pa_fhflags & PUFFS_FHFLAG_NFSV2) {
|
||||
if (NFSX_FHTOOBIG_P(kfhsize, 0)) {
|
||||
printf("puffs_mount: fhsize larger than "
|
||||
"NFSv2 max %d\n",
|
||||
PUFFS_FROMFHSIZE(NFSX_V2FH));
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if (args->pa_fhflags & PUFFS_FHFLAG_NFSV3) {
|
||||
if (NFSX_FHTOOBIG_P(kfhsize, 1)) {
|
||||
printf("puffs_mount: fhsize larger than "
|
||||
"NFSv3 max %d\n",
|
||||
PUFFS_FROMFHSIZE(NFSX_V3FHMAX));
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* don't allow non-printing characters (like my sweet umlauts.. snif) */
|
||||
args->pa_typename[sizeof(args->pa_typename)-1] = '\0';
|
||||
for (p = args->pa_typename; *p; p++)
|
||||
if (*p < ' ' || *p > '~')
|
||||
*p = '.';
|
||||
|
||||
args->pa_mntfromname[sizeof(args->pa_mntfromname)-1] = '\0';
|
||||
for (p = args->pa_mntfromname; *p; p++)
|
||||
if (*p < ' ' || *p > '~')
|
||||
*p = '.';
|
||||
|
||||
/* build real name */
|
||||
(void)strlcpy(fstype, PUFFS_TYPEPREFIX, sizeof(fstype));
|
||||
(void)strlcat(fstype, args->pa_typename, sizeof(fstype));
|
||||
|
||||
/* inform user server if it got the max request size it wanted */
|
||||
if (args->pa_maxmsglen == 0 || args->pa_maxmsglen > PUFFS_MSG_MAXSIZE)
|
||||
args->pa_maxmsglen = PUFFS_MSG_MAXSIZE;
|
||||
else if (args->pa_maxmsglen < 2*PUFFS_MSGSTRUCT_MAX)
|
||||
args->pa_maxmsglen = 2*PUFFS_MSGSTRUCT_MAX;
|
||||
|
||||
(void)strlcpy(args->pa_typename, fstype, sizeof(args->pa_typename));
|
||||
|
||||
if (args->pa_nhashbuckets == 0)
|
||||
args->pa_nhashbuckets = puffs_pnodebuckets_default;
|
||||
if (args->pa_nhashbuckets < 1)
|
||||
args->pa_nhashbuckets = 1;
|
||||
if (args->pa_nhashbuckets > PUFFS_MAXPNODEBUCKETS) {
|
||||
args->pa_nhashbuckets = puffs_maxpnodebuckets;
|
||||
printf("puffs_mount: using %d hash buckets. "
|
||||
"adjust puffs_maxpnodebuckets for more\n",
|
||||
puffs_maxpnodebuckets);
|
||||
}
|
||||
|
||||
error = set_statvfs_info(path, UIO_USERSPACE, args->pa_mntfromname,
|
||||
UIO_SYSSPACE, fstype, mp, curlwp);
|
||||
if (error)
|
||||
goto out;
|
||||
mp->mnt_stat.f_iosize = DEV_BSIZE;
|
||||
mp->mnt_stat.f_namemax = args->pa_svfsb.f_namemax;
|
||||
|
||||
/*
|
||||
* We can't handle the VFS_STATVFS() mount_domount() does
|
||||
* after VFS_MOUNT() because we'd deadlock, so handle it
|
||||
* here already.
|
||||
*/
|
||||
copy_statvfs_info(&args->pa_svfsb, mp);
|
||||
(void)memcpy(&mp->mnt_stat, &args->pa_svfsb, sizeof(mp->mnt_stat));
|
||||
|
||||
KASSERT(curlwp != uvm.pagedaemon_lwp);
|
||||
pmp = kmem_zalloc(sizeof(struct puffs_mount), KM_SLEEP);
|
||||
|
||||
mp->mnt_fs_bshift = DEV_BSHIFT;
|
||||
mp->mnt_dev_bshift = DEV_BSHIFT;
|
||||
mp->mnt_flag &= ~MNT_LOCAL; /* we don't really know, so ... */
|
||||
mp->mnt_data = pmp;
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* XXX: puffs code is MPSAFE. However, VFS really isn't.
|
||||
* Currently, there is nothing which protects an inode from
|
||||
* reclaim while there are threads inside the file system.
|
||||
* This means that in the event of a server crash, an MPSAFE
|
||||
* mount is likely to end up accessing invalid memory. For the
|
||||
* non-mpsafe case, the kernel lock, general structure of
|
||||
* puffs and pmp_refcount protect the threads during escape.
|
||||
*
|
||||
* Fixing this will require:
|
||||
* a) fixing vfs
|
||||
* OR
|
||||
* b) adding a small sleep to puffs_msgif_close() between
|
||||
* userdead() and dounmount().
|
||||
* (well, this isn't really a fix, but would solve
|
||||
* 99.999% of the race conditions).
|
||||
*
|
||||
* Also, in the event of "b", unmount -f should be used,
|
||||
* like with any other file system, sparingly and only when
|
||||
* it is "known" to be safe.
|
||||
*/
|
||||
mp->mnt_iflags |= IMNT_MPSAFE;
|
||||
#endif
|
||||
|
||||
pmp->pmp_status = PUFFSTAT_MOUNTING;
|
||||
pmp->pmp_mp = mp;
|
||||
pmp->pmp_msg_maxsize = args->pa_maxmsglen;
|
||||
pmp->pmp_args = *args;
|
||||
|
||||
pmp->pmp_npnodehash = args->pa_nhashbuckets;
|
||||
pmp->pmp_pnodehash = kmem_alloc(BUCKETALLOC(pmp->pmp_npnodehash),
|
||||
KM_SLEEP);
|
||||
for (i = 0; i < pmp->pmp_npnodehash; i++)
|
||||
LIST_INIT(&pmp->pmp_pnodehash[i]);
|
||||
LIST_INIT(&pmp->pmp_newcookie);
|
||||
|
||||
/*
|
||||
* Inform the fileops processing code that we have a mountpoint.
|
||||
* If it doesn't know about anyone with our pid/fd having the
|
||||
* device open, punt
|
||||
*/
|
||||
if ((pmp->pmp_pi
|
||||
= putter_attach(mntpid, args->pa_fd, pmp, &puffs_putter)) == NULL) {
|
||||
error = ENOENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* XXX: check parameters */
|
||||
pmp->pmp_root_cookie = args->pa_root_cookie;
|
||||
pmp->pmp_root_vtype = args->pa_root_vtype;
|
||||
pmp->pmp_root_vsize = args->pa_root_vsize;
|
||||
pmp->pmp_root_rdev = args->pa_root_rdev;
|
||||
pmp->pmp_docompat = args->pa_time32;
|
||||
|
||||
mutex_init(&pmp->pmp_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
mutex_init(&pmp->pmp_sopmtx, MUTEX_DEFAULT, IPL_NONE);
|
||||
cv_init(&pmp->pmp_msg_waiter_cv, "puffsget");
|
||||
cv_init(&pmp->pmp_refcount_cv, "puffsref");
|
||||
cv_init(&pmp->pmp_unmounting_cv, "puffsum");
|
||||
cv_init(&pmp->pmp_sopcv, "puffsop");
|
||||
TAILQ_INIT(&pmp->pmp_msg_touser);
|
||||
TAILQ_INIT(&pmp->pmp_msg_replywait);
|
||||
TAILQ_INIT(&pmp->pmp_sopfastreqs);
|
||||
TAILQ_INIT(&pmp->pmp_sopnodereqs);
|
||||
|
||||
if ((error = kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL,
|
||||
puffs_sop_thread, pmp, NULL, "puffsop")) != 0)
|
||||
goto out;
|
||||
pmp->pmp_sopthrcount = 1;
|
||||
|
||||
DPRINTF(("puffs_mount: mount point at %p, puffs specific at %p\n",
|
||||
mp, MPTOPUFFSMP(mp)));
|
||||
|
||||
vfs_getnewfsid(mp);
|
||||
|
||||
out:
|
||||
if (error && pmp && pmp->pmp_pi)
|
||||
putter_detach(pmp->pmp_pi);
|
||||
if (error && pmp && pmp->pmp_pnodehash)
|
||||
kmem_free(pmp->pmp_pnodehash, BUCKETALLOC(pmp->pmp_npnodehash));
|
||||
if (error && pmp)
|
||||
kmem_free(pmp, sizeof(struct puffs_mount));
|
||||
return error;
|
||||
}
|
||||
|
||||
int
|
||||
puffs_vfsop_start(struct mount *mp, int flags)
|
||||
{
|
||||
struct puffs_mount *pmp = MPTOPUFFSMP(mp);
|
||||
|
||||
KASSERT(pmp->pmp_status == PUFFSTAT_MOUNTING);
|
||||
pmp->pmp_status = PUFFSTAT_RUNNING;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
puffs_vfsop_unmount(struct mount *mp, int mntflags)
|
||||
{
|
||||
PUFFS_MSG_VARS(vfs, unmount);
|
||||
struct puffs_mount *pmp;
|
||||
int error, force;
|
||||
|
||||
error = 0;
|
||||
force = mntflags & MNT_FORCE;
|
||||
pmp = MPTOPUFFSMP(mp);
|
||||
|
||||
DPRINTF(("puffs_unmount: detach filesystem from vfs, current "
|
||||
"status 0x%x\n", pmp->pmp_status));
|
||||
|
||||
/*
|
||||
* flush all the vnodes. VOP_RECLAIM() takes care that the
|
||||
* root vnode does not get flushed until unmount. The
|
||||
* userspace root node cookie is stored in the mount
|
||||
* structure, so we can always re-instantiate a root vnode,
|
||||
* should userspace unmount decide it doesn't want to
|
||||
* cooperate.
|
||||
*/
|
||||
error = vflush(mp, NULLVP, force ? FORCECLOSE : 0);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* If we are not DYING, we should ask userspace's opinion
|
||||
* about the situation
|
||||
*/
|
||||
mutex_enter(&pmp->pmp_lock);
|
||||
if (pmp->pmp_status != PUFFSTAT_DYING) {
|
||||
pmp->pmp_unmounting = 1;
|
||||
mutex_exit(&pmp->pmp_lock);
|
||||
|
||||
PUFFS_MSG_ALLOC(vfs, unmount);
|
||||
puffs_msg_setinfo(park_unmount,
|
||||
PUFFSOP_VFS, PUFFS_VFS_UNMOUNT, NULL);
|
||||
unmount_msg->pvfsr_flags = mntflags;
|
||||
|
||||
PUFFS_MSG_ENQUEUEWAIT(pmp, park_unmount, error);
|
||||
PUFFS_MSG_RELEASE(unmount);
|
||||
|
||||
error = checkerr(pmp, error, __func__);
|
||||
DPRINTF(("puffs_unmount: error %d force %d\n", error, force));
|
||||
|
||||
mutex_enter(&pmp->pmp_lock);
|
||||
pmp->pmp_unmounting = 0;
|
||||
cv_broadcast(&pmp->pmp_unmounting_cv);
|
||||
}
|
||||
|
||||
/*
|
||||
* if userspace cooperated or we really need to die,
|
||||
* screw what userland thinks and just die.
|
||||
*/
|
||||
if (error == 0 || force) {
|
||||
struct puffs_sopreq *psopr;
|
||||
|
||||
/* tell waiters & other resources to go unwait themselves */
|
||||
puffs_userdead(pmp);
|
||||
putter_detach(pmp->pmp_pi);
|
||||
|
||||
/*
|
||||
* Wait until there are no more users for the mount resource.
|
||||
* Notice that this is hooked against transport_close
|
||||
* and return from touser. In an ideal world, it would
|
||||
* be hooked against final return from all operations.
|
||||
* But currently it works well enough, since nobody
|
||||
* does weird blocking voodoo after return from touser().
|
||||
*/
|
||||
while (pmp->pmp_refcount != 0)
|
||||
cv_wait(&pmp->pmp_refcount_cv, &pmp->pmp_lock);
|
||||
mutex_exit(&pmp->pmp_lock);
|
||||
|
||||
/*
|
||||
* Release kernel thread now that there is nothing
|
||||
* it would be wanting to lock.
|
||||
*/
|
||||
KASSERT(curlwp != uvm.pagedaemon_lwp);
|
||||
psopr = kmem_alloc(sizeof(*psopr), KM_SLEEP);
|
||||
psopr->psopr_sopreq = PUFFS_SOPREQSYS_EXIT;
|
||||
mutex_enter(&pmp->pmp_sopmtx);
|
||||
if (pmp->pmp_sopthrcount == 0) {
|
||||
mutex_exit(&pmp->pmp_sopmtx);
|
||||
kmem_free(psopr, sizeof(*psopr));
|
||||
mutex_enter(&pmp->pmp_sopmtx);
|
||||
KASSERT(pmp->pmp_sopthrcount == 0);
|
||||
} else {
|
||||
TAILQ_INSERT_TAIL(&pmp->pmp_sopfastreqs,
|
||||
psopr, psopr_entries);
|
||||
cv_signal(&pmp->pmp_sopcv);
|
||||
}
|
||||
while (pmp->pmp_sopthrcount > 0)
|
||||
cv_wait(&pmp->pmp_sopcv, &pmp->pmp_sopmtx);
|
||||
mutex_exit(&pmp->pmp_sopmtx);
|
||||
|
||||
/* free resources now that we hopefully have no waiters left */
|
||||
cv_destroy(&pmp->pmp_unmounting_cv);
|
||||
cv_destroy(&pmp->pmp_refcount_cv);
|
||||
cv_destroy(&pmp->pmp_msg_waiter_cv);
|
||||
cv_destroy(&pmp->pmp_sopcv);
|
||||
mutex_destroy(&pmp->pmp_lock);
|
||||
mutex_destroy(&pmp->pmp_sopmtx);
|
||||
|
||||
kmem_free(pmp->pmp_pnodehash, BUCKETALLOC(pmp->pmp_npnodehash));
|
||||
kmem_free(pmp, sizeof(struct puffs_mount));
|
||||
error = 0;
|
||||
} else {
|
||||
mutex_exit(&pmp->pmp_lock);
|
||||
}
|
||||
|
||||
out:
|
||||
DPRINTF(("puffs_unmount: return %d\n", error));
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* This doesn't need to travel to userspace
|
||||
*/
|
||||
int
|
||||
puffs_vfsop_root(struct mount *mp, struct vnode **vpp)
|
||||
{
|
||||
struct puffs_mount *pmp = MPTOPUFFSMP(mp);
|
||||
int rv;
|
||||
|
||||
rv = puffs_cookie2vnode(pmp, pmp->pmp_root_cookie, 1, 1, vpp);
|
||||
KASSERT(rv != PUFFS_NOSUCHCOOKIE);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
puffs_vfsop_statvfs(struct mount *mp, struct statvfs *sbp)
|
||||
{
|
||||
PUFFS_MSG_VARS(vfs, statvfs);
|
||||
struct puffs_mount *pmp;
|
||||
int error = 0;
|
||||
|
||||
pmp = MPTOPUFFSMP(mp);
|
||||
|
||||
/*
|
||||
* If we are mounting, it means that the userspace counterpart
|
||||
* is calling mount(2), but mount(2) also calls statvfs. So
|
||||
* requesting statvfs from userspace would mean a deadlock.
|
||||
* Compensate.
|
||||
*/
|
||||
if (__predict_false(pmp->pmp_status == PUFFSTAT_MOUNTING))
|
||||
return EINPROGRESS;
|
||||
|
||||
PUFFS_MSG_ALLOC(vfs, statvfs);
|
||||
puffs_msg_setinfo(park_statvfs, PUFFSOP_VFS, PUFFS_VFS_STATVFS, NULL);
|
||||
|
||||
PUFFS_MSG_ENQUEUEWAIT(pmp, park_statvfs, error);
|
||||
error = checkerr(pmp, error, __func__);
|
||||
statvfs_msg->pvfsr_sb.f_iosize = DEV_BSIZE;
|
||||
|
||||
/*
|
||||
* Try to produce a sensible result even in the event
|
||||
* of userspace error.
|
||||
*
|
||||
* XXX: cache the copy in non-error case
|
||||
*/
|
||||
if (!error) {
|
||||
copy_statvfs_info(&statvfs_msg->pvfsr_sb, mp);
|
||||
(void)memcpy(sbp, &statvfs_msg->pvfsr_sb,
|
||||
sizeof(struct statvfs));
|
||||
} else {
|
||||
copy_statvfs_info(sbp, mp);
|
||||
}
|
||||
|
||||
PUFFS_MSG_RELEASE(statvfs);
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
pageflush(struct mount *mp, kauth_cred_t cred, int waitfor)
|
||||
{
|
||||
struct puffs_node *pn;
|
||||
struct vnode *vp, *mvp;
|
||||
int error, rv, fsyncwait;
|
||||
|
||||
error = 0;
|
||||
fsyncwait = (waitfor == MNT_WAIT) ? FSYNC_WAIT : 0;
|
||||
|
||||
/* Allocate a marker vnode. */
|
||||
mvp = vnalloc(mp);
|
||||
|
||||
/*
|
||||
* Sync all cached data from regular vnodes (which are not
|
||||
* currently locked, see below). After this we call VFS_SYNC
|
||||
* for the fs server, which should handle data and metadata for
|
||||
* all the nodes it knows to exist.
|
||||
*/
|
||||
mutex_enter(&mntvnode_lock);
|
||||
loop:
|
||||
for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); vp; vp = vunmark(mvp)) {
|
||||
vmark(mvp, vp);
|
||||
if (vp->v_mount != mp || vismarker(vp))
|
||||
continue;
|
||||
|
||||
mutex_enter(vp->v_interlock);
|
||||
pn = VPTOPP(vp);
|
||||
if (vp->v_type != VREG || UVM_OBJ_IS_CLEAN(&vp->v_uobj)) {
|
||||
mutex_exit(vp->v_interlock);
|
||||
continue;
|
||||
}
|
||||
|
||||
mutex_exit(&mntvnode_lock);
|
||||
|
||||
/*
|
||||
* Here we try to get a reference to the vnode and to
|
||||
* lock it. This is mostly cargo-culted, but I will
|
||||
* offer an explanation to why I believe this might
|
||||
* actually do the right thing.
|
||||
*
|
||||
* If the vnode is a goner, we quite obviously don't need
|
||||
* to sync it.
|
||||
*
|
||||
* If the vnode was busy, we don't need to sync it because
|
||||
* this is never called with MNT_WAIT except from
|
||||
* dounmount(), when we are wait-flushing all the dirty
|
||||
* vnodes through other routes in any case. So there,
|
||||
* sync() doesn't actually sync. Happy now?
|
||||
*/
|
||||
rv = vget(vp, LK_EXCLUSIVE | LK_NOWAIT);
|
||||
if (rv) {
|
||||
mutex_enter(&mntvnode_lock);
|
||||
if (rv == ENOENT) {
|
||||
(void)vunmark(mvp);
|
||||
goto loop;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* hmm.. is the FAF thing entirely sensible? */
|
||||
if (waitfor == MNT_LAZY) {
|
||||
mutex_enter(vp->v_interlock);
|
||||
pn->pn_stat |= PNODE_FAF;
|
||||
mutex_exit(vp->v_interlock);
|
||||
}
|
||||
rv = VOP_FSYNC(vp, cred, fsyncwait, 0, 0);
|
||||
if (waitfor == MNT_LAZY) {
|
||||
mutex_enter(vp->v_interlock);
|
||||
pn->pn_stat &= ~PNODE_FAF;
|
||||
mutex_exit(vp->v_interlock);
|
||||
}
|
||||
if (rv)
|
||||
error = rv;
|
||||
vput(vp);
|
||||
mutex_enter(&mntvnode_lock);
|
||||
}
|
||||
mutex_exit(&mntvnode_lock);
|
||||
vnfree(mvp);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int
|
||||
puffs_vfsop_sync(struct mount *mp, int waitfor, struct kauth_cred *cred)
|
||||
{
|
||||
PUFFS_MSG_VARS(vfs, sync);
|
||||
struct puffs_mount *pmp = MPTOPUFFSMP(mp);
|
||||
int error, rv;
|
||||
|
||||
error = pageflush(mp, cred, waitfor);
|
||||
|
||||
/* sync fs */
|
||||
PUFFS_MSG_ALLOC(vfs, sync);
|
||||
sync_msg->pvfsr_waitfor = waitfor;
|
||||
puffs_credcvt(&sync_msg->pvfsr_cred, cred);
|
||||
puffs_msg_setinfo(park_sync, PUFFSOP_VFS, PUFFS_VFS_SYNC, NULL);
|
||||
|
||||
PUFFS_MSG_ENQUEUEWAIT(pmp, park_sync, rv);
|
||||
rv = checkerr(pmp, rv, __func__);
|
||||
if (rv)
|
||||
error = rv;
|
||||
|
||||
PUFFS_MSG_RELEASE(sync);
|
||||
return error;
|
||||
}
|
||||
|
||||
int
|
||||
puffs_vfsop_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
|
||||
{
|
||||
PUFFS_MSG_VARS(vfs, fhtonode);
|
||||
struct puffs_mount *pmp = MPTOPUFFSMP(mp);
|
||||
struct vnode *vp;
|
||||
void *fhdata;
|
||||
size_t argsize, fhlen;
|
||||
int error;
|
||||
|
||||
if (pmp->pmp_args.pa_fhsize == 0)
|
||||
return EOPNOTSUPP;
|
||||
|
||||
if (pmp->pmp_args.pa_fhflags & PUFFS_FHFLAG_PASSTHROUGH) {
|
||||
fhlen = fhp->fid_len;
|
||||
fhdata = fhp;
|
||||
} else {
|
||||
fhlen = PUFFS_FROMFHSIZE(fhp->fid_len);
|
||||
fhdata = fhp->fid_data;
|
||||
|
||||
if (pmp->pmp_args.pa_fhflags & PUFFS_FHFLAG_DYNAMIC) {
|
||||
if (pmp->pmp_args.pa_fhsize < fhlen)
|
||||
return EINVAL;
|
||||
} else {
|
||||
if (pmp->pmp_args.pa_fhsize != fhlen)
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
argsize = sizeof(struct puffs_vfsmsg_fhtonode) + fhlen;
|
||||
puffs_msgmem_alloc(argsize, &park_fhtonode, (void *)&fhtonode_msg, 1);
|
||||
fhtonode_msg->pvfsr_dsize = fhlen;
|
||||
memcpy(fhtonode_msg->pvfsr_data, fhdata, fhlen);
|
||||
puffs_msg_setinfo(park_fhtonode, PUFFSOP_VFS, PUFFS_VFS_FHTOVP, NULL);
|
||||
|
||||
PUFFS_MSG_ENQUEUEWAIT(pmp, park_fhtonode, error);
|
||||
error = checkerr(pmp, error, __func__);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
error = puffs_cookie2vnode(pmp, fhtonode_msg->pvfsr_fhcookie, 1,1,&vp);
|
||||
DPRINTF(("puffs_fhtovp: got cookie %p, existing vnode %p\n",
|
||||
fhtonode_msg->pvfsr_fhcookie, vp));
|
||||
if (error == PUFFS_NOSUCHCOOKIE) {
|
||||
error = puffs_getvnode(mp, fhtonode_msg->pvfsr_fhcookie,
|
||||
fhtonode_msg->pvfsr_vtype, fhtonode_msg->pvfsr_size,
|
||||
fhtonode_msg->pvfsr_rdev, &vp);
|
||||
if (error)
|
||||
goto out;
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
} else if (error) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
*vpp = vp;
|
||||
out:
|
||||
puffs_msgmem_release(park_fhtonode);
|
||||
return error;
|
||||
}
|
||||
|
||||
int
|
||||
puffs_vfsop_vptofh(struct vnode *vp, struct fid *fhp, size_t *fh_size)
|
||||
{
|
||||
PUFFS_MSG_VARS(vfs, nodetofh);
|
||||
struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount);
|
||||
size_t argsize, fhlen;
|
||||
int error;
|
||||
|
||||
if (pmp->pmp_args.pa_fhsize == 0)
|
||||
return EOPNOTSUPP;
|
||||
|
||||
/* if file handles are static len, we can test len immediately */
|
||||
if (((pmp->pmp_args.pa_fhflags & PUFFS_FHFLAG_DYNAMIC) == 0)
|
||||
&& ((pmp->pmp_args.pa_fhflags & PUFFS_FHFLAG_PASSTHROUGH) == 0)
|
||||
&& (PUFFS_FROMFHSIZE(*fh_size) < pmp->pmp_args.pa_fhsize)) {
|
||||
*fh_size = PUFFS_TOFHSIZE(pmp->pmp_args.pa_fhsize);
|
||||
return E2BIG;
|
||||
}
|
||||
|
||||
if (pmp->pmp_args.pa_fhflags & PUFFS_FHFLAG_PASSTHROUGH)
|
||||
fhlen = *fh_size;
|
||||
else
|
||||
fhlen = PUFFS_FROMFHSIZE(*fh_size);
|
||||
|
||||
argsize = sizeof(struct puffs_vfsmsg_nodetofh) + fhlen;
|
||||
puffs_msgmem_alloc(argsize, &park_nodetofh, (void *)&nodetofh_msg, 1);
|
||||
nodetofh_msg->pvfsr_fhcookie = VPTOPNC(vp);
|
||||
nodetofh_msg->pvfsr_dsize = fhlen;
|
||||
puffs_msg_setinfo(park_nodetofh, PUFFSOP_VFS, PUFFS_VFS_VPTOFH, NULL);
|
||||
|
||||
PUFFS_MSG_ENQUEUEWAIT(pmp, park_nodetofh, error);
|
||||
error = checkerr(pmp, error, __func__);
|
||||
|
||||
if (pmp->pmp_args.pa_fhflags & PUFFS_FHFLAG_PASSTHROUGH)
|
||||
fhlen = nodetofh_msg->pvfsr_dsize;
|
||||
else if (pmp->pmp_args.pa_fhflags & PUFFS_FHFLAG_DYNAMIC)
|
||||
fhlen = PUFFS_TOFHSIZE(nodetofh_msg->pvfsr_dsize);
|
||||
else
|
||||
fhlen = PUFFS_TOFHSIZE(pmp->pmp_args.pa_fhsize);
|
||||
|
||||
if (error) {
|
||||
if (error == E2BIG)
|
||||
*fh_size = fhlen;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (fhlen > FHANDLE_SIZE_MAX) {
|
||||
puffs_senderr(pmp, PUFFS_ERR_VPTOFH, E2BIG,
|
||||
"file handle too big", VPTOPNC(vp));
|
||||
error = EPROTO;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (*fh_size < fhlen) {
|
||||
*fh_size = fhlen;
|
||||
error = E2BIG;
|
||||
goto out;
|
||||
}
|
||||
*fh_size = fhlen;
|
||||
|
||||
if (fhp) {
|
||||
if (pmp->pmp_args.pa_fhflags & PUFFS_FHFLAG_PASSTHROUGH) {
|
||||
memcpy(fhp, nodetofh_msg->pvfsr_data, fhlen);
|
||||
} else {
|
||||
fhp->fid_len = *fh_size;
|
||||
memcpy(fhp->fid_data, nodetofh_msg->pvfsr_data,
|
||||
nodetofh_msg->pvfsr_dsize);
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
puffs_msgmem_release(park_nodetofh);
|
||||
return error;
|
||||
}
|
||||
|
||||
void
|
||||
puffs_vfsop_init(void)
|
||||
{
|
||||
|
||||
/* some checks depend on this */
|
||||
KASSERT(VNOVAL == VSIZENOTSET);
|
||||
|
||||
pool_init(&puffs_pnpool, sizeof(struct puffs_node), 0, 0, 0,
|
||||
"puffpnpl", &pool_allocator_nointr, IPL_NONE);
|
||||
pool_init(&puffs_vapool, sizeof(struct vattr), 0, 0, 0,
|
||||
"puffvapl", &pool_allocator_nointr, IPL_NONE);
|
||||
puffs_msgif_init();
|
||||
}
|
||||
|
||||
void
|
||||
puffs_vfsop_done(void)
|
||||
{
|
||||
|
||||
puffs_msgif_destroy();
|
||||
pool_destroy(&puffs_pnpool);
|
||||
pool_destroy(&puffs_vapool);
|
||||
}
|
||||
|
||||
int
|
||||
puffs_vfsop_snapshot(struct mount *mp, struct vnode *vp, struct timespec *ts)
|
||||
{
|
||||
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
int
|
||||
puffs_vfsop_extattrctl(struct mount *mp, int cmd, struct vnode *vp,
|
||||
int attrnamespace, const char *attrname)
|
||||
{
|
||||
PUFFS_MSG_VARS(vfs, extattrctl);
|
||||
struct puffs_mount *pmp = MPTOPUFFSMP(mp);
|
||||
struct puffs_node *pnp;
|
||||
puffs_cookie_t pnc;
|
||||
int error, flags;
|
||||
|
||||
if (vp) {
|
||||
/* doesn't make sense for puffs servers */
|
||||
if (vp->v_mount != mp)
|
||||
return EXDEV;
|
||||
pnp = vp->v_data;
|
||||
pnc = pnp->pn_cookie;
|
||||
flags = PUFFS_EXTATTRCTL_HASNODE;
|
||||
} else {
|
||||
pnp = pnc = NULL;
|
||||
flags = 0;
|
||||
}
|
||||
|
||||
PUFFS_MSG_ALLOC(vfs, extattrctl);
|
||||
extattrctl_msg->pvfsr_cmd = cmd;
|
||||
extattrctl_msg->pvfsr_attrnamespace = attrnamespace;
|
||||
extattrctl_msg->pvfsr_flags = flags;
|
||||
if (attrname) {
|
||||
strlcpy(extattrctl_msg->pvfsr_attrname, attrname,
|
||||
sizeof(extattrctl_msg->pvfsr_attrname));
|
||||
extattrctl_msg->pvfsr_flags |= PUFFS_EXTATTRCTL_HASATTRNAME;
|
||||
}
|
||||
puffs_msg_setinfo(park_extattrctl,
|
||||
PUFFSOP_VFS, PUFFS_VFS_EXTATTRCTL, pnc);
|
||||
|
||||
puffs_msg_enqueue(pmp, park_extattrctl);
|
||||
if (vp) {
|
||||
mutex_enter(&pnp->pn_mtx);
|
||||
puffs_referencenode(pnp);
|
||||
mutex_exit(&pnp->pn_mtx);
|
||||
VOP_UNLOCK(vp);
|
||||
}
|
||||
error = puffs_msg_wait2(pmp, park_extattrctl, pnp, NULL);
|
||||
PUFFS_MSG_RELEASE(extattrctl);
|
||||
if (vp) {
|
||||
puffs_releasenode(pnp);
|
||||
}
|
||||
|
||||
return checkerr(pmp, error, __func__);
|
||||
}
|
||||
|
||||
const struct vnodeopv_desc * const puffs_vnodeopv_descs[] = {
|
||||
&puffs_vnodeop_opv_desc,
|
||||
&puffs_specop_opv_desc,
|
||||
&puffs_fifoop_opv_desc,
|
||||
&puffs_msgop_opv_desc,
|
||||
NULL,
|
||||
};
|
||||
|
||||
struct vfsops puffs_vfsops = {
|
||||
MOUNT_PUFFS,
|
||||
sizeof (struct puffs_kargs),
|
||||
puffs_vfsop_mount, /* mount */
|
||||
puffs_vfsop_start, /* start */
|
||||
puffs_vfsop_unmount, /* unmount */
|
||||
puffs_vfsop_root, /* root */
|
||||
(void *)eopnotsupp, /* quotactl */
|
||||
puffs_vfsop_statvfs, /* statvfs */
|
||||
puffs_vfsop_sync, /* sync */
|
||||
(void *)eopnotsupp, /* vget */
|
||||
puffs_vfsop_fhtovp, /* fhtovp */
|
||||
puffs_vfsop_vptofh, /* vptofh */
|
||||
puffs_vfsop_init, /* init */
|
||||
NULL, /* reinit */
|
||||
puffs_vfsop_done, /* done */
|
||||
NULL, /* mountroot */
|
||||
puffs_vfsop_snapshot, /* snapshot */
|
||||
puffs_vfsop_extattrctl, /* extattrctl */
|
||||
(void *)eopnotsupp, /* suspendctl */
|
||||
genfs_renamelock_enter,
|
||||
genfs_renamelock_exit,
|
||||
(void *)eopnotsupp,
|
||||
puffs_vnodeopv_descs, /* vnodeops */
|
||||
0, /* refcount */
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static int
|
||||
puffs_modcmd(modcmd_t cmd, void *arg)
|
||||
{
|
||||
|
||||
switch (cmd) {
|
||||
case MODULE_CMD_INIT:
|
||||
return vfs_attach(&puffs_vfsops);
|
||||
case MODULE_CMD_FINI:
|
||||
return vfs_detach(&puffs_vfsops);
|
||||
default:
|
||||
return ENOTTY;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user