Home | History | Annotate | Line # | Download | only in sysvbfs
sysvbfs_vfsops.c revision 1.3
      1  1.3     elad /*	$NetBSD: sysvbfs_vfsops.c,v 1.3 2006/05/14 21:31:52 elad 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  * 3. All advertising materials mentioning features or use of this software
     19  1.1  tsutsui  *    must display the following acknowledgement:
     20  1.1  tsutsui  *        This product includes software developed by the NetBSD
     21  1.1  tsutsui  *        Foundation, Inc. and its contributors.
     22  1.1  tsutsui  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.1  tsutsui  *    contributors may be used to endorse or promote products derived
     24  1.1  tsutsui  *    from this software without specific prior written permission.
     25  1.1  tsutsui  *
     26  1.1  tsutsui  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.1  tsutsui  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.1  tsutsui  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.1  tsutsui  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.1  tsutsui  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.1  tsutsui  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.1  tsutsui  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.1  tsutsui  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.1  tsutsui  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.1  tsutsui  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.1  tsutsui  * POSSIBILITY OF SUCH DAMAGE.
     37  1.1  tsutsui  */
     38  1.1  tsutsui 
     39  1.1  tsutsui #include <sys/cdefs.h>
     40  1.3     elad __KERNEL_RCSID(0, "$NetBSD: sysvbfs_vfsops.c,v 1.3 2006/05/14 21:31:52 elad Exp $");
     41  1.1  tsutsui 
     42  1.1  tsutsui #include <sys/types.h>
     43  1.1  tsutsui #include <sys/param.h>
     44  1.1  tsutsui #include <sys/systm.h>
     45  1.1  tsutsui #include <sys/pool.h>
     46  1.1  tsutsui 
     47  1.1  tsutsui #include <sys/time.h>
     48  1.1  tsutsui #include <sys/ucred.h>
     49  1.1  tsutsui #include <sys/mount.h>
     50  1.1  tsutsui #include <sys/disklabel.h>
     51  1.1  tsutsui #include <sys/fcntl.h>
     52  1.1  tsutsui #include <sys/malloc.h>
     53  1.1  tsutsui 
     54  1.1  tsutsui /* v-node */
     55  1.1  tsutsui #include <sys/namei.h>
     56  1.1  tsutsui #include <sys/vnode.h>
     57  1.1  tsutsui /* devsw */
     58  1.1  tsutsui #include <sys/conf.h>
     59  1.1  tsutsui 
     60  1.1  tsutsui #include <fs/sysvbfs/sysvbfs.h>	/* external interface */
     61  1.1  tsutsui #include <fs/sysvbfs/bfs.h>	/* internal interface */
     62  1.1  tsutsui 
     63  1.1  tsutsui #ifdef SYSVBFS_VNOPS_DEBUG
     64  1.1  tsutsui #define	DPRINTF(fmt, args...)	printf(fmt, ##args)
     65  1.1  tsutsui #else
     66  1.1  tsutsui #define	DPRINTF(arg...)		((void)0)
     67  1.1  tsutsui #endif
     68  1.1  tsutsui 
     69  1.1  tsutsui MALLOC_DEFINE(M_SYSVBFS_VFS, "sysvbfs vfs", "sysvbfs vfs structures");
     70  1.1  tsutsui 
     71  1.1  tsutsui POOL_INIT(sysvbfs_node_pool, sizeof(struct sysvbfs_node), 0, 0, 0,
     72  1.1  tsutsui     "sysvbfs_node_pool", &pool_allocator_nointr);
     73  1.1  tsutsui 
     74  1.1  tsutsui int sysvbfs_mountfs(struct vnode *, struct mount *, struct lwp *);
     75  1.1  tsutsui 
     76  1.1  tsutsui int
     77  1.1  tsutsui sysvbfs_mount(struct mount *mp, const char *path, void *data,
     78  1.1  tsutsui     struct nameidata *ndp, struct lwp *l)
     79  1.1  tsutsui {
     80  1.1  tsutsui 	struct sysvbfs_args args;
     81  1.1  tsutsui 	struct sysvbfs_mount *bmp = NULL;
     82  1.1  tsutsui 	struct vnode *devvp = NULL;
     83  1.1  tsutsui 	struct proc *p = l->l_proc;
     84  1.1  tsutsui 	int error;
     85  1.1  tsutsui 	boolean_t update;
     86  1.1  tsutsui 
     87  1.1  tsutsui 	DPRINTF("%s: mnt_flag=%x\n", __FUNCTION__, mp->mnt_flag);
     88  1.1  tsutsui 
     89  1.1  tsutsui 	if (mp->mnt_flag & MNT_GETARGS) {
     90  1.1  tsutsui 		if ((bmp = (void *)mp->mnt_data) == NULL)
     91  1.1  tsutsui 			return EIO;
     92  1.1  tsutsui 		args.fspec = NULL;
     93  1.1  tsutsui 		return copyout(&args, data, sizeof(args));
     94  1.1  tsutsui 	}
     95  1.1  tsutsui 
     96  1.1  tsutsui 	if ((error = copyin(data, &args, sizeof(args))) != 0)
     97  1.1  tsutsui 		return error;
     98  1.1  tsutsui 
     99  1.1  tsutsui 	DPRINTF("%s: args.fspec=%s\n", __FUNCTION__, args.fspec);
    100  1.1  tsutsui 	update = mp->mnt_flag & MNT_UPDATE;
    101  1.1  tsutsui 	if (args.fspec == NULL) {
    102  1.1  tsutsui 		/* nothing to do. */
    103  1.1  tsutsui 		return EINVAL;
    104  1.1  tsutsui 	}
    105  1.1  tsutsui 
    106  1.1  tsutsui 	if (args.fspec != NULL) {
    107  1.1  tsutsui 		/* Look up the name and verify that it's sane. */
    108  1.1  tsutsui 		NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, l);
    109  1.1  tsutsui 		if ((error = namei(ndp)) != 0)
    110  1.1  tsutsui 			return (error);
    111  1.1  tsutsui 		devvp = ndp->ni_vp;
    112  1.1  tsutsui 
    113  1.1  tsutsui 		if (!update) {
    114  1.1  tsutsui 			/*
    115  1.1  tsutsui 			 * Be sure this is a valid block device
    116  1.1  tsutsui 			 */
    117  1.1  tsutsui 			if (devvp->v_type != VBLK)
    118  1.1  tsutsui 				error = ENOTBLK;
    119  1.1  tsutsui 			else if (bdevsw_lookup(devvp->v_specinfo->si_rdev) ==
    120  1.1  tsutsui 			    NULL)
    121  1.1  tsutsui 				error = ENXIO;
    122  1.1  tsutsui 		} else {
    123  1.1  tsutsui 			/*
    124  1.1  tsutsui 			 * Be sure we're still naming the same device
    125  1.1  tsutsui 			 * used for our initial mount
    126  1.1  tsutsui 			 */
    127  1.1  tsutsui 			if (devvp != bmp->devvp)
    128  1.1  tsutsui 				error = EINVAL;
    129  1.1  tsutsui 		}
    130  1.1  tsutsui 	}
    131  1.1  tsutsui 
    132  1.1  tsutsui 	/*
    133  1.1  tsutsui 	 * If mount by non-root, then verify that user has necessary
    134  1.1  tsutsui 	 * permissions on the device.
    135  1.1  tsutsui 	 */
    136  1.3     elad 	if (error == 0 && kauth_cred_geteuid(p->p_cred) != 0) {
    137  1.1  tsutsui 		int accessmode = VREAD;
    138  1.1  tsutsui 		if (update ?
    139  1.1  tsutsui 		    (mp->mnt_iflag & IMNT_WANTRDWR) != 0 :
    140  1.1  tsutsui 		    (mp->mnt_flag & MNT_RDONLY) == 0)
    141  1.1  tsutsui 			accessmode |= VWRITE;
    142  1.1  tsutsui 		vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
    143  1.3     elad 		error = VOP_ACCESS(devvp, accessmode, p->p_cred, l);
    144  1.1  tsutsui 		VOP_UNLOCK(devvp, 0);
    145  1.1  tsutsui 	}
    146  1.1  tsutsui 
    147  1.1  tsutsui 	if (error) {
    148  1.1  tsutsui 		vrele(devvp);
    149  1.1  tsutsui 		return error;
    150  1.1  tsutsui 	}
    151  1.1  tsutsui 
    152  1.1  tsutsui 	if (!update) {
    153  1.1  tsutsui 		if ((error = sysvbfs_mountfs(devvp, mp, l)) != 0) {
    154  1.1  tsutsui 			vrele(devvp);
    155  1.1  tsutsui 			return error;
    156  1.1  tsutsui 		}
    157  1.1  tsutsui 	} else 	if (mp->mnt_flag & MNT_RDONLY) {
    158  1.1  tsutsui 		/* XXX: r/w -> read only */
    159  1.1  tsutsui 	}
    160  1.1  tsutsui 
    161  1.1  tsutsui 	return set_statvfs_info(path, UIO_USERSPACE, args.fspec, UIO_USERSPACE,
    162  1.1  tsutsui 	    mp, l);
    163  1.1  tsutsui }
    164  1.1  tsutsui 
    165  1.1  tsutsui int
    166  1.1  tsutsui sysvbfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l)
    167  1.1  tsutsui {
    168  1.3     elad 	kauth_cred_t cred = l->l_proc->p_cred;
    169  1.1  tsutsui 	struct sysvbfs_mount *bmp;
    170  1.1  tsutsui 	struct partinfo dpart;
    171  1.1  tsutsui 	int error;
    172  1.1  tsutsui 
    173  1.1  tsutsui 	if ((error = vfs_mountedon(devvp)) != 0)
    174  1.1  tsutsui 		return error;	/* Already mounted */
    175  1.1  tsutsui 	if (vcount(devvp) > 1)
    176  1.1  tsutsui 		return EBUSY;	/* Opened by other */
    177  1.1  tsutsui 	vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
    178  1.1  tsutsui 	error = vinvalbuf(devvp, V_SAVE, cred, l, 0, 0);
    179  1.1  tsutsui 	VOP_UNLOCK(devvp, 0);
    180  1.1  tsutsui 	if (error)
    181  1.1  tsutsui 		return error;
    182  1.1  tsutsui 
    183  1.1  tsutsui 	/* Open block device */
    184  1.1  tsutsui 	if ((error = VOP_OPEN(devvp, FREAD, NOCRED, l)) != 0)
    185  1.1  tsutsui 		return error;
    186  1.1  tsutsui 
    187  1.2      wiz 	/* Get partition information */
    188  1.1  tsutsui 	if ((error = VOP_IOCTL(devvp, DIOCGPART, &dpart, FREAD, cred, l)) != 0)
    189  1.1  tsutsui 		return error;
    190  1.1  tsutsui 
    191  1.1  tsutsui 	bmp = malloc(sizeof(struct sysvbfs_mount), M_SYSVBFS_VFS, M_WAITOK);
    192  1.1  tsutsui 	if (bmp == NULL)
    193  1.1  tsutsui 		return ENOMEM;
    194  1.1  tsutsui 	bmp->devvp = devvp;
    195  1.1  tsutsui 	bmp->mountp = mp;
    196  1.1  tsutsui 	if ((error = sysvbfs_bfs_init(&bmp->bfs, devvp)) != 0) {
    197  1.1  tsutsui 		free(bmp, M_SYSVBFS_VFS);
    198  1.1  tsutsui 		return error;
    199  1.1  tsutsui 	}
    200  1.1  tsutsui 	LIST_INIT(&bmp->bnode_head);
    201  1.1  tsutsui 
    202  1.1  tsutsui 	mp->mnt_data = bmp;
    203  1.1  tsutsui 	mp->mnt_stat.f_fsidx.__fsid_val[0] = (long)devvp->v_rdev;
    204  1.1  tsutsui 	mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_SYSVBFS);
    205  1.1  tsutsui 	mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0];
    206  1.1  tsutsui 	mp->mnt_flag |= MNT_LOCAL;
    207  1.1  tsutsui 	mp->mnt_dev_bshift = BFS_BSIZE;
    208  1.1  tsutsui 	mp->mnt_fs_bshift = BFS_BSHIFT;
    209  1.1  tsutsui 
    210  1.1  tsutsui 	DPRINTF("fstype=%d dtype=%d bsize=%d\n", dpart.part->p_fstype,
    211  1.1  tsutsui 	    dpart.disklab->d_type, dpart.disklab->d_secsize);
    212  1.1  tsutsui 
    213  1.1  tsutsui 	return 0;
    214  1.1  tsutsui }
    215  1.1  tsutsui 
    216  1.1  tsutsui int
    217  1.1  tsutsui sysvbfs_start(struct mount *mp, int flags, struct lwp *l)
    218  1.1  tsutsui {
    219  1.1  tsutsui 
    220  1.1  tsutsui 	DPRINTF("%s:\n", __FUNCTION__);
    221  1.1  tsutsui 	/* Nothing to do. */
    222  1.1  tsutsui 	return 0;
    223  1.1  tsutsui }
    224  1.1  tsutsui 
    225  1.1  tsutsui int
    226  1.1  tsutsui sysvbfs_unmount(struct mount *mp, int mntflags, struct lwp *l)
    227  1.1  tsutsui {
    228  1.1  tsutsui 	struct sysvbfs_mount *bmp = (void *)mp->mnt_data;
    229  1.1  tsutsui 	int error;
    230  1.1  tsutsui 
    231  1.1  tsutsui 	DPRINTF("%s: %p\n", __FUNCTION__, bmp);
    232  1.1  tsutsui 
    233  1.1  tsutsui 	if ((error = vflush(mp, NULLVP,
    234  1.1  tsutsui 	    mntflags & MNT_FORCE ? FORCECLOSE : 0)) != 0)
    235  1.1  tsutsui 		return error;
    236  1.1  tsutsui 
    237  1.1  tsutsui 	vn_lock(bmp->devvp, LK_EXCLUSIVE | LK_RETRY);
    238  1.1  tsutsui 	error = VOP_CLOSE(bmp->devvp, FREAD, NOCRED, l);
    239  1.1  tsutsui 	vput(bmp->devvp);
    240  1.1  tsutsui 
    241  1.1  tsutsui 	sysvbfs_bfs_fini(bmp->bfs);
    242  1.1  tsutsui 
    243  1.1  tsutsui 	free(bmp, M_SYSVBFS_VFS);
    244  1.1  tsutsui 	mp->mnt_data = NULL;
    245  1.1  tsutsui 	mp->mnt_flag &= ~MNT_LOCAL;
    246  1.1  tsutsui 
    247  1.1  tsutsui 	return 0;
    248  1.1  tsutsui }
    249  1.1  tsutsui 
    250  1.1  tsutsui int
    251  1.1  tsutsui sysvbfs_root(struct mount *mp, struct vnode **vpp)
    252  1.1  tsutsui {
    253  1.1  tsutsui 	struct vnode *vp;
    254  1.1  tsutsui 	int error;
    255  1.1  tsutsui 
    256  1.1  tsutsui 	DPRINTF("%s:\n", __FUNCTION__);
    257  1.1  tsutsui 	if ((error = VFS_VGET(mp, BFS_ROOT_INODE, &vp)) != 0)
    258  1.1  tsutsui 		return error;
    259  1.1  tsutsui 	*vpp = vp;
    260  1.1  tsutsui 
    261  1.1  tsutsui 	return 0;
    262  1.1  tsutsui }
    263  1.1  tsutsui 
    264  1.1  tsutsui int
    265  1.1  tsutsui sysvbfs_quotactl(struct mount *mp, int cmd, uid_t uid, void *arg,
    266  1.1  tsutsui     struct lwp *l)
    267  1.1  tsutsui {
    268  1.1  tsutsui 
    269  1.1  tsutsui 	DPRINTF("%s:\n", __FUNCTION__);
    270  1.1  tsutsui 	/* Don't support. */
    271  1.1  tsutsui 	return 0;
    272  1.1  tsutsui }
    273  1.1  tsutsui 
    274  1.1  tsutsui int
    275  1.1  tsutsui sysvbfs_statvfs(struct mount *mp, struct statvfs *f, struct lwp *l)
    276  1.1  tsutsui {
    277  1.1  tsutsui 	struct sysvbfs_mount *bmp = mp->mnt_data;
    278  1.1  tsutsui 	struct bfs *bfs = bmp->bfs;
    279  1.1  tsutsui 	int free_block;
    280  1.1  tsutsui 	size_t data_block;
    281  1.1  tsutsui 
    282  1.1  tsutsui 	data_block = (bfs->data_end - bfs->data_start) >> BFS_BSHIFT;
    283  1.1  tsutsui 	if (bfs_inode_alloc(bfs, 0, 0, &free_block) != 0)
    284  1.1  tsutsui 		free_block = 0;
    285  1.1  tsutsui 	else
    286  1.1  tsutsui 		free_block = (bfs->data_end >> BFS_BSHIFT) - free_block;
    287  1.1  tsutsui 
    288  1.1  tsutsui 	DPRINTF("%s: %d %d %d\n", __FUNCTION__, bfs->data_start,
    289  1.1  tsutsui 	    bfs->data_end, free_block);
    290  1.1  tsutsui 
    291  1.1  tsutsui 	f->f_bsize = BFS_BSIZE;
    292  1.1  tsutsui 	f->f_frsize = BFS_BSIZE;
    293  1.1  tsutsui 	f->f_iosize = BFS_BSIZE;
    294  1.1  tsutsui 	f->f_blocks = data_block;
    295  1.1  tsutsui 	f->f_bfree = free_block;
    296  1.1  tsutsui 	f->f_bavail = f->f_bfree;
    297  1.1  tsutsui 	f->f_bresvd = 0;
    298  1.1  tsutsui 	f->f_files = bfs->n_inode;
    299  1.1  tsutsui 	f->f_ffree = bfs->max_inode - f->f_files;
    300  1.1  tsutsui 	f->f_favail = f->f_ffree;
    301  1.1  tsutsui 	f->f_fresvd = 0;
    302  1.1  tsutsui 	copy_statvfs_info(f, mp);
    303  1.1  tsutsui 
    304  1.1  tsutsui 	return 0;
    305  1.1  tsutsui }
    306  1.1  tsutsui 
    307  1.1  tsutsui int
    308  1.3     elad sysvbfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred,
    309  1.1  tsutsui     struct lwp *l)
    310  1.1  tsutsui {
    311  1.1  tsutsui 	struct sysvbfs_mount *bmp = mp->mnt_data;
    312  1.1  tsutsui 	struct sysvbfs_node *bnode;
    313  1.1  tsutsui 	struct vnode *v;
    314  1.1  tsutsui 	int err, error;
    315  1.1  tsutsui 
    316  1.1  tsutsui 	DPRINTF("%s:\n", __FUNCTION__);
    317  1.1  tsutsui 	error = 0;
    318  1.1  tsutsui 	simple_lock(&mntvnode_slock);
    319  1.1  tsutsui 	for (bnode = LIST_FIRST(&bmp->bnode_head); bnode != NULL;
    320  1.1  tsutsui 	    bnode = LIST_NEXT(bnode, link)) {
    321  1.1  tsutsui 		simple_unlock(&mntvnode_slock);
    322  1.1  tsutsui 		v = bnode->vnode;
    323  1.1  tsutsui 		err = vget(v, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK);
    324  1.1  tsutsui 		if (err == 0) {
    325  1.1  tsutsui 			err = VOP_FSYNC(v, cred, FSYNC_WAIT, 0, 0, l);
    326  1.1  tsutsui 			vput(v);
    327  1.1  tsutsui 		}
    328  1.1  tsutsui 		if (err != 0)
    329  1.1  tsutsui 			error = err;
    330  1.1  tsutsui 		simple_lock(&mntvnode_slock);
    331  1.1  tsutsui 	}
    332  1.1  tsutsui 	simple_unlock(&mntvnode_slock);
    333  1.1  tsutsui 
    334  1.1  tsutsui 	return error;
    335  1.1  tsutsui }
    336  1.1  tsutsui 
    337  1.1  tsutsui int
    338  1.1  tsutsui sysvbfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
    339  1.1  tsutsui {
    340  1.1  tsutsui 	struct sysvbfs_mount *bmp = mp->mnt_data;
    341  1.1  tsutsui 	struct bfs *bfs = bmp->bfs;
    342  1.1  tsutsui 	struct vnode *vp;
    343  1.1  tsutsui 	struct sysvbfs_node *bnode;
    344  1.1  tsutsui 	struct bfs_inode *inode;
    345  1.1  tsutsui 	int error;
    346  1.1  tsutsui 
    347  1.1  tsutsui 	DPRINTF("%s: i-node=%d\n", __FUNCTION__, ino);
    348  1.1  tsutsui 	/* Lookup requested i-node */
    349  1.1  tsutsui 	if (!bfs_inode_lookup(bfs, ino, &inode)) {
    350  1.1  tsutsui 		DPRINTF("bfs_inode_lookup failed.\n");
    351  1.1  tsutsui 		return ENOENT;
    352  1.1  tsutsui 	}
    353  1.1  tsutsui 	for (bnode = LIST_FIRST(&bmp->bnode_head); bnode != NULL;
    354  1.1  tsutsui 	    bnode = LIST_NEXT(bnode, link)) {
    355  1.1  tsutsui 		if (bnode->inode->number == ino) {
    356  1.1  tsutsui 			*vpp = bnode->vnode;
    357  1.1  tsutsui 		}
    358  1.1  tsutsui 	}
    359  1.1  tsutsui 
    360  1.1  tsutsui 	/* Allocate v-node. */
    361  1.1  tsutsui 	if ((error = getnewvnode(VT_SYSVBFS, mp, sysvbfs_vnodeop_p, &vp)) !=
    362  1.1  tsutsui 	    0) {
    363  1.1  tsutsui 		DPRINTF("%s: getnewvnode error.\n", __FUNCTION__);
    364  1.1  tsutsui 		return error;
    365  1.1  tsutsui 	}
    366  1.1  tsutsui 	/* Lock vnode here */
    367  1.1  tsutsui 	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
    368  1.1  tsutsui 
    369  1.1  tsutsui 	/* Allocate i-node */
    370  1.1  tsutsui 	vp->v_data = pool_get(&sysvbfs_node_pool, PR_WAITOK);
    371  1.1  tsutsui 	memset(vp->v_data, 0, sizeof(struct sysvbfs_node));
    372  1.1  tsutsui 	bnode = vp->v_data;
    373  1.1  tsutsui 	simple_lock(&mntvnode_slock);
    374  1.1  tsutsui 	LIST_INSERT_HEAD(&bmp->bnode_head, bnode, link);
    375  1.1  tsutsui 	simple_unlock(&mntvnode_slock);
    376  1.1  tsutsui 	bnode->vnode = vp;
    377  1.1  tsutsui 	bnode->bmp = bmp;
    378  1.1  tsutsui 	bnode->inode = inode;
    379  1.1  tsutsui 	bnode->lockf = NULL; /* advlock */
    380  1.1  tsutsui 
    381  1.1  tsutsui 	if (ino == BFS_ROOT_INODE) {	/* BFS is flat filesystem */
    382  1.1  tsutsui 		vp->v_type = VDIR;
    383  1.1  tsutsui 		vp->v_flag |= VROOT;
    384  1.1  tsutsui 	} else {
    385  1.1  tsutsui 		vp->v_type = VREG;
    386  1.1  tsutsui 	}
    387  1.1  tsutsui 	vp->v_size = bfs_file_size(inode);
    388  1.1  tsutsui 
    389  1.1  tsutsui 	genfs_node_init(vp, &sysvbfs_genfsops);
    390  1.1  tsutsui 	uvm_vnp_setsize(vp, vp->v_size);
    391  1.1  tsutsui 	*vpp = vp;
    392  1.1  tsutsui 
    393  1.1  tsutsui 	return 0;
    394  1.1  tsutsui }
    395  1.1  tsutsui 
    396  1.1  tsutsui int
    397  1.1  tsutsui sysvbfs_fhtovp(struct mount *mp, struct fid *fid, struct vnode **vpp)
    398  1.1  tsutsui {
    399  1.1  tsutsui 
    400  1.1  tsutsui 	DPRINTF("%s:\n", __FUNCTION__);
    401  1.1  tsutsui 	/* notyet */
    402  1.1  tsutsui 	return EOPNOTSUPP;
    403  1.1  tsutsui }
    404  1.1  tsutsui 
    405  1.1  tsutsui int
    406  1.1  tsutsui sysvbfs_vptofh(struct vnode *vpp, struct fid *fid)
    407  1.1  tsutsui {
    408  1.1  tsutsui 
    409  1.1  tsutsui 	DPRINTF("%s:\n", __FUNCTION__);
    410  1.1  tsutsui 	/* notyet */
    411  1.1  tsutsui 	return EOPNOTSUPP;
    412  1.1  tsutsui }
    413  1.1  tsutsui 
    414  1.1  tsutsui void
    415  1.1  tsutsui sysvbfs_init(void)
    416  1.1  tsutsui {
    417  1.1  tsutsui 
    418  1.1  tsutsui 	/* Nothing to do. */
    419  1.1  tsutsui 	DPRINTF("%s:\n", __FUNCTION__);
    420  1.1  tsutsui }
    421  1.1  tsutsui 
    422  1.1  tsutsui void
    423  1.1  tsutsui sysvbfs_reinit(void)
    424  1.1  tsutsui {
    425  1.1  tsutsui 
    426  1.1  tsutsui 	/* Nothing to do. */
    427  1.1  tsutsui 	DPRINTF("%s:\n", __FUNCTION__);
    428  1.1  tsutsui }
    429  1.1  tsutsui 
    430  1.1  tsutsui void
    431  1.1  tsutsui sysvbfs_done(void)
    432  1.1  tsutsui {
    433  1.1  tsutsui 
    434  1.1  tsutsui 	DPRINTF("%s:\n", __FUNCTION__);
    435  1.1  tsutsui 	pool_destroy(&sysvbfs_node_pool);
    436  1.1  tsutsui }
    437  1.1  tsutsui 
    438  1.1  tsutsui int
    439  1.1  tsutsui sysvbfs_gop_alloc(struct vnode *vp, off_t off, off_t len, int flags,
    440  1.3     elad     kauth_cred_t cred)
    441  1.1  tsutsui {
    442  1.1  tsutsui 
    443  1.1  tsutsui 	return 0;
    444  1.1  tsutsui }
    445