Home | History | Annotate | Line # | Download | only in sysvbfs
sysvbfs.c revision 1.15.2.1
      1  1.15.2.1  pgoyette /*	$NetBSD: sysvbfs.c,v 1.15.2.1 2017/03/20 06:57:47 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.15.2.1  pgoyette __KERNEL_RCSID(0, "$NetBSD: sysvbfs.c,v 1.15.2.1 2017/03/20 06:57:47 pgoyette 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.14  dholland 	{ &vop_fallocate_desc, genfs_eopnotsupp },	/* fallocate */
     63      1.14  dholland 	{ &vop_fdiscard_desc, genfs_eopnotsupp },	/* fdiscard */
     64       1.1   tsutsui 	{ &vop_fcntl_desc, genfs_fcntl },		/* fcntl */
     65       1.1   tsutsui 	{ &vop_ioctl_desc, genfs_enoioctl },		/* ioctl */
     66       1.1   tsutsui 	{ &vop_poll_desc, genfs_poll },			/* poll */
     67       1.1   tsutsui 	{ &vop_kqfilter_desc, genfs_kqfilter },		/* kqfilter */
     68       1.1   tsutsui 	{ &vop_revoke_desc, genfs_revoke },		/* revoke */
     69       1.1   tsutsui 	{ &vop_mmap_desc, genfs_mmap },			/* mmap */
     70       1.1   tsutsui 	{ &vop_fsync_desc, sysvbfs_fsync },		/* fsync */
     71       1.1   tsutsui 	{ &vop_seek_desc, genfs_seek },			/* seek */
     72       1.1   tsutsui 	{ &vop_remove_desc, sysvbfs_remove },		/* remove */
     73       1.1   tsutsui 	{ &vop_link_desc, genfs_eopnotsupp },		/* link */
     74       1.1   tsutsui 	{ &vop_rename_desc, sysvbfs_rename },		/* rename */
     75       1.1   tsutsui 	{ &vop_mkdir_desc, genfs_eopnotsupp },		/* mkdir */
     76       1.1   tsutsui 	{ &vop_rmdir_desc, genfs_eopnotsupp },		/* rmdir */
     77       1.1   tsutsui 	{ &vop_symlink_desc, genfs_eopnotsupp },	/* symlink */
     78       1.1   tsutsui 	{ &vop_readdir_desc, sysvbfs_readdir },		/* readdir */
     79       1.1   tsutsui 	{ &vop_readlink_desc, genfs_eopnotsupp },	/* readlink */
     80       1.1   tsutsui 	{ &vop_abortop_desc, genfs_abortop },		/* abortop */
     81       1.1   tsutsui 	{ &vop_inactive_desc, sysvbfs_inactive },	/* inactive */
     82       1.1   tsutsui 	{ &vop_reclaim_desc, sysvbfs_reclaim },		/* reclaim */
     83       1.1   tsutsui 	{ &vop_lock_desc, genfs_lock },			/* lock */
     84       1.1   tsutsui 	{ &vop_unlock_desc, genfs_unlock },		/* unlock */
     85       1.1   tsutsui 	{ &vop_bmap_desc, sysvbfs_bmap },		/* bmap */
     86       1.1   tsutsui 	{ &vop_strategy_desc, sysvbfs_strategy },	/* strategy */
     87       1.1   tsutsui 	{ &vop_print_desc, sysvbfs_print },		/* print */
     88       1.1   tsutsui 	{ &vop_islocked_desc, genfs_islocked },		/* islocked */
     89       1.1   tsutsui 	{ &vop_pathconf_desc, sysvbfs_pathconf },	/* pathconf */
     90       1.1   tsutsui 	{ &vop_advlock_desc, sysvbfs_advlock },		/* advlock */
     91       1.1   tsutsui 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
     92       1.1   tsutsui 	{ &vop_getpages_desc, genfs_getpages },		/* getpages */
     93       1.1   tsutsui 	{ &vop_putpages_desc, genfs_putpages },		/* putpages */
     94       1.1   tsutsui 	{ NULL, NULL }
     95       1.1   tsutsui };
     96       1.1   tsutsui 
     97       1.1   tsutsui const struct vnodeopv_desc sysvbfs_vnodeop_opv_desc = {
     98       1.1   tsutsui 	&sysvbfs_vnodeop_p,
     99       1.1   tsutsui 	sysvbfs_vnodeop_entries
    100       1.1   tsutsui };
    101       1.1   tsutsui 
    102       1.1   tsutsui const struct vnodeopv_desc *sysvbfs_vnodeopv_descs[] = {
    103       1.1   tsutsui 	&sysvbfs_vnodeop_opv_desc,
    104       1.1   tsutsui 	NULL,
    105       1.1   tsutsui };
    106       1.1   tsutsui 
    107       1.1   tsutsui const struct genfs_ops sysvbfs_genfsops = {
    108       1.1   tsutsui 	.gop_size = genfs_size,
    109       1.1   tsutsui 	.gop_alloc = sysvbfs_gop_alloc,
    110       1.1   tsutsui 	.gop_write = genfs_gop_write,
    111       1.1   tsutsui };
    112       1.1   tsutsui 
    113       1.1   tsutsui struct vfsops sysvbfs_vfsops = {
    114      1.13   hannken 	.vfs_name = MOUNT_SYSVBFS,
    115      1.13   hannken 	.vfs_min_mount_data = sizeof (struct sysvbfs_args),
    116      1.13   hannken 	.vfs_mount = sysvbfs_mount,
    117      1.13   hannken 	.vfs_start = sysvbfs_start,
    118      1.13   hannken 	.vfs_unmount = sysvbfs_unmount,
    119      1.13   hannken 	.vfs_root = sysvbfs_root,
    120      1.13   hannken 	.vfs_quotactl = (void *)eopnotsupp,
    121      1.13   hannken 	.vfs_statvfs = sysvbfs_statvfs,
    122      1.13   hannken 	.vfs_sync = sysvbfs_sync,
    123      1.13   hannken 	.vfs_vget = sysvbfs_vget,
    124      1.15   hannken 	.vfs_loadvnode = sysvbfs_loadvnode,
    125      1.13   hannken 	.vfs_fhtovp = sysvbfs_fhtovp,
    126      1.13   hannken 	.vfs_vptofh = sysvbfs_vptofh,
    127      1.13   hannken 	.vfs_init = sysvbfs_init,
    128      1.13   hannken 	.vfs_reinit = sysvbfs_reinit,
    129      1.13   hannken 	.vfs_done = sysvbfs_done,
    130      1.13   hannken 	.vfs_snapshot = (void *)eopnotsupp,
    131      1.13   hannken 	.vfs_extattrctl = vfs_stdextattrctl,
    132  1.15.2.1  pgoyette 	.vfs_suspendctl = genfs_suspendctl,
    133      1.13   hannken 	.vfs_renamelock_enter = genfs_renamelock_enter,
    134      1.13   hannken 	.vfs_renamelock_exit = genfs_renamelock_exit,
    135      1.13   hannken 	.vfs_fsync = (void *)eopnotsupp,
    136      1.13   hannken 	.vfs_opv_descs = sysvbfs_vnodeopv_descs
    137       1.1   tsutsui };
    138      1.12    rumble 
    139      1.12    rumble static int
    140      1.12    rumble sysvbfs_modcmd(modcmd_t cmd, void *arg)
    141      1.12    rumble {
    142      1.12    rumble 
    143      1.12    rumble 	switch (cmd) {
    144      1.12    rumble 	case MODULE_CMD_INIT:
    145      1.12    rumble 		return vfs_attach(&sysvbfs_vfsops);
    146      1.12    rumble 	case MODULE_CMD_FINI:
    147      1.12    rumble 		return vfs_detach(&sysvbfs_vfsops);
    148      1.12    rumble 	default:
    149      1.12    rumble 		return ENOTTY;
    150      1.12    rumble 	}
    151      1.12    rumble }
    152