Home | History | Annotate | Line # | Download | only in sysvbfs
sysvbfs.c revision 1.13
      1  1.13  hannken /*	$NetBSD: sysvbfs.c,v 1.13 2014/03/23 15:21:15 hannken 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.13  hannken __KERNEL_RCSID(0, "$NetBSD: sysvbfs.c,v 1.13 2014/03/23 15:21:15 hannken 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.12   rumble #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.12   rumble MODULE(MODULE_CLASS_VFS, sysvbfs, NULL);
     45  1.12   rumble 
     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.13  hannken 	.vfs_name = MOUNT_SYSVBFS,
    113  1.13  hannken 	.vfs_min_mount_data = sizeof (struct sysvbfs_args),
    114  1.13  hannken 	.vfs_mount = sysvbfs_mount,
    115  1.13  hannken 	.vfs_start = sysvbfs_start,
    116  1.13  hannken 	.vfs_unmount = sysvbfs_unmount,
    117  1.13  hannken 	.vfs_root = sysvbfs_root,
    118  1.13  hannken 	.vfs_quotactl = (void *)eopnotsupp,
    119  1.13  hannken 	.vfs_statvfs = sysvbfs_statvfs,
    120  1.13  hannken 	.vfs_sync = sysvbfs_sync,
    121  1.13  hannken 	.vfs_vget = sysvbfs_vget,
    122  1.13  hannken 	.vfs_fhtovp = sysvbfs_fhtovp,
    123  1.13  hannken 	.vfs_vptofh = sysvbfs_vptofh,
    124  1.13  hannken 	.vfs_init = sysvbfs_init,
    125  1.13  hannken 	.vfs_reinit = sysvbfs_reinit,
    126  1.13  hannken 	.vfs_done = sysvbfs_done,
    127  1.13  hannken 	.vfs_snapshot = (void *)eopnotsupp,
    128  1.13  hannken 	.vfs_extattrctl = vfs_stdextattrctl,
    129  1.13  hannken 	.vfs_suspendctl = (void *)eopnotsupp,
    130  1.13  hannken 	.vfs_renamelock_enter = genfs_renamelock_enter,
    131  1.13  hannken 	.vfs_renamelock_exit = genfs_renamelock_exit,
    132  1.13  hannken 	.vfs_fsync = (void *)eopnotsupp,
    133  1.13  hannken 	.vfs_opv_descs = sysvbfs_vnodeopv_descs
    134   1.1  tsutsui };
    135  1.12   rumble 
    136  1.12   rumble static int
    137  1.12   rumble sysvbfs_modcmd(modcmd_t cmd, void *arg)
    138  1.12   rumble {
    139  1.12   rumble 
    140  1.12   rumble 	switch (cmd) {
    141  1.12   rumble 	case MODULE_CMD_INIT:
    142  1.12   rumble 		return vfs_attach(&sysvbfs_vfsops);
    143  1.12   rumble 	case MODULE_CMD_FINI:
    144  1.12   rumble 		return vfs_detach(&sysvbfs_vfsops);
    145  1.12   rumble 	default:
    146  1.12   rumble 		return ENOTTY;
    147  1.12   rumble 	}
    148  1.12   rumble }
    149