Home | History | Annotate | Line # | Download | only in sysvbfs
sysvbfs.c revision 1.9.8.1
      1  1.9.8.1      yamt /*	$NetBSD: sysvbfs.c,v 1.9.8.1 2008/05/18 12:35:02 yamt 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.9.8.1      yamt __KERNEL_RCSID(0, "$NetBSD: sysvbfs.c,v 1.9.8.1 2008/05/18 12:35:02 yamt Exp $");
     34      1.1   tsutsui 
     35      1.1   tsutsui #include <sys/resource.h>
     36      1.2    martin #include <sys/param.h>
     37      1.1   tsutsui #include <sys/vnode.h>
     38      1.1   tsutsui #include <sys/mount.h>
     39  1.9.8.1      yamt #include <sys/module.h>
     40      1.1   tsutsui #include <miscfs/genfs/genfs.h>
     41      1.1   tsutsui #include <miscfs/genfs/genfs_node.h>
     42      1.1   tsutsui #include <fs/sysvbfs/sysvbfs.h>
     43      1.1   tsutsui 
     44  1.9.8.1      yamt MODULE(MODULE_CLASS_VFS, sysvbfs, NULL);
     45  1.9.8.1      yamt 
     46      1.1   tsutsui /* External interfaces */
     47      1.1   tsutsui 
     48      1.1   tsutsui int (**sysvbfs_vnodeop_p)(void *);	/* filled by getnewvnode (vnode.h) */
     49      1.1   tsutsui 
     50      1.1   tsutsui const struct vnodeopv_entry_desc sysvbfs_vnodeop_entries[] = {
     51      1.1   tsutsui 	{ &vop_default_desc, vn_default_error },
     52      1.1   tsutsui 	{ &vop_lookup_desc, sysvbfs_lookup },		/* lookup */
     53      1.1   tsutsui 	{ &vop_create_desc, sysvbfs_create },		/* create */
     54      1.1   tsutsui 	{ &vop_mknod_desc, genfs_eopnotsupp },		/* mknod */
     55      1.1   tsutsui 	{ &vop_open_desc, sysvbfs_open },		/* open */
     56      1.1   tsutsui 	{ &vop_close_desc, sysvbfs_close },		/* close */
     57      1.1   tsutsui 	{ &vop_access_desc, sysvbfs_access },		/* access */
     58      1.1   tsutsui 	{ &vop_getattr_desc, sysvbfs_getattr },		/* getattr */
     59      1.1   tsutsui 	{ &vop_setattr_desc, sysvbfs_setattr },		/* setattr */
     60      1.1   tsutsui 	{ &vop_read_desc, sysvbfs_read },		/* read */
     61      1.1   tsutsui 	{ &vop_write_desc, sysvbfs_write },		/* write */
     62      1.1   tsutsui 	{ &vop_fcntl_desc, genfs_fcntl },		/* fcntl */
     63      1.1   tsutsui 	{ &vop_ioctl_desc, genfs_enoioctl },		/* ioctl */
     64      1.1   tsutsui 	{ &vop_poll_desc, genfs_poll },			/* poll */
     65      1.1   tsutsui 	{ &vop_kqfilter_desc, genfs_kqfilter },		/* kqfilter */
     66      1.1   tsutsui 	{ &vop_revoke_desc, genfs_revoke },		/* revoke */
     67      1.1   tsutsui 	{ &vop_mmap_desc, genfs_mmap },			/* mmap */
     68      1.1   tsutsui 	{ &vop_fsync_desc, sysvbfs_fsync },		/* fsync */
     69      1.1   tsutsui 	{ &vop_seek_desc, genfs_seek },			/* seek */
     70      1.1   tsutsui 	{ &vop_remove_desc, sysvbfs_remove },		/* remove */
     71      1.1   tsutsui 	{ &vop_link_desc, genfs_eopnotsupp },		/* link */
     72      1.1   tsutsui 	{ &vop_rename_desc, sysvbfs_rename },		/* rename */
     73      1.1   tsutsui 	{ &vop_mkdir_desc, genfs_eopnotsupp },		/* mkdir */
     74      1.1   tsutsui 	{ &vop_rmdir_desc, genfs_eopnotsupp },		/* rmdir */
     75      1.1   tsutsui 	{ &vop_symlink_desc, genfs_eopnotsupp },	/* symlink */
     76      1.1   tsutsui 	{ &vop_readdir_desc, sysvbfs_readdir },		/* readdir */
     77      1.1   tsutsui 	{ &vop_readlink_desc, genfs_eopnotsupp },	/* readlink */
     78      1.1   tsutsui 	{ &vop_abortop_desc, genfs_abortop },		/* abortop */
     79      1.1   tsutsui 	{ &vop_inactive_desc, sysvbfs_inactive },	/* inactive */
     80      1.1   tsutsui 	{ &vop_reclaim_desc, sysvbfs_reclaim },		/* reclaim */
     81      1.1   tsutsui 	{ &vop_lock_desc, genfs_lock },			/* lock */
     82      1.1   tsutsui 	{ &vop_unlock_desc, genfs_unlock },		/* unlock */
     83      1.1   tsutsui 	{ &vop_bmap_desc, sysvbfs_bmap },		/* bmap */
     84      1.1   tsutsui 	{ &vop_strategy_desc, sysvbfs_strategy },	/* strategy */
     85      1.1   tsutsui 	{ &vop_print_desc, sysvbfs_print },		/* print */
     86      1.1   tsutsui 	{ &vop_islocked_desc, genfs_islocked },		/* islocked */
     87      1.1   tsutsui 	{ &vop_pathconf_desc, sysvbfs_pathconf },	/* pathconf */
     88      1.1   tsutsui 	{ &vop_advlock_desc, sysvbfs_advlock },		/* advlock */
     89      1.1   tsutsui 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
     90      1.1   tsutsui 	{ &vop_getpages_desc, genfs_getpages },		/* getpages */
     91      1.1   tsutsui 	{ &vop_putpages_desc, genfs_putpages },		/* putpages */
     92      1.1   tsutsui 	{ NULL, NULL }
     93      1.1   tsutsui };
     94      1.1   tsutsui 
     95      1.1   tsutsui const struct vnodeopv_desc sysvbfs_vnodeop_opv_desc = {
     96      1.1   tsutsui 	&sysvbfs_vnodeop_p,
     97      1.1   tsutsui 	sysvbfs_vnodeop_entries
     98      1.1   tsutsui };
     99      1.1   tsutsui 
    100      1.1   tsutsui const struct vnodeopv_desc *sysvbfs_vnodeopv_descs[] = {
    101      1.1   tsutsui 	&sysvbfs_vnodeop_opv_desc,
    102      1.1   tsutsui 	NULL,
    103      1.1   tsutsui };
    104      1.1   tsutsui 
    105      1.1   tsutsui const struct genfs_ops sysvbfs_genfsops = {
    106      1.1   tsutsui 	.gop_size = genfs_size,
    107      1.1   tsutsui 	.gop_alloc = sysvbfs_gop_alloc,
    108      1.1   tsutsui 	.gop_write = genfs_gop_write,
    109      1.1   tsutsui };
    110      1.1   tsutsui 
    111      1.1   tsutsui struct vfsops sysvbfs_vfsops = {
    112      1.1   tsutsui 	MOUNT_SYSVBFS,
    113      1.5       dsl 	sizeof (struct sysvbfs_args),
    114      1.1   tsutsui 	sysvbfs_mount,
    115      1.1   tsutsui 	sysvbfs_start,
    116      1.1   tsutsui 	sysvbfs_unmount,
    117      1.1   tsutsui 	sysvbfs_root,
    118      1.7     pooka 	(void *)eopnotsupp,	/* vfs_quotactl */
    119      1.1   tsutsui 	sysvbfs_statvfs,
    120      1.1   tsutsui 	sysvbfs_sync,
    121      1.1   tsutsui 	sysvbfs_vget,
    122      1.1   tsutsui 	sysvbfs_fhtovp,
    123      1.1   tsutsui 	sysvbfs_vptofh,
    124      1.1   tsutsui 	sysvbfs_init,
    125      1.1   tsutsui 	sysvbfs_reinit,
    126      1.1   tsutsui 	sysvbfs_done,
    127      1.1   tsutsui 	NULL,			/* vfs_mountroot */
    128      1.1   tsutsui 	(int (*)(struct mount *, struct vnode *, struct timespec *))
    129      1.1   tsutsui 	    eopnotsupp,		/* snapshot */
    130      1.1   tsutsui 	vfs_stdextattrctl,
    131      1.6     pooka 	(void *)eopnotsupp,	/* vfs_suspendctl */
    132      1.9  dholland 	genfs_renamelock_enter,
    133      1.9  dholland 	genfs_renamelock_exit,
    134  1.9.8.1      yamt 	(void *)eopnotsupp,
    135      1.1   tsutsui 	sysvbfs_vnodeopv_descs,
    136      1.3       chs 	0,
    137      1.3       chs 	{ NULL, NULL }
    138      1.1   tsutsui };
    139  1.9.8.1      yamt 
    140  1.9.8.1      yamt static int
    141  1.9.8.1      yamt sysvbfs_modcmd(modcmd_t cmd, void *arg)
    142  1.9.8.1      yamt {
    143  1.9.8.1      yamt 
    144  1.9.8.1      yamt 	switch (cmd) {
    145  1.9.8.1      yamt 	case MODULE_CMD_INIT:
    146  1.9.8.1      yamt 		return vfs_attach(&sysvbfs_vfsops);
    147  1.9.8.1      yamt 	case MODULE_CMD_FINI:
    148  1.9.8.1      yamt 		return vfs_detach(&sysvbfs_vfsops);
    149  1.9.8.1      yamt 	default:
    150  1.9.8.1      yamt 		return ENOTTY;
    151  1.9.8.1      yamt 	}
    152  1.9.8.1      yamt }
    153