Home | History | Annotate | Line # | Download | only in sysvbfs
sysvbfs_vfsops.c revision 1.46.2.1
      1  1.46.2.1  pgoyette /*	$NetBSD: sysvbfs_vfsops.c,v 1.46.2.1 2016/07/20 23:47:57 pgoyette Exp $	*/
      2       1.1   tsutsui 
      3       1.1   tsutsui /*-
      4       1.1   tsutsui  * Copyright (c) 2004 The NetBSD Foundation, Inc.
      5       1.1   tsutsui  * All rights reserved.
      6       1.1   tsutsui  *
      7       1.1   tsutsui  * This code is derived from software contributed to The NetBSD Foundation
      8       1.1   tsutsui  * by UCHIYAMA Yasushi.
      9       1.1   tsutsui  *
     10       1.1   tsutsui  * Redistribution and use in source and binary forms, with or without
     11       1.1   tsutsui  * modification, are permitted provided that the following conditions
     12       1.1   tsutsui  * are met:
     13       1.1   tsutsui  * 1. Redistributions of source code must retain the above copyright
     14       1.1   tsutsui  *    notice, this list of conditions and the following disclaimer.
     15       1.1   tsutsui  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1   tsutsui  *    notice, this list of conditions and the following disclaimer in the
     17       1.1   tsutsui  *    documentation and/or other materials provided with the distribution.
     18       1.1   tsutsui  *
     19       1.1   tsutsui  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20       1.1   tsutsui  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21       1.1   tsutsui  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22       1.1   tsutsui  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23       1.1   tsutsui  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24       1.1   tsutsui  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25       1.1   tsutsui  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26       1.1   tsutsui  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27       1.1   tsutsui  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28       1.1   tsutsui  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29       1.1   tsutsui  * POSSIBILITY OF SUCH DAMAGE.
     30       1.1   tsutsui  */
     31       1.1   tsutsui 
     32       1.1   tsutsui #include <sys/cdefs.h>
     33  1.46.2.1  pgoyette __KERNEL_RCSID(0, "$NetBSD: sysvbfs_vfsops.c,v 1.46.2.1 2016/07/20 23:47:57 pgoyette Exp $");
     34       1.1   tsutsui 
     35       1.1   tsutsui #include <sys/types.h>
     36       1.1   tsutsui #include <sys/param.h>
     37       1.1   tsutsui #include <sys/systm.h>
     38       1.1   tsutsui #include <sys/pool.h>
     39       1.1   tsutsui #include <sys/time.h>
     40       1.1   tsutsui #include <sys/ucred.h>
     41       1.1   tsutsui #include <sys/mount.h>
     42       1.1   tsutsui #include <sys/fcntl.h>
     43       1.1   tsutsui #include <sys/malloc.h>
     44       1.4      yamt #include <sys/kauth.h>
     45      1.14        ad #include <sys/proc.h>
     46       1.1   tsutsui 
     47       1.1   tsutsui /* v-node */
     48       1.1   tsutsui #include <sys/namei.h>
     49       1.1   tsutsui #include <sys/vnode.h>
     50       1.1   tsutsui /* devsw */
     51       1.1   tsutsui #include <sys/conf.h>
     52       1.1   tsutsui 
     53       1.1   tsutsui #include <fs/sysvbfs/sysvbfs.h>	/* external interface */
     54       1.1   tsutsui #include <fs/sysvbfs/bfs.h>	/* internal interface */
     55       1.1   tsutsui 
     56       1.1   tsutsui #ifdef SYSVBFS_VNOPS_DEBUG
     57       1.1   tsutsui #define	DPRINTF(fmt, args...)	printf(fmt, ##args)
     58       1.1   tsutsui #else
     59       1.1   tsutsui #define	DPRINTF(arg...)		((void)0)
     60       1.1   tsutsui #endif
     61       1.1   tsutsui 
     62      1.11     pooka MALLOC_JUSTDEFINE(M_SYSVBFS_VFS, "sysvbfs vfs", "sysvbfs vfs structures");
     63       1.1   tsutsui 
     64      1.11     pooka struct pool sysvbfs_node_pool;
     65       1.1   tsutsui 
     66       1.1   tsutsui int sysvbfs_mountfs(struct vnode *, struct mount *, struct lwp *);
     67       1.1   tsutsui 
     68       1.1   tsutsui int
     69      1.18     pooka sysvbfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
     70       1.1   tsutsui {
     71      1.18     pooka 	struct lwp *l = curlwp;
     72      1.12       dsl 	struct sysvbfs_args *args = data;
     73       1.1   tsutsui 	struct sysvbfs_mount *bmp = NULL;
     74       1.1   tsutsui 	struct vnode *devvp = NULL;
     75      1.40     joerg 	int error = 0;
     76       1.8   thorpej 	bool update;
     77  1.46.2.1  pgoyette 	const struct bdevsw *bdev = NULL;
     78       1.1   tsutsui 
     79      1.20     perry 	DPRINTF("%s: mnt_flag=%x\n", __func__, mp->mnt_flag);
     80       1.1   tsutsui 
     81      1.43      maxv 	if (args == NULL)
     82      1.43      maxv 		return EINVAL;
     83      1.12       dsl 	if (*data_len < sizeof *args)
     84      1.12       dsl 		return EINVAL;
     85      1.12       dsl 
     86       1.1   tsutsui 	if (mp->mnt_flag & MNT_GETARGS) {
     87      1.42   mlelstv 		if ((bmp = (struct sysvbfs_mount *)mp->mnt_data) == NULL)
     88       1.1   tsutsui 			return EIO;
     89      1.12       dsl 		args->fspec = NULL;
     90      1.12       dsl 		*data_len = sizeof *args;
     91      1.12       dsl 		return 0;
     92       1.1   tsutsui 	}
     93       1.1   tsutsui 
     94       1.1   tsutsui 
     95      1.20     perry 	DPRINTF("%s: args->fspec=%s\n", __func__, args->fspec);
     96       1.1   tsutsui 	update = mp->mnt_flag & MNT_UPDATE;
     97      1.12       dsl 	if (args->fspec == NULL) {
     98       1.1   tsutsui 		/* nothing to do. */
     99       1.1   tsutsui 		return EINVAL;
    100       1.1   tsutsui 	}
    101       1.1   tsutsui 
    102      1.12       dsl 	if (args->fspec != NULL) {
    103       1.1   tsutsui 		/* Look up the name and verify that it's sane. */
    104      1.30  dholland 		error = namei_simple_user(args->fspec,
    105      1.30  dholland 					NSM_FOLLOW_NOEMULROOT, &devvp);
    106      1.30  dholland 		if (error != 0)
    107       1.1   tsutsui 			return (error);
    108       1.1   tsutsui 
    109       1.1   tsutsui 		if (!update) {
    110       1.1   tsutsui 			/*
    111       1.1   tsutsui 			 * Be sure this is a valid block device
    112       1.1   tsutsui 			 */
    113       1.1   tsutsui 			if (devvp->v_type != VBLK)
    114       1.1   tsutsui 				error = ENOTBLK;
    115  1.46.2.1  pgoyette 			else if ((bdev = bdevsw_lookup_acquire(devvp->v_rdev))
    116  1.46.2.1  pgoyette 						== NULL)
    117       1.1   tsutsui 				error = ENXIO;
    118       1.1   tsutsui 		} else {
    119       1.1   tsutsui 			/*
    120       1.1   tsutsui 			 * Be sure we're still naming the same device
    121       1.1   tsutsui 			 * used for our initial mount
    122       1.1   tsutsui 			 */
    123      1.42   mlelstv 			bmp = (struct sysvbfs_mount *)mp->mnt_data;
    124       1.1   tsutsui 			if (devvp != bmp->devvp)
    125       1.1   tsutsui 				error = EINVAL;
    126       1.1   tsutsui 		}
    127       1.1   tsutsui 	}
    128       1.1   tsutsui 
    129       1.1   tsutsui 	/*
    130       1.1   tsutsui 	 * If mount by non-root, then verify that user has necessary
    131       1.1   tsutsui 	 * permissions on the device.
    132      1.29      elad 	 *
    133      1.29      elad 	 * Permission to update a mount is checked higher, so here we presume
    134      1.29      elad 	 * updating the mount is okay (for example, as far as securelevel goes)
    135      1.29      elad 	 * which leaves us with the normal check.
    136       1.1   tsutsui 	 */
    137      1.29      elad 	if (error == 0) {
    138       1.1   tsutsui 		int accessmode = VREAD;
    139       1.1   tsutsui 		if (update ?
    140       1.1   tsutsui 		    (mp->mnt_iflag & IMNT_WANTRDWR) != 0 :
    141       1.1   tsutsui 		    (mp->mnt_flag & MNT_RDONLY) == 0)
    142       1.1   tsutsui 			accessmode |= VWRITE;
    143      1.39      elad 
    144      1.39      elad 		error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_MOUNT,
    145      1.39      elad 		    KAUTH_REQ_SYSTEM_MOUNT_DEVICE, mp, devvp,
    146      1.39      elad 		    KAUTH_ARG(accessmode));
    147       1.1   tsutsui 	}
    148       1.1   tsutsui 
    149       1.1   tsutsui 	if (error) {
    150       1.1   tsutsui 		vrele(devvp);
    151  1.46.2.1  pgoyette 		bdevsw_release(bdev);
    152       1.1   tsutsui 		return error;
    153       1.1   tsutsui 	}
    154       1.1   tsutsui 
    155       1.1   tsutsui 	if (!update) {
    156       1.1   tsutsui 		if ((error = sysvbfs_mountfs(devvp, mp, l)) != 0) {
    157       1.1   tsutsui 			vrele(devvp);
    158  1.46.2.1  pgoyette 			bdevsw_release(bdev);
    159       1.1   tsutsui 			return error;
    160       1.1   tsutsui 		}
    161       1.1   tsutsui 	} else 	if (mp->mnt_flag & MNT_RDONLY) {
    162       1.1   tsutsui 		/* XXX: r/w -> read only */
    163       1.1   tsutsui 	}
    164       1.1   tsutsui 
    165  1.46.2.1  pgoyette 	error = set_statvfs_info(path, UIO_USERSPACE, args->fspec,
    166  1.46.2.1  pgoyette 	    UIO_USERSPACE, mp->mnt_op->vfs_name, mp, l);
    167  1.46.2.1  pgoyette 
    168  1.46.2.1  pgoyette 	if (bdev != NULL)
    169  1.46.2.1  pgoyette 		bdevsw_release(bdev);
    170  1.46.2.1  pgoyette 	return error;
    171       1.1   tsutsui }
    172       1.1   tsutsui 
    173       1.1   tsutsui int
    174       1.1   tsutsui sysvbfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l)
    175       1.1   tsutsui {
    176       1.6        ad 	kauth_cred_t cred = l->l_cred;
    177       1.1   tsutsui 	struct sysvbfs_mount *bmp;
    178      1.26     pooka 	int error, oflags;
    179       1.1   tsutsui 
    180       1.1   tsutsui 	vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
    181       1.1   tsutsui 	error = vinvalbuf(devvp, V_SAVE, cred, l, 0, 0);
    182       1.1   tsutsui 	if (error)
    183      1.31     pooka 		goto out;
    184       1.1   tsutsui 
    185       1.1   tsutsui 	/* Open block device */
    186      1.26     pooka 	oflags = FREAD;
    187      1.26     pooka 	if ((mp->mnt_flag & MNT_RDONLY) == 0)
    188      1.26     pooka 		oflags |= FWRITE;
    189      1.26     pooka 	if ((error = VOP_OPEN(devvp, oflags, NOCRED)) != 0)
    190      1.31     pooka 		goto out;
    191       1.1   tsutsui 
    192      1.38  christos 	bmp = malloc(sizeof(*bmp), M_SYSVBFS_VFS, M_WAITOK | M_ZERO);
    193       1.1   tsutsui 	bmp->devvp = devvp;
    194       1.1   tsutsui 	bmp->mountp = mp;
    195       1.1   tsutsui 	if ((error = sysvbfs_bfs_init(&bmp->bfs, devvp)) != 0) {
    196       1.1   tsutsui 		free(bmp, M_SYSVBFS_VFS);
    197      1.44    justin 		VOP_CLOSE(devvp, oflags, NOCRED);
    198      1.31     pooka 		goto out;
    199       1.1   tsutsui 	}
    200       1.1   tsutsui 
    201       1.1   tsutsui 	mp->mnt_data = bmp;
    202       1.1   tsutsui 	mp->mnt_stat.f_fsidx.__fsid_val[0] = (long)devvp->v_rdev;
    203       1.1   tsutsui 	mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_SYSVBFS);
    204       1.1   tsutsui 	mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
    205      1.33     njoly 	mp->mnt_stat.f_namemax = BFS_FILENAME_MAXLEN;
    206       1.1   tsutsui 	mp->mnt_flag |= MNT_LOCAL;
    207      1.10   tsutsui 	mp->mnt_dev_bshift = BFS_BSHIFT;
    208       1.1   tsutsui 	mp->mnt_fs_bshift = BFS_BSHIFT;
    209       1.1   tsutsui 
    210      1.31     pooka  out:
    211      1.32   hannken 	VOP_UNLOCK(devvp);
    212      1.31     pooka 	return error;
    213       1.1   tsutsui }
    214       1.1   tsutsui 
    215       1.1   tsutsui int
    216      1.18     pooka sysvbfs_start(struct mount *mp, int flags)
    217       1.1   tsutsui {
    218       1.1   tsutsui 
    219      1.20     perry 	DPRINTF("%s:\n", __func__);
    220       1.1   tsutsui 	/* Nothing to do. */
    221       1.1   tsutsui 	return 0;
    222       1.1   tsutsui }
    223       1.1   tsutsui 
    224       1.1   tsutsui int
    225      1.18     pooka sysvbfs_unmount(struct mount *mp, int mntflags)
    226       1.1   tsutsui {
    227       1.1   tsutsui 	struct sysvbfs_mount *bmp = (void *)mp->mnt_data;
    228       1.1   tsutsui 	int error;
    229       1.1   tsutsui 
    230      1.20     perry 	DPRINTF("%s: %p\n", __func__, bmp);
    231       1.1   tsutsui 
    232       1.1   tsutsui 	if ((error = vflush(mp, NULLVP,
    233       1.1   tsutsui 	    mntflags & MNT_FORCE ? FORCECLOSE : 0)) != 0)
    234       1.1   tsutsui 		return error;
    235       1.1   tsutsui 
    236       1.1   tsutsui 	vn_lock(bmp->devvp, LK_EXCLUSIVE | LK_RETRY);
    237      1.18     pooka 	error = VOP_CLOSE(bmp->devvp, FREAD, NOCRED);
    238       1.1   tsutsui 	vput(bmp->devvp);
    239       1.1   tsutsui 
    240       1.1   tsutsui 	sysvbfs_bfs_fini(bmp->bfs);
    241       1.1   tsutsui 
    242       1.1   tsutsui 	free(bmp, M_SYSVBFS_VFS);
    243       1.1   tsutsui 	mp->mnt_data = NULL;
    244       1.1   tsutsui 	mp->mnt_flag &= ~MNT_LOCAL;
    245       1.1   tsutsui 
    246       1.1   tsutsui 	return 0;
    247       1.1   tsutsui }
    248       1.1   tsutsui 
    249       1.1   tsutsui int
    250       1.1   tsutsui sysvbfs_root(struct mount *mp, struct vnode **vpp)
    251       1.1   tsutsui {
    252       1.1   tsutsui 	struct vnode *vp;
    253       1.1   tsutsui 	int error;
    254       1.1   tsutsui 
    255      1.20     perry 	DPRINTF("%s:\n", __func__);
    256       1.1   tsutsui 	if ((error = VFS_VGET(mp, BFS_ROOT_INODE, &vp)) != 0)
    257       1.1   tsutsui 		return error;
    258       1.1   tsutsui 	*vpp = vp;
    259       1.1   tsutsui 
    260       1.1   tsutsui 	return 0;
    261       1.1   tsutsui }
    262       1.1   tsutsui 
    263       1.1   tsutsui int
    264      1.18     pooka sysvbfs_statvfs(struct mount *mp, struct statvfs *f)
    265       1.1   tsutsui {
    266       1.1   tsutsui 	struct sysvbfs_mount *bmp = mp->mnt_data;
    267       1.1   tsutsui 	struct bfs *bfs = bmp->bfs;
    268       1.1   tsutsui 	int free_block;
    269       1.1   tsutsui 	size_t data_block;
    270       1.1   tsutsui 
    271       1.1   tsutsui 	data_block = (bfs->data_end - bfs->data_start) >> BFS_BSHIFT;
    272       1.1   tsutsui 	if (bfs_inode_alloc(bfs, 0, 0, &free_block) != 0)
    273       1.1   tsutsui 		free_block = 0;
    274       1.1   tsutsui 	else
    275       1.1   tsutsui 		free_block = (bfs->data_end >> BFS_BSHIFT) - free_block;
    276       1.1   tsutsui 
    277      1.20     perry 	DPRINTF("%s: %d %d %d\n", __func__, bfs->data_start,
    278       1.1   tsutsui 	    bfs->data_end, free_block);
    279       1.1   tsutsui 
    280       1.1   tsutsui 	f->f_bsize = BFS_BSIZE;
    281       1.1   tsutsui 	f->f_frsize = BFS_BSIZE;
    282       1.1   tsutsui 	f->f_iosize = BFS_BSIZE;
    283       1.1   tsutsui 	f->f_blocks = data_block;
    284       1.1   tsutsui 	f->f_bfree = free_block;
    285       1.1   tsutsui 	f->f_bavail = f->f_bfree;
    286       1.1   tsutsui 	f->f_bresvd = 0;
    287      1.41       agc 	f->f_files = bfs->max_inode;
    288      1.41       agc 	f->f_ffree = bfs->max_inode - bfs->n_inode;
    289       1.1   tsutsui 	f->f_favail = f->f_ffree;
    290       1.1   tsutsui 	f->f_fresvd = 0;
    291       1.1   tsutsui 	copy_statvfs_info(f, mp);
    292       1.1   tsutsui 
    293       1.1   tsutsui 	return 0;
    294       1.1   tsutsui }
    295       1.1   tsutsui 
    296       1.1   tsutsui int
    297      1.18     pooka sysvbfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
    298       1.1   tsutsui {
    299      1.45   hannken 	struct vnode_iterator *marker;
    300      1.45   hannken 	struct vnode *vp;
    301       1.1   tsutsui 	int err, error;
    302       1.1   tsutsui 
    303      1.20     perry 	DPRINTF("%s:\n", __func__);
    304       1.1   tsutsui 	error = 0;
    305      1.45   hannken 	vfs_vnode_iterator_init(mp, &marker);
    306      1.45   hannken 	while ((vp = vfs_vnode_iterator_next(marker, NULL, NULL)) != NULL) {
    307      1.45   hannken 		err = vn_lock(vp, LK_EXCLUSIVE);
    308      1.45   hannken 		if (err) {
    309      1.45   hannken 			vrele(vp);
    310      1.45   hannken 			continue;
    311       1.1   tsutsui 		}
    312      1.45   hannken 		err = VOP_FSYNC(vp, cred, FSYNC_WAIT, 0, 0);
    313      1.45   hannken 		vput(vp);
    314       1.1   tsutsui 		if (err != 0)
    315       1.1   tsutsui 			error = err;
    316       1.1   tsutsui 	}
    317      1.45   hannken 	vfs_vnode_iterator_destroy(marker);
    318       1.1   tsutsui 
    319       1.1   tsutsui 	return error;
    320       1.1   tsutsui }
    321       1.1   tsutsui 
    322       1.1   tsutsui int
    323      1.45   hannken sysvbfs_loadvnode(struct mount *mp, struct vnode *vp,
    324      1.45   hannken     const void *key, size_t key_len, const void **new_key)
    325       1.1   tsutsui {
    326      1.45   hannken 	struct sysvbfs_mount *bmp;
    327      1.45   hannken 	struct bfs *bfs;
    328       1.1   tsutsui 	struct sysvbfs_node *bnode;
    329       1.1   tsutsui 	struct bfs_inode *inode;
    330      1.45   hannken 	uint16_t ino;
    331      1.45   hannken 
    332      1.45   hannken 	KASSERT(key_len == sizeof(ino));
    333      1.45   hannken 	memcpy(&ino, key, key_len);
    334      1.45   hannken 
    335      1.45   hannken 	DPRINTF("%s: i-node=%u\n", __func__, ino);
    336      1.45   hannken 
    337      1.45   hannken 	bmp = mp->mnt_data;
    338      1.45   hannken 	bfs = bmp->bfs;
    339       1.1   tsutsui 
    340       1.1   tsutsui 	/* Lookup requested i-node */
    341       1.1   tsutsui 	if (!bfs_inode_lookup(bfs, ino, &inode)) {
    342      1.37     njoly 		DPRINTF("%s: bfs_inode_lookup failed.\n", __func__);
    343       1.1   tsutsui 		return ENOENT;
    344       1.1   tsutsui 	}
    345      1.28     pooka 
    346      1.45   hannken 	bnode = pool_get(&sysvbfs_node_pool, PR_WAITOK);
    347      1.46   hannken 	memset(bnode, 0, sizeof(*bnode));
    348       1.1   tsutsui 
    349      1.45   hannken 	vp->v_tag = VT_SYSVBFS;
    350      1.45   hannken 	vp->v_op = sysvbfs_vnodeop_p;
    351      1.45   hannken 	vp->v_data = bnode;
    352      1.45   hannken 	if (ino == BFS_ROOT_INODE) {	/* BFS is flat filesystem */
    353      1.45   hannken 		vp->v_type = VDIR;
    354      1.45   hannken 		vp->v_vflag |= VV_ROOT;
    355      1.45   hannken 	} else {
    356      1.45   hannken 		vp->v_type = VREG;
    357       1.1   tsutsui 	}
    358       1.1   tsutsui 
    359       1.1   tsutsui 	bnode->vnode = vp;
    360       1.1   tsutsui 	bnode->bmp = bmp;
    361       1.1   tsutsui 	bnode->inode = inode;
    362       1.1   tsutsui 	bnode->lockf = NULL; /* advlock */
    363       1.1   tsutsui 
    364      1.45   hannken 	genfs_node_init(vp, &sysvbfs_genfsops);
    365      1.45   hannken 	uvm_vnp_setsize(vp, bfs_file_size(inode));
    366      1.45   hannken 
    367      1.45   hannken 	*new_key = &bnode->inode->number;
    368      1.45   hannken 
    369      1.45   hannken 	return 0;
    370      1.45   hannken }
    371      1.45   hannken 
    372      1.45   hannken int
    373      1.45   hannken sysvbfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
    374      1.45   hannken {
    375      1.45   hannken 	int error;
    376      1.45   hannken 	uint16_t number;
    377      1.45   hannken 	struct vnode *vp;
    378      1.45   hannken 
    379      1.45   hannken 	KASSERT(ino <= UINT16_MAX);
    380      1.45   hannken 	number = ino;
    381      1.45   hannken 
    382      1.45   hannken 	DPRINTF("%s: i-node=%u\n", __func__, number);
    383      1.45   hannken 
    384      1.45   hannken 	error = vcache_get(mp, &number, sizeof(number), &vp);
    385      1.45   hannken 	if (error)
    386      1.45   hannken 		return error;
    387      1.45   hannken 	error = vn_lock(vp, LK_EXCLUSIVE);
    388      1.45   hannken 	if (error) {
    389      1.45   hannken 		vrele(vp);
    390      1.45   hannken 		return error;
    391       1.1   tsutsui 	}
    392       1.1   tsutsui 
    393       1.1   tsutsui 	*vpp = vp;
    394       1.1   tsutsui 
    395       1.1   tsutsui 	return 0;
    396       1.1   tsutsui }
    397       1.1   tsutsui 
    398       1.1   tsutsui int
    399       1.1   tsutsui sysvbfs_fhtovp(struct mount *mp, struct fid *fid, struct vnode **vpp)
    400       1.1   tsutsui {
    401       1.1   tsutsui 
    402      1.20     perry 	DPRINTF("%s:\n", __func__);
    403       1.1   tsutsui 	/* notyet */
    404       1.1   tsutsui 	return EOPNOTSUPP;
    405       1.1   tsutsui }
    406       1.1   tsutsui 
    407       1.1   tsutsui int
    408       1.5    martin sysvbfs_vptofh(struct vnode *vpp, struct fid *fid, size_t *fh_size)
    409       1.1   tsutsui {
    410       1.1   tsutsui 
    411      1.20     perry 	DPRINTF("%s:\n", __func__);
    412       1.1   tsutsui 	/* notyet */
    413       1.1   tsutsui 	return EOPNOTSUPP;
    414       1.1   tsutsui }
    415       1.1   tsutsui 
    416      1.11     pooka MALLOC_DECLARE(M_BFS);
    417      1.11     pooka MALLOC_DECLARE(M_SYSVBFS_VNODE);
    418      1.11     pooka 
    419       1.1   tsutsui void
    420       1.1   tsutsui sysvbfs_init(void)
    421       1.1   tsutsui {
    422       1.1   tsutsui 
    423      1.20     perry 	DPRINTF("%s:\n", __func__);
    424      1.11     pooka 	malloc_type_attach(M_SYSVBFS_VFS);
    425      1.11     pooka 	malloc_type_attach(M_BFS);
    426      1.11     pooka 	malloc_type_attach(M_SYSVBFS_VNODE);
    427      1.11     pooka 	pool_init(&sysvbfs_node_pool, sizeof(struct sysvbfs_node), 0, 0, 0,
    428      1.11     pooka 	    "sysvbfs_node_pool", &pool_allocator_nointr, IPL_NONE);
    429       1.1   tsutsui }
    430       1.1   tsutsui 
    431       1.1   tsutsui void
    432       1.1   tsutsui sysvbfs_reinit(void)
    433       1.1   tsutsui {
    434       1.1   tsutsui 
    435       1.1   tsutsui 	/* Nothing to do. */
    436      1.20     perry 	DPRINTF("%s:\n", __func__);
    437       1.1   tsutsui }
    438       1.1   tsutsui 
    439       1.1   tsutsui void
    440       1.1   tsutsui sysvbfs_done(void)
    441       1.1   tsutsui {
    442       1.1   tsutsui 
    443      1.20     perry 	DPRINTF("%s:\n", __func__);
    444       1.1   tsutsui 	pool_destroy(&sysvbfs_node_pool);
    445      1.11     pooka 	malloc_type_detach(M_BFS);
    446      1.11     pooka 	malloc_type_detach(M_SYSVBFS_VFS);
    447      1.11     pooka 	malloc_type_detach(M_SYSVBFS_VNODE);
    448       1.1   tsutsui }
    449       1.1   tsutsui 
    450       1.1   tsutsui int
    451       1.1   tsutsui sysvbfs_gop_alloc(struct vnode *vp, off_t off, off_t len, int flags,
    452       1.3      elad     kauth_cred_t cred)
    453       1.1   tsutsui {
    454       1.1   tsutsui 
    455       1.1   tsutsui 	return 0;
    456       1.1   tsutsui }
    457