Home | History | Annotate | Line # | Download | only in lfs
lfs_vnops.c revision 1.31.2.2
      1  1.31.2.2  perseant /*	$NetBSD: lfs_vnops.c,v 1.31.2.2 1999/11/06 20:33:07 perseant Exp $	*/
      2  1.31.2.2  perseant 
      3  1.31.2.2  perseant /*-
      4  1.31.2.2  perseant  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5  1.31.2.2  perseant  * All rights reserved.
      6  1.31.2.2  perseant  *
      7  1.31.2.2  perseant  * This code is derived from software contributed to The NetBSD Foundation
      8  1.31.2.2  perseant  * by Konrad E. Schroder <perseant (at) hhhh.org>.
      9  1.31.2.2  perseant  *
     10  1.31.2.2  perseant  * Redistribution and use in source and binary forms, with or without
     11  1.31.2.2  perseant  * modification, are permitted provided that the following conditions
     12  1.31.2.2  perseant  * are met:
     13  1.31.2.2  perseant  * 1. Redistributions of source code must retain the above copyright
     14  1.31.2.2  perseant  *    notice, this list of conditions and the following disclaimer.
     15  1.31.2.2  perseant  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.31.2.2  perseant  *    notice, this list of conditions and the following disclaimer in the
     17  1.31.2.2  perseant  *    documentation and/or other materials provided with the distribution.
     18  1.31.2.2  perseant  * 3. All advertising materials mentioning features or use of this software
     19  1.31.2.2  perseant  *    must display the following acknowledgement:
     20  1.31.2.2  perseant  *      This product includes software developed by the NetBSD
     21  1.31.2.2  perseant  *      Foundation, Inc. and its contributors.
     22  1.31.2.2  perseant  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.31.2.2  perseant  *    contributors may be used to endorse or promote products derived
     24  1.31.2.2  perseant  *    from this software without specific prior written permission.
     25  1.31.2.2  perseant  *
     26  1.31.2.2  perseant  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.31.2.2  perseant  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.31.2.2  perseant  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.31.2.2  perseant  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.31.2.2  perseant  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.31.2.2  perseant  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.31.2.2  perseant  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.31.2.2  perseant  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.31.2.2  perseant  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.31.2.2  perseant  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.31.2.2  perseant  * POSSIBILITY OF SUCH DAMAGE.
     37  1.31.2.2  perseant  */
     38  1.31.2.2  perseant /*
     39  1.31.2.2  perseant  * Copyright (c) 1986, 1989, 1991, 1993, 1995
     40  1.31.2.2  perseant  *	The Regents of the University of California.  All rights reserved.
     41  1.31.2.2  perseant  *
     42  1.31.2.2  perseant  * Redistribution and use in source and binary forms, with or without
     43  1.31.2.2  perseant  * modification, are permitted provided that the following conditions
     44  1.31.2.2  perseant  * are met:
     45  1.31.2.2  perseant  * 1. Redistributions of source code must retain the above copyright
     46  1.31.2.2  perseant  *    notice, this list of conditions and the following disclaimer.
     47  1.31.2.2  perseant  * 2. Redistributions in binary form must reproduce the above copyright
     48  1.31.2.2  perseant  *    notice, this list of conditions and the following disclaimer in the
     49  1.31.2.2  perseant  *    documentation and/or other materials provided with the distribution.
     50  1.31.2.2  perseant  * 3. All advertising materials mentioning features or use of this software
     51  1.31.2.2  perseant  *    must display the following acknowledgement:
     52  1.31.2.2  perseant  *	This product includes software developed by the University of
     53  1.31.2.2  perseant  *	California, Berkeley and its contributors.
     54  1.31.2.2  perseant  * 4. Neither the name of the University nor the names of its contributors
     55  1.31.2.2  perseant  *    may be used to endorse or promote products derived from this software
     56  1.31.2.2  perseant  *    without specific prior written permission.
     57  1.31.2.2  perseant  *
     58  1.31.2.2  perseant  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     59  1.31.2.2  perseant  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     60  1.31.2.2  perseant  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     61  1.31.2.2  perseant  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     62  1.31.2.2  perseant  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     63  1.31.2.2  perseant  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     64  1.31.2.2  perseant  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     65  1.31.2.2  perseant  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     66  1.31.2.2  perseant  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     67  1.31.2.2  perseant  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     68  1.31.2.2  perseant  * SUCH DAMAGE.
     69  1.31.2.2  perseant  *
     70  1.31.2.2  perseant  *	@(#)lfs_vnops.c	8.13 (Berkeley) 6/10/95
     71  1.31.2.2  perseant  */
     72  1.31.2.2  perseant 
     73  1.31.2.2  perseant #include <sys/param.h>
     74  1.31.2.2  perseant #include <sys/systm.h>
     75  1.31.2.2  perseant #include <sys/namei.h>
     76  1.31.2.2  perseant #include <sys/resourcevar.h>
     77  1.31.2.2  perseant #include <sys/kernel.h>
     78  1.31.2.2  perseant #include <sys/file.h>
     79  1.31.2.2  perseant #include <sys/stat.h>
     80  1.31.2.2  perseant #include <sys/buf.h>
     81  1.31.2.2  perseant #include <sys/proc.h>
     82  1.31.2.2  perseant #include <sys/conf.h>
     83  1.31.2.2  perseant #include <sys/mount.h>
     84  1.31.2.2  perseant #include <sys/vnode.h>
     85  1.31.2.2  perseant #include <sys/malloc.h>
     86  1.31.2.2  perseant #include <sys/pool.h>
     87  1.31.2.2  perseant #include <sys/signalvar.h>
     88  1.31.2.2  perseant 
     89  1.31.2.2  perseant #include <vm/vm.h>
     90  1.31.2.2  perseant 
     91  1.31.2.2  perseant #include <miscfs/fifofs/fifo.h>
     92  1.31.2.2  perseant #include <miscfs/genfs/genfs.h>
     93  1.31.2.2  perseant #include <miscfs/specfs/specdev.h>
     94  1.31.2.2  perseant 
     95  1.31.2.2  perseant #include <ufs/ufs/quota.h>
     96  1.31.2.2  perseant #include <ufs/ufs/inode.h>
     97  1.31.2.2  perseant #include <ufs/ufs/dir.h>
     98  1.31.2.2  perseant #include <ufs/ufs/ufsmount.h>
     99  1.31.2.2  perseant #include <ufs/ufs/ufs_extern.h>
    100  1.31.2.2  perseant 
    101  1.31.2.2  perseant #include <ufs/lfs/lfs.h>
    102  1.31.2.2  perseant #include <ufs/lfs/lfs_extern.h>
    103  1.31.2.2  perseant 
    104  1.31.2.2  perseant /* Global vfs data structures for lfs. */
    105  1.31.2.2  perseant int (**lfs_vnodeop_p) __P((void *));
    106  1.31.2.2  perseant struct vnodeopv_entry_desc lfs_vnodeop_entries[] = {
    107  1.31.2.2  perseant 	{ &vop_default_desc, vn_default_error },
    108  1.31.2.2  perseant 	{ &vop_lookup_desc, ufs_lookup },		/* lookup */
    109  1.31.2.2  perseant 	{ &vop_create_desc, lfs_create },		/* create */
    110  1.31.2.2  perseant 	{ &vop_whiteout_desc, lfs_whiteout },		/* whiteout */
    111  1.31.2.2  perseant 	{ &vop_mknod_desc, lfs_mknod },			/* mknod */
    112  1.31.2.2  perseant 	{ &vop_open_desc, ufs_open },			/* open */
    113  1.31.2.2  perseant 	{ &vop_close_desc, lfs_close },			/* close */
    114  1.31.2.2  perseant 	{ &vop_access_desc, ufs_access },		/* access */
    115  1.31.2.2  perseant 	{ &vop_getattr_desc, lfs_getattr },		/* getattr */
    116  1.31.2.2  perseant 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
    117  1.31.2.2  perseant 	{ &vop_read_desc, lfs_read },			/* read */
    118  1.31.2.2  perseant 	{ &vop_write_desc, lfs_write },			/* write */
    119  1.31.2.2  perseant 	{ &vop_lease_desc, ufs_lease_check },		/* lease */
    120  1.31.2.2  perseant 	{ &vop_ioctl_desc, ufs_ioctl },			/* ioctl */
    121  1.31.2.2  perseant 	{ &vop_fcntl_desc, ufs_fcntl },			/* fcntl */
    122  1.31.2.2  perseant 	{ &vop_poll_desc, ufs_poll },			/* poll */
    123  1.31.2.2  perseant 	{ &vop_revoke_desc, ufs_revoke },		/* revoke */
    124  1.31.2.2  perseant 	{ &vop_mmap_desc, ufs_mmap },			/* mmap */
    125  1.31.2.2  perseant 	{ &vop_fsync_desc, lfs_fsync },			/* fsync */
    126  1.31.2.2  perseant 	{ &vop_seek_desc, ufs_seek },			/* seek */
    127  1.31.2.2  perseant 	{ &vop_remove_desc, lfs_remove },		/* remove */
    128  1.31.2.2  perseant 	{ &vop_link_desc, lfs_link },			/* link */
    129  1.31.2.2  perseant 	{ &vop_rename_desc, lfs_rename },		/* rename */
    130  1.31.2.2  perseant 	{ &vop_mkdir_desc, lfs_mkdir },			/* mkdir */
    131  1.31.2.2  perseant 	{ &vop_rmdir_desc, lfs_rmdir },			/* rmdir */
    132  1.31.2.2  perseant 	{ &vop_symlink_desc, lfs_symlink },		/* symlink */
    133  1.31.2.2  perseant 	{ &vop_readdir_desc, ufs_readdir },		/* readdir */
    134  1.31.2.2  perseant 	{ &vop_readlink_desc, ufs_readlink },		/* readlink */
    135  1.31.2.2  perseant 	{ &vop_abortop_desc, ufs_abortop },		/* abortop */
    136  1.31.2.2  perseant 	{ &vop_inactive_desc, ufs_inactive },		/* inactive */
    137  1.31.2.2  perseant 	{ &vop_reclaim_desc, lfs_reclaim },		/* reclaim */
    138  1.31.2.2  perseant 	{ &vop_lock_desc, ufs_lock },			/* lock */
    139  1.31.2.2  perseant 	{ &vop_unlock_desc, ufs_unlock },		/* unlock */
    140  1.31.2.2  perseant 	{ &vop_bmap_desc, ufs_bmap },			/* bmap */
    141  1.31.2.2  perseant 	{ &vop_strategy_desc, ufs_strategy },		/* strategy */
    142  1.31.2.2  perseant 	{ &vop_print_desc, ufs_print },			/* print */
    143  1.31.2.2  perseant 	{ &vop_islocked_desc, ufs_islocked },		/* islocked */
    144  1.31.2.2  perseant 	{ &vop_pathconf_desc, ufs_pathconf },		/* pathconf */
    145  1.31.2.2  perseant 	{ &vop_advlock_desc, ufs_advlock },		/* advlock */
    146  1.31.2.2  perseant 	{ &vop_blkatoff_desc, lfs_blkatoff },		/* blkatoff */
    147  1.31.2.2  perseant 	{ &vop_valloc_desc, lfs_valloc },		/* valloc */
    148  1.31.2.2  perseant 	{ &vop_vfree_desc, lfs_vfree },			/* vfree */
    149  1.31.2.2  perseant 	{ &vop_truncate_desc, lfs_truncate },		/* truncate */
    150  1.31.2.2  perseant 	{ &vop_update_desc, lfs_update },		/* update */
    151  1.31.2.2  perseant 	{ &vop_bwrite_desc, lfs_bwrite },		/* bwrite */
    152  1.31.2.2  perseant 	{ (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL }
    153  1.31.2.2  perseant };
    154  1.31.2.2  perseant struct vnodeopv_desc lfs_vnodeop_opv_desc =
    155  1.31.2.2  perseant 	{ &lfs_vnodeop_p, lfs_vnodeop_entries };
    156  1.31.2.2  perseant 
    157  1.31.2.2  perseant int (**lfs_specop_p) __P((void *));
    158  1.31.2.2  perseant struct vnodeopv_entry_desc lfs_specop_entries[] = {
    159  1.31.2.2  perseant 	{ &vop_default_desc, vn_default_error },
    160  1.31.2.2  perseant 	{ &vop_lookup_desc, spec_lookup },		/* lookup */
    161  1.31.2.2  perseant 	{ &vop_create_desc, spec_create },		/* create */
    162  1.31.2.2  perseant 	{ &vop_mknod_desc, spec_mknod },		/* mknod */
    163  1.31.2.2  perseant 	{ &vop_open_desc, spec_open },			/* open */
    164  1.31.2.2  perseant 	{ &vop_close_desc, ufsspec_close },		/* close */
    165  1.31.2.2  perseant 	{ &vop_access_desc, ufs_access },		/* access */
    166  1.31.2.2  perseant 	{ &vop_getattr_desc, lfs_getattr },		/* getattr */
    167  1.31.2.2  perseant 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
    168  1.31.2.2  perseant 	{ &vop_read_desc, ufsspec_read },		/* read */
    169  1.31.2.2  perseant 	{ &vop_write_desc, ufsspec_write },		/* write */
    170  1.31.2.2  perseant 	{ &vop_lease_desc, spec_lease_check },		/* lease */
    171  1.31.2.2  perseant 	{ &vop_ioctl_desc, spec_ioctl },		/* ioctl */
    172  1.31.2.2  perseant 	{ &vop_fcntl_desc, ufs_fcntl },			/* fcntl */
    173  1.31.2.2  perseant 	{ &vop_poll_desc, spec_poll },			/* poll */
    174  1.31.2.2  perseant 	{ &vop_revoke_desc, spec_revoke },		/* revoke */
    175  1.31.2.2  perseant 	{ &vop_mmap_desc, spec_mmap },			/* mmap */
    176  1.31.2.2  perseant 	{ &vop_fsync_desc, spec_fsync },		/* fsync */
    177  1.31.2.2  perseant 	{ &vop_seek_desc, spec_seek },			/* seek */
    178  1.31.2.2  perseant 	{ &vop_remove_desc, spec_remove },		/* remove */
    179  1.31.2.2  perseant 	{ &vop_link_desc, spec_link },			/* link */
    180  1.31.2.2  perseant 	{ &vop_rename_desc, spec_rename },		/* rename */
    181  1.31.2.2  perseant 	{ &vop_mkdir_desc, spec_mkdir },		/* mkdir */
    182  1.31.2.2  perseant 	{ &vop_rmdir_desc, spec_rmdir },		/* rmdir */
    183  1.31.2.2  perseant 	{ &vop_symlink_desc, spec_symlink },		/* symlink */
    184  1.31.2.2  perseant 	{ &vop_readdir_desc, spec_readdir },		/* readdir */
    185  1.31.2.2  perseant 	{ &vop_readlink_desc, spec_readlink },		/* readlink */
    186  1.31.2.2  perseant 	{ &vop_abortop_desc, spec_abortop },		/* abortop */
    187  1.31.2.2  perseant 	{ &vop_inactive_desc, ufs_inactive },		/* inactive */
    188  1.31.2.2  perseant 	{ &vop_reclaim_desc, lfs_reclaim },		/* reclaim */
    189  1.31.2.2  perseant 	{ &vop_lock_desc, ufs_lock },			/* lock */
    190  1.31.2.2  perseant 	{ &vop_unlock_desc, ufs_unlock },		/* unlock */
    191  1.31.2.2  perseant 	{ &vop_bmap_desc, spec_bmap },			/* bmap */
    192  1.31.2.2  perseant 	{ &vop_strategy_desc, spec_strategy },		/* strategy */
    193  1.31.2.2  perseant 	{ &vop_print_desc, ufs_print },			/* print */
    194  1.31.2.2  perseant 	{ &vop_islocked_desc, ufs_islocked },		/* islocked */
    195  1.31.2.2  perseant 	{ &vop_pathconf_desc, spec_pathconf },		/* pathconf */
    196  1.31.2.2  perseant 	{ &vop_advlock_desc, spec_advlock },		/* advlock */
    197  1.31.2.2  perseant 	{ &vop_blkatoff_desc, spec_blkatoff },		/* blkatoff */
    198  1.31.2.2  perseant 	{ &vop_valloc_desc, spec_valloc },		/* valloc */
    199  1.31.2.2  perseant 	{ &vop_vfree_desc, lfs_vfree },			/* vfree */
    200  1.31.2.2  perseant 	{ &vop_truncate_desc, spec_truncate },		/* truncate */
    201  1.31.2.2  perseant 	{ &vop_update_desc, lfs_update },		/* update */
    202  1.31.2.2  perseant 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
    203  1.31.2.2  perseant 	{ (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL }
    204  1.31.2.2  perseant };
    205  1.31.2.2  perseant struct vnodeopv_desc lfs_specop_opv_desc =
    206  1.31.2.2  perseant 	{ &lfs_specop_p, lfs_specop_entries };
    207  1.31.2.2  perseant 
    208  1.31.2.2  perseant int (**lfs_fifoop_p) __P((void *));
    209  1.31.2.2  perseant struct vnodeopv_entry_desc lfs_fifoop_entries[] = {
    210  1.31.2.2  perseant 	{ &vop_default_desc, vn_default_error },
    211  1.31.2.2  perseant 	{ &vop_lookup_desc, fifo_lookup },		/* lookup */
    212  1.31.2.2  perseant 	{ &vop_create_desc, fifo_create },		/* create */
    213  1.31.2.2  perseant 	{ &vop_mknod_desc, fifo_mknod },		/* mknod */
    214  1.31.2.2  perseant 	{ &vop_open_desc, fifo_open },			/* open */
    215  1.31.2.2  perseant 	{ &vop_close_desc, ufsfifo_close },		/* close */
    216  1.31.2.2  perseant 	{ &vop_access_desc, ufs_access },		/* access */
    217  1.31.2.2  perseant 	{ &vop_getattr_desc, lfs_getattr },		/* getattr */
    218  1.31.2.2  perseant 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
    219  1.31.2.2  perseant 	{ &vop_read_desc, ufsfifo_read },		/* read */
    220  1.31.2.2  perseant 	{ &vop_write_desc, ufsfifo_write },		/* write */
    221  1.31.2.2  perseant 	{ &vop_lease_desc, fifo_lease_check },		/* lease */
    222  1.31.2.2  perseant 	{ &vop_ioctl_desc, fifo_ioctl },		/* ioctl */
    223  1.31.2.2  perseant 	{ &vop_fcntl_desc, ufs_fcntl },			/* fcntl */
    224  1.31.2.2  perseant 	{ &vop_poll_desc, fifo_poll },			/* poll */
    225  1.31.2.2  perseant 	{ &vop_revoke_desc, fifo_revoke },		/* revoke */
    226  1.31.2.2  perseant 	{ &vop_mmap_desc, fifo_mmap },			/* mmap */
    227  1.31.2.2  perseant 	{ &vop_fsync_desc, fifo_fsync },		/* fsync */
    228  1.31.2.2  perseant 	{ &vop_seek_desc, fifo_seek },			/* seek */
    229  1.31.2.2  perseant 	{ &vop_remove_desc, fifo_remove },		/* remove */
    230  1.31.2.2  perseant 	{ &vop_link_desc, fifo_link },			/* link */
    231  1.31.2.2  perseant 	{ &vop_rename_desc, fifo_rename },		/* rename */
    232  1.31.2.2  perseant 	{ &vop_mkdir_desc, fifo_mkdir },		/* mkdir */
    233  1.31.2.2  perseant 	{ &vop_rmdir_desc, fifo_rmdir },		/* rmdir */
    234  1.31.2.2  perseant 	{ &vop_symlink_desc, fifo_symlink },		/* symlink */
    235  1.31.2.2  perseant 	{ &vop_readdir_desc, fifo_readdir },		/* readdir */
    236  1.31.2.2  perseant 	{ &vop_readlink_desc, fifo_readlink },		/* readlink */
    237  1.31.2.2  perseant 	{ &vop_abortop_desc, fifo_abortop },		/* abortop */
    238  1.31.2.2  perseant 	{ &vop_inactive_desc, ufs_inactive },		/* inactive */
    239  1.31.2.2  perseant 	{ &vop_reclaim_desc, lfs_reclaim },		/* reclaim */
    240  1.31.2.2  perseant 	{ &vop_lock_desc, ufs_lock },			/* lock */
    241  1.31.2.2  perseant 	{ &vop_unlock_desc, ufs_unlock },		/* unlock */
    242  1.31.2.2  perseant 	{ &vop_bmap_desc, fifo_bmap },			/* bmap */
    243  1.31.2.2  perseant 	{ &vop_strategy_desc, fifo_strategy },		/* strategy */
    244  1.31.2.2  perseant 	{ &vop_print_desc, ufs_print },			/* print */
    245  1.31.2.2  perseant 	{ &vop_islocked_desc, ufs_islocked },		/* islocked */
    246  1.31.2.2  perseant 	{ &vop_pathconf_desc, fifo_pathconf },		/* pathconf */
    247  1.31.2.2  perseant 	{ &vop_advlock_desc, fifo_advlock },		/* advlock */
    248  1.31.2.2  perseant 	{ &vop_blkatoff_desc, fifo_blkatoff },		/* blkatoff */
    249  1.31.2.2  perseant 	{ &vop_valloc_desc, fifo_valloc },		/* valloc */
    250  1.31.2.2  perseant 	{ &vop_vfree_desc, lfs_vfree },			/* vfree */
    251  1.31.2.2  perseant 	{ &vop_truncate_desc, fifo_truncate },		/* truncate */
    252  1.31.2.2  perseant 	{ &vop_update_desc, lfs_update },		/* update */
    253  1.31.2.2  perseant 	{ &vop_bwrite_desc, lfs_bwrite },		/* bwrite */
    254  1.31.2.2  perseant 	{ (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL }
    255  1.31.2.2  perseant };
    256  1.31.2.2  perseant struct vnodeopv_desc lfs_fifoop_opv_desc =
    257  1.31.2.2  perseant 	{ &lfs_fifoop_p, lfs_fifoop_entries };
    258  1.31.2.2  perseant 
    259  1.31.2.2  perseant #define	LFS_READWRITE
    260  1.31.2.2  perseant #include <ufs/ufs/ufs_readwrite.c>
    261  1.31.2.2  perseant #undef	LFS_READWRITE
    262  1.31.2.2  perseant 
    263  1.31.2.2  perseant /*
    264  1.31.2.2  perseant  * Synch an open file.
    265  1.31.2.2  perseant  */
    266  1.31.2.2  perseant /* ARGSUSED */
    267  1.31.2.2  perseant int
    268  1.31.2.2  perseant lfs_fsync(v)
    269  1.31.2.2  perseant 	void *v;
    270  1.31.2.2  perseant {
    271  1.31.2.2  perseant 	struct vop_fsync_args /* {
    272  1.31.2.2  perseant 		struct vnode *a_vp;
    273  1.31.2.2  perseant 		struct ucred *a_cred;
    274  1.31.2.2  perseant 		int a_flags;
    275  1.31.2.2  perseant 		struct proc *a_p;
    276  1.31.2.2  perseant 	} */ *ap = v;
    277  1.31.2.2  perseant 
    278  1.31.2.2  perseant 	return (VOP_UPDATE(ap->a_vp, NULL, NULL,
    279  1.31.2.2  perseant 			   (ap->a_flags & FSYNC_WAIT) != 0 ? LFS_SYNC : 0)); /* XXX */
    280  1.31.2.2  perseant }
    281  1.31.2.2  perseant 
    282  1.31.2.2  perseant /*
    283  1.31.2.2  perseant  * These macros are used to bracket UFS directory ops, so that we can
    284  1.31.2.2  perseant  * identify all the pages touched during directory ops which need to
    285  1.31.2.2  perseant  * be ordered and flushed atomically, so that they may be recovered.
    286  1.31.2.2  perseant  */
    287  1.31.2.2  perseant /*
    288  1.31.2.2  perseant  * XXX KS - Because we have to mark nodes VDIROP in order to prevent
    289  1.31.2.2  perseant  * the cache from reclaiming them while a dirop is in progress, we must
    290  1.31.2.2  perseant  * also manage the number of nodes so marked (otherwise we can run out).
    291  1.31.2.2  perseant  * We do this by setting lfs_dirvcount to the number of marked vnodes; it
    292  1.31.2.2  perseant  * is decremented during segment write, when VDIROP is taken off.
    293  1.31.2.2  perseant  */
    294  1.31.2.2  perseant #define	SET_DIROP(fs) lfs_set_dirop(fs)
    295  1.31.2.2  perseant static int lfs_set_dirop __P((struct lfs *));
    296  1.31.2.2  perseant extern int lfs_dirvcount;
    297  1.31.2.2  perseant 
    298  1.31.2.2  perseant static int lfs_set_dirop(fs)
    299  1.31.2.2  perseant 	struct lfs *fs;
    300  1.31.2.2  perseant {
    301  1.31.2.2  perseant 	int error;
    302  1.31.2.2  perseant 
    303  1.31.2.2  perseant 	while (fs->lfs_writer || lfs_dirvcount>LFS_MAXDIROP) {
    304  1.31.2.2  perseant 		if(fs->lfs_writer)
    305  1.31.2.2  perseant 			tsleep(&fs->lfs_dirops, PRIBIO + 1, "lfs_dirop", 0);
    306  1.31.2.2  perseant 		if(lfs_dirvcount > LFS_MAXDIROP) {
    307  1.31.2.2  perseant #ifdef DEBUG_LFS
    308  1.31.2.2  perseant 			printf("(dirvcount=%d)\n",lfs_dirvcount);
    309  1.31.2.2  perseant #endif
    310  1.31.2.2  perseant 			if((error=tsleep(&lfs_dirvcount, PCATCH|PUSER, "lfs_maxdirop", 0))!=0)
    311  1.31.2.2  perseant 				return error;
    312  1.31.2.2  perseant 		}
    313  1.31.2.2  perseant 	}
    314  1.31.2.2  perseant 	++fs->lfs_dirops;
    315  1.31.2.2  perseant 	fs->lfs_doifile = 1;
    316  1.31.2.2  perseant 
    317  1.31.2.2  perseant 	return 0;
    318  1.31.2.2  perseant }
    319  1.31.2.2  perseant 
    320  1.31.2.2  perseant #define	SET_ENDOP(fs,vp,str) {						\
    321  1.31.2.2  perseant 	--(fs)->lfs_dirops;						\
    322  1.31.2.2  perseant 	if (!(fs)->lfs_dirops) {					\
    323  1.31.2.2  perseant 		wakeup(&(fs)->lfs_writer);				\
    324  1.31.2.2  perseant 		lfs_check((vp),LFS_UNUSED_LBN,0);			\
    325  1.31.2.2  perseant 	}								\
    326  1.31.2.2  perseant }
    327  1.31.2.2  perseant 
    328  1.31.2.2  perseant #define	MARK_VNODE(dvp)  do {                                           \
    329  1.31.2.2  perseant         if(!((dvp)->v_flag & VDIROP)) {					\
    330  1.31.2.2  perseant                 lfs_vref(dvp);						\
    331  1.31.2.2  perseant 		++lfs_dirvcount;					\
    332  1.31.2.2  perseant 	}								\
    333  1.31.2.2  perseant         (dvp)->v_flag |= VDIROP;					\
    334  1.31.2.2  perseant } while(0)
    335  1.31.2.2  perseant 
    336  1.31.2.2  perseant #define MAYBE_INACTIVE(fs,vp) do {                                      \
    337  1.31.2.2  perseant         if((vp) && ((vp)->v_flag & VDIROP) && (vp)->v_usecount == 1     \
    338  1.31.2.2  perseant            && VTOI(vp) && VTOI(vp)->i_ffs_nlink == 0)                   \
    339  1.31.2.2  perseant         {                                                               \
    340  1.31.2.2  perseant 		if (VOP_LOCK((vp), LK_EXCLUSIVE) == 0) { 		\
    341  1.31.2.2  perseant                         VOP_INACTIVE((vp),curproc);                     \
    342  1.31.2.2  perseant 		}                                                       \
    343  1.31.2.2  perseant         }                                                               \
    344  1.31.2.2  perseant } while(0)
    345  1.31.2.2  perseant 
    346  1.31.2.2  perseant int
    347  1.31.2.2  perseant lfs_symlink(v)
    348  1.31.2.2  perseant 	void *v;
    349  1.31.2.2  perseant {
    350  1.31.2.2  perseant 	struct vop_symlink_args /* {
    351  1.31.2.2  perseant 		struct vnode *a_dvp;
    352  1.31.2.2  perseant 		struct vnode **a_vpp;
    353  1.31.2.2  perseant 		struct componentname *a_cnp;
    354  1.31.2.2  perseant 		struct vattr *a_vap;
    355  1.31.2.2  perseant 		char *a_target;
    356  1.31.2.2  perseant 	} */ *ap = v;
    357  1.31.2.2  perseant 	int ret;
    358  1.31.2.2  perseant 
    359  1.31.2.2  perseant 	if((ret=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    360  1.31.2.2  perseant 		return ret;
    361  1.31.2.2  perseant 	MARK_VNODE(ap->a_dvp);
    362  1.31.2.2  perseant 	ret = ufs_symlink(ap);
    363  1.31.2.2  perseant 	MAYBE_INACTIVE(VTOI(ap->a_dvp)->i_lfs,*(ap->a_vpp)); /* XXX KS */
    364  1.31.2.2  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"symilnk");
    365  1.31.2.2  perseant 	return (ret);
    366  1.31.2.2  perseant }
    367  1.31.2.2  perseant 
    368  1.31.2.2  perseant int
    369  1.31.2.2  perseant lfs_mknod(v)
    370  1.31.2.2  perseant 	void *v;
    371  1.31.2.2  perseant {
    372  1.31.2.2  perseant 	struct vop_mknod_args	/* {
    373  1.31.2.2  perseant 		struct vnode *a_dvp;
    374  1.31.2.2  perseant 		struct vnode **a_vpp;
    375  1.31.2.2  perseant 		struct componentname *a_cnp;
    376  1.31.2.2  perseant 		struct vattr *a_vap;
    377  1.31.2.2  perseant 		} */ *ap = v;
    378  1.31.2.2  perseant         struct vattr *vap = ap->a_vap;
    379  1.31.2.2  perseant         struct vnode **vpp = ap->a_vpp;
    380  1.31.2.2  perseant         struct inode *ip;
    381  1.31.2.2  perseant         int error;
    382  1.31.2.2  perseant 
    383  1.31.2.2  perseant 	if((error=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    384  1.31.2.2  perseant 		return error;
    385  1.31.2.2  perseant 	MARK_VNODE(ap->a_dvp);
    386  1.31.2.2  perseant 	error = ufs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode),
    387  1.31.2.2  perseant             ap->a_dvp, vpp, ap->a_cnp);
    388  1.31.2.2  perseant 
    389  1.31.2.2  perseant 	/* Either way we're done with the dirop at this point */
    390  1.31.2.2  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"mknod");
    391  1.31.2.2  perseant 
    392  1.31.2.2  perseant         if (error)
    393  1.31.2.2  perseant 		return (error);
    394  1.31.2.2  perseant 
    395  1.31.2.2  perseant         ip = VTOI(*vpp);
    396  1.31.2.2  perseant         ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
    397  1.31.2.2  perseant         if (vap->va_rdev != VNOVAL) {
    398  1.31.2.2  perseant                 /*
    399  1.31.2.2  perseant                  * Want to be able to use this to make badblock
    400  1.31.2.2  perseant                  * inodes, so don't truncate the dev number.
    401  1.31.2.2  perseant                  */
    402  1.31.2.2  perseant #if 0
    403  1.31.2.2  perseant                 ip->i_ffs_rdev = ufs_rw32(vap->va_rdev,
    404  1.31.2.2  perseant                     UFS_MPNEEDSWAP((*vpp)->v_mount));
    405  1.31.2.2  perseant #else
    406  1.31.2.2  perseant                 ip->i_ffs_rdev = vap->va_rdev;
    407  1.31.2.2  perseant #endif
    408  1.31.2.2  perseant         }
    409  1.31.2.2  perseant 	/*
    410  1.31.2.2  perseant 	 * Call fsync to write the vnode so that we don't have to deal with
    411  1.31.2.2  perseant 	 * flushing it when it's marked VDIROP|VXLOCK.
    412  1.31.2.2  perseant 	 *
    413  1.31.2.2  perseant 	 * XXX KS - If we can't flush we also can't call vgone(), so must
    414  1.31.2.2  perseant 	 * return.  But, that leaves this vnode in limbo, also not good.
    415  1.31.2.2  perseant 	 * Can this ever happen (barring hardware failure)?
    416  1.31.2.2  perseant 	 */
    417  1.31.2.2  perseant 	if ((error = VOP_FSYNC(*vpp, NOCRED, FSYNC_WAIT, curproc)) != 0)
    418  1.31.2.2  perseant 		return (error);
    419  1.31.2.2  perseant         /*
    420  1.31.2.2  perseant          * Remove inode so that it will be reloaded by VFS_VGET and
    421  1.31.2.2  perseant          * checked to see if it is an alias of an existing entry in
    422  1.31.2.2  perseant          * the inode cache.
    423  1.31.2.2  perseant          */
    424  1.31.2.2  perseant 	/* Used to be vput, but that causes us to call VOP_INACTIVE twice. */
    425  1.31.2.2  perseant 	VOP_UNLOCK(*vpp,0);
    426  1.31.2.2  perseant 	lfs_vunref(*vpp);
    427  1.31.2.2  perseant         (*vpp)->v_type = VNON;
    428  1.31.2.2  perseant         vgone(*vpp);
    429  1.31.2.2  perseant         *vpp = 0;
    430  1.31.2.2  perseant         return (0);
    431  1.31.2.2  perseant }
    432  1.31.2.2  perseant 
    433  1.31.2.2  perseant int
    434  1.31.2.2  perseant lfs_create(v)
    435  1.31.2.2  perseant 	void *v;
    436  1.31.2.2  perseant {
    437  1.31.2.2  perseant 	struct vop_create_args	/* {
    438  1.31.2.2  perseant 		struct vnode *a_dvp;
    439  1.31.2.2  perseant 		struct vnode **a_vpp;
    440  1.31.2.2  perseant 		struct componentname *a_cnp;
    441  1.31.2.2  perseant 		struct vattr *a_vap;
    442  1.31.2.2  perseant 	} */ *ap = v;
    443  1.31.2.2  perseant 	int ret;
    444  1.31.2.2  perseant 
    445  1.31.2.2  perseant 	if((ret=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    446  1.31.2.2  perseant 		return ret;
    447  1.31.2.2  perseant 	MARK_VNODE(ap->a_dvp);
    448  1.31.2.2  perseant 	ret = ufs_create(ap);
    449  1.31.2.2  perseant 	MAYBE_INACTIVE(VTOI(ap->a_dvp)->i_lfs,*(ap->a_vpp)); /* XXX KS */
    450  1.31.2.2  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"create");
    451  1.31.2.2  perseant 	return (ret);
    452  1.31.2.2  perseant }
    453  1.31.2.2  perseant 
    454  1.31.2.2  perseant int
    455  1.31.2.2  perseant lfs_whiteout(v)
    456  1.31.2.2  perseant 	void *v;
    457  1.31.2.2  perseant {
    458  1.31.2.2  perseant 	struct vop_whiteout_args /* {
    459  1.31.2.2  perseant 		struct vnode *a_dvp;
    460  1.31.2.2  perseant 		struct componentname *a_cnp;
    461  1.31.2.2  perseant 		int a_flags;
    462  1.31.2.2  perseant 	} */ *ap = v;
    463  1.31.2.2  perseant 	int ret;
    464  1.31.2.2  perseant 
    465  1.31.2.2  perseant 	if((ret=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    466  1.31.2.2  perseant 		return ret;
    467  1.31.2.2  perseant 	MARK_VNODE(ap->a_dvp);
    468  1.31.2.2  perseant 	ret = ufs_whiteout(ap);
    469  1.31.2.2  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"whiteout");
    470  1.31.2.2  perseant 	return (ret);
    471  1.31.2.2  perseant }
    472  1.31.2.2  perseant 
    473  1.31.2.2  perseant int
    474  1.31.2.2  perseant lfs_mkdir(v)
    475  1.31.2.2  perseant 	void *v;
    476  1.31.2.2  perseant {
    477  1.31.2.2  perseant 	struct vop_mkdir_args	/* {
    478  1.31.2.2  perseant 		struct vnode *a_dvp;
    479  1.31.2.2  perseant 		struct vnode **a_vpp;
    480  1.31.2.2  perseant 		struct componentname *a_cnp;
    481  1.31.2.2  perseant 		struct vattr *a_vap;
    482  1.31.2.2  perseant 	} */ *ap = v;
    483  1.31.2.2  perseant 	int ret;
    484  1.31.2.2  perseant 
    485  1.31.2.2  perseant 	if((ret=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    486  1.31.2.2  perseant 		return ret;
    487  1.31.2.2  perseant 	MARK_VNODE(ap->a_dvp);
    488  1.31.2.2  perseant 	ret = ufs_mkdir(ap);
    489  1.31.2.2  perseant 	MAYBE_INACTIVE(VTOI(ap->a_dvp)->i_lfs,*(ap->a_vpp)); /* XXX KS */
    490  1.31.2.2  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"mkdir");
    491  1.31.2.2  perseant 	return (ret);
    492  1.31.2.2  perseant }
    493  1.31.2.2  perseant 
    494  1.31.2.2  perseant int
    495  1.31.2.2  perseant lfs_remove(v)
    496  1.31.2.2  perseant 	void *v;
    497  1.31.2.2  perseant {
    498  1.31.2.2  perseant 	struct vop_remove_args	/* {
    499  1.31.2.2  perseant 		struct vnode *a_dvp;
    500  1.31.2.2  perseant 		struct vnode *a_vp;
    501  1.31.2.2  perseant 		struct componentname *a_cnp;
    502  1.31.2.2  perseant 	} */ *ap = v;
    503  1.31.2.2  perseant 	int ret;
    504  1.31.2.2  perseant 	if((ret=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    505  1.31.2.2  perseant 		return ret;
    506  1.31.2.2  perseant 	MARK_VNODE(ap->a_dvp);
    507  1.31.2.2  perseant 	MARK_VNODE(ap->a_vp);
    508  1.31.2.2  perseant 	ret = ufs_remove(ap);
    509  1.31.2.2  perseant 	MAYBE_INACTIVE(VTOI(ap->a_dvp)->i_lfs,ap->a_vp);
    510  1.31.2.2  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"remove");
    511  1.31.2.2  perseant 	return (ret);
    512  1.31.2.2  perseant }
    513  1.31.2.2  perseant 
    514  1.31.2.2  perseant int
    515  1.31.2.2  perseant lfs_rmdir(v)
    516  1.31.2.2  perseant 	void *v;
    517  1.31.2.2  perseant {
    518  1.31.2.2  perseant 	struct vop_rmdir_args	/* {
    519  1.31.2.2  perseant 		struct vnodeop_desc *a_desc;
    520  1.31.2.2  perseant 		struct vnode *a_dvp;
    521  1.31.2.2  perseant 		struct vnode *a_vp;
    522  1.31.2.2  perseant 		struct componentname *a_cnp;
    523  1.31.2.2  perseant 	} */ *ap = v;
    524  1.31.2.2  perseant 	int ret;
    525  1.31.2.2  perseant 
    526  1.31.2.2  perseant 	if((ret=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    527  1.31.2.2  perseant 		return ret;
    528  1.31.2.2  perseant 	MARK_VNODE(ap->a_dvp);
    529  1.31.2.2  perseant 	MARK_VNODE(ap->a_vp);
    530  1.31.2.2  perseant 	ret = ufs_rmdir(ap);
    531  1.31.2.2  perseant 	MAYBE_INACTIVE(VTOI(ap->a_dvp)->i_lfs,ap->a_vp);
    532  1.31.2.2  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"rmdir");
    533  1.31.2.2  perseant 	return (ret);
    534  1.31.2.2  perseant }
    535  1.31.2.2  perseant 
    536  1.31.2.2  perseant int
    537  1.31.2.2  perseant lfs_link(v)
    538  1.31.2.2  perseant 	void *v;
    539  1.31.2.2  perseant {
    540  1.31.2.2  perseant 	struct vop_link_args	/* {
    541  1.31.2.2  perseant 		struct vnode *a_dvp;
    542  1.31.2.2  perseant 		struct vnode *a_vp;
    543  1.31.2.2  perseant 		struct componentname *a_cnp;
    544  1.31.2.2  perseant 	} */ *ap = v;
    545  1.31.2.2  perseant 	int ret;
    546  1.31.2.2  perseant 
    547  1.31.2.2  perseant 	if((ret=SET_DIROP(VTOI(ap->a_dvp)->i_lfs))!=0)
    548  1.31.2.2  perseant 		return ret;
    549  1.31.2.2  perseant 	MARK_VNODE(ap->a_dvp);
    550  1.31.2.2  perseant 	ret = ufs_link(ap);
    551  1.31.2.2  perseant 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"link");
    552  1.31.2.2  perseant 	return (ret);
    553  1.31.2.2  perseant }
    554  1.31.2.2  perseant 
    555  1.31.2.2  perseant int
    556  1.31.2.2  perseant lfs_rename(v)
    557  1.31.2.2  perseant 	void *v;
    558  1.31.2.2  perseant {
    559  1.31.2.2  perseant 	struct vop_rename_args	/* {
    560  1.31.2.2  perseant 		struct vnode *a_fdvp;
    561  1.31.2.2  perseant 		struct vnode *a_fvp;
    562  1.31.2.2  perseant 		struct componentname *a_fcnp;
    563  1.31.2.2  perseant 		struct vnode *a_tdvp;
    564  1.31.2.2  perseant 		struct vnode *a_tvp;
    565  1.31.2.2  perseant 		struct componentname *a_tcnp;
    566  1.31.2.2  perseant 	} */ *ap = v;
    567  1.31.2.2  perseant 	struct vnode *tvp, *fvp, *tdvp, *fdvp;
    568  1.31.2.2  perseant 	int error;
    569  1.31.2.2  perseant 	struct lfs *fs;
    570  1.31.2.2  perseant 
    571  1.31.2.2  perseant 	fs = VTOI(ap->a_fdvp)->i_lfs;
    572  1.31.2.2  perseant 	tvp = ap->a_tvp;
    573  1.31.2.2  perseant 	tdvp = ap->a_tdvp;
    574  1.31.2.2  perseant 	fvp = ap->a_fvp;
    575  1.31.2.2  perseant 	fdvp = ap->a_fdvp;
    576  1.31.2.2  perseant 
    577  1.31.2.2  perseant 	/*
    578  1.31.2.2  perseant 	 * Check for cross-device rename.
    579  1.31.2.2  perseant 	 * If it is, we don't want to set dirops, just error out.
    580  1.31.2.2  perseant 	 * (In particular note that MARK_VNODE(tdvp) will DTWT on
    581  1.31.2.2  perseant 	 * a cross-device rename.)
    582  1.31.2.2  perseant 	 *
    583  1.31.2.2  perseant 	 * Copied from ufs_rename.
    584  1.31.2.2  perseant 	 */
    585  1.31.2.2  perseant 	if ((fvp->v_mount != tdvp->v_mount) ||
    586  1.31.2.2  perseant 	    (tvp && (fvp->v_mount != tvp->v_mount))) {
    587  1.31.2.2  perseant 		error = EXDEV;
    588  1.31.2.2  perseant 		VOP_ABORTOP(tdvp, ap->a_tcnp); /* XXX, why not in NFS? */
    589  1.31.2.2  perseant 		if (tdvp == tvp)
    590  1.31.2.2  perseant 			vrele(tdvp);
    591  1.31.2.2  perseant 		else
    592  1.31.2.2  perseant 			vput(tdvp);
    593  1.31.2.2  perseant 		if (tvp)
    594  1.31.2.2  perseant 			vput(tvp);
    595  1.31.2.2  perseant 		VOP_ABORTOP(fdvp, ap->a_fcnp); /* XXX, why not in NFS? */
    596  1.31.2.2  perseant 		vrele(fdvp);
    597  1.31.2.2  perseant 		vrele(fvp);
    598  1.31.2.2  perseant 		return (error);
    599  1.31.2.2  perseant 	}
    600  1.31.2.2  perseant 	if((error=SET_DIROP(fs))!=0)
    601  1.31.2.2  perseant 		return (error);
    602  1.31.2.2  perseant 	MARK_VNODE(fdvp);
    603  1.31.2.2  perseant 	MARK_VNODE(tdvp);
    604  1.31.2.2  perseant 	error = ufs_rename(ap);
    605  1.31.2.2  perseant 	MAYBE_INACTIVE(fs,fvp);
    606  1.31.2.2  perseant 	MAYBE_INACTIVE(fs,tvp);
    607  1.31.2.2  perseant 	SET_ENDOP(fs,fdvp,"rename");
    608  1.31.2.2  perseant 	return (error);
    609  1.31.2.2  perseant }
    610  1.31.2.2  perseant 
    611  1.31.2.2  perseant /* XXX hack to avoid calling ITIMES in getattr */
    612  1.31.2.2  perseant int
    613  1.31.2.2  perseant lfs_getattr(v)
    614  1.31.2.2  perseant 	void *v;
    615  1.31.2.2  perseant {
    616  1.31.2.2  perseant 	struct vop_getattr_args /* {
    617  1.31.2.2  perseant 		struct vnode *a_vp;
    618  1.31.2.2  perseant 		struct vattr *a_vap;
    619  1.31.2.2  perseant 		struct ucred *a_cred;
    620  1.31.2.2  perseant 		struct proc *a_p;
    621  1.31.2.2  perseant 	} */ *ap = v;
    622  1.31.2.2  perseant 	register struct vnode *vp = ap->a_vp;
    623  1.31.2.2  perseant 	register struct inode *ip = VTOI(vp);
    624  1.31.2.2  perseant 	register struct vattr *vap = ap->a_vap;
    625  1.31.2.2  perseant 	/*
    626  1.31.2.2  perseant 	 * Copy from inode table
    627  1.31.2.2  perseant 	 */
    628  1.31.2.2  perseant 	vap->va_fsid = ip->i_dev;
    629  1.31.2.2  perseant 	vap->va_fileid = ip->i_number;
    630  1.31.2.2  perseant 	vap->va_mode = ip->i_ffs_mode & ~IFMT;
    631  1.31.2.2  perseant 	vap->va_nlink = ip->i_ffs_nlink;
    632  1.31.2.2  perseant 	vap->va_uid = ip->i_ffs_uid;
    633  1.31.2.2  perseant 	vap->va_gid = ip->i_ffs_gid;
    634  1.31.2.2  perseant 	vap->va_rdev = (dev_t)ip->i_ffs_rdev;
    635  1.31.2.2  perseant 	vap->va_size = ip->i_ffs_size;
    636  1.31.2.2  perseant 	vap->va_atime.tv_sec = ip->i_ffs_atime;
    637  1.31.2.2  perseant 	vap->va_atime.tv_nsec = ip->i_ffs_atimensec;
    638  1.31.2.2  perseant 	vap->va_mtime.tv_sec = ip->i_ffs_mtime;
    639  1.31.2.2  perseant 	vap->va_mtime.tv_nsec = ip->i_ffs_mtimensec;
    640  1.31.2.2  perseant 	vap->va_ctime.tv_sec = ip->i_ffs_ctime;
    641  1.31.2.2  perseant 	vap->va_ctime.tv_nsec = ip->i_ffs_ctimensec;
    642  1.31.2.2  perseant 	vap->va_flags = ip->i_ffs_flags;
    643  1.31.2.2  perseant 	vap->va_gen = ip->i_ffs_gen;
    644  1.31.2.2  perseant 	/* this doesn't belong here */
    645  1.31.2.2  perseant 	if (vp->v_type == VBLK)
    646  1.31.2.2  perseant 		vap->va_blocksize = BLKDEV_IOSIZE;
    647  1.31.2.2  perseant 	else if (vp->v_type == VCHR)
    648  1.31.2.2  perseant 		vap->va_blocksize = MAXBSIZE;
    649  1.31.2.2  perseant 	else
    650  1.31.2.2  perseant 		vap->va_blocksize = vp->v_mount->mnt_stat.f_iosize;
    651  1.31.2.2  perseant 	vap->va_bytes = dbtob((u_quad_t)ip->i_ffs_blocks);
    652  1.31.2.2  perseant 	vap->va_type = vp->v_type;
    653  1.31.2.2  perseant 	vap->va_filerev = ip->i_modrev;
    654  1.31.2.2  perseant 	return (0);
    655  1.31.2.2  perseant }
    656  1.31.2.2  perseant 
    657  1.31.2.2  perseant /*
    658  1.31.2.2  perseant  * Close called
    659  1.31.2.2  perseant  *
    660  1.31.2.2  perseant  * XXX -- we were using ufs_close, but since it updates the
    661  1.31.2.2  perseant  * times on the inode, we might need to bump the uinodes
    662  1.31.2.2  perseant  * count.
    663  1.31.2.2  perseant  */
    664  1.31.2.2  perseant /* ARGSUSED */
    665  1.31.2.2  perseant int
    666  1.31.2.2  perseant lfs_close(v)
    667  1.31.2.2  perseant 	void *v;
    668  1.31.2.2  perseant {
    669  1.31.2.2  perseant 	struct vop_close_args /* {
    670  1.31.2.2  perseant 		struct vnode *a_vp;
    671  1.31.2.2  perseant 		int  a_fflag;
    672  1.31.2.2  perseant 		struct ucred *a_cred;
    673  1.31.2.2  perseant 		struct proc *a_p;
    674  1.31.2.2  perseant 	} */ *ap = v;
    675  1.31.2.2  perseant 	register struct vnode *vp = ap->a_vp;
    676  1.31.2.2  perseant 	register struct inode *ip = VTOI(vp);
    677  1.31.2.2  perseant 	int mod;
    678  1.31.2.2  perseant 	struct timespec ts;
    679  1.31.2.2  perseant 
    680  1.31.2.2  perseant 	simple_lock(&vp->v_interlock);
    681  1.31.2.2  perseant 	if (vp->v_usecount > 1) {
    682  1.31.2.2  perseant 		mod = ip->i_flag & IN_MODIFIED;
    683  1.31.2.2  perseant 		TIMEVAL_TO_TIMESPEC(&time, &ts);
    684  1.31.2.2  perseant 		LFS_ITIMES(ip, &ts, &ts, &ts);
    685  1.31.2.2  perseant 		if (!mod && ip->i_flag & IN_MODIFIED)
    686  1.31.2.2  perseant 			ip->i_lfs->lfs_uinodes++;
    687  1.31.2.2  perseant 	}
    688  1.31.2.2  perseant 	simple_unlock(&vp->v_interlock);
    689  1.31.2.2  perseant 	return (0);
    690  1.31.2.2  perseant }
    691  1.31.2.2  perseant 
    692  1.31.2.2  perseant /*
    693  1.31.2.2  perseant  * Reclaim an inode so that it can be used for other purposes.
    694  1.31.2.2  perseant  */
    695  1.31.2.2  perseant int lfs_no_inactive = 0;
    696  1.31.2.2  perseant 
    697  1.31.2.2  perseant int
    698  1.31.2.2  perseant lfs_reclaim(v)
    699  1.31.2.2  perseant 	void *v;
    700  1.31.2.2  perseant {
    701  1.31.2.2  perseant 	struct vop_reclaim_args /* {
    702  1.31.2.2  perseant 		struct vnode *a_vp;
    703  1.31.2.2  perseant 		struct proc *a_p;
    704  1.31.2.2  perseant 	} */ *ap = v;
    705  1.31.2.2  perseant 	struct vnode *vp = ap->a_vp;
    706  1.31.2.2  perseant 	int error;
    707  1.31.2.2  perseant 
    708  1.31.2.2  perseant 	if ((error = ufs_reclaim(vp, ap->a_p)))
    709  1.31.2.2  perseant 		return (error);
    710  1.31.2.2  perseant 	pool_put(&lfs_inode_pool, vp->v_data);
    711  1.31.2.2  perseant 	vp->v_data = NULL;
    712  1.31.2.2  perseant 	return (0);
    713  1.31.2.2  perseant }
    714