Home | History | Annotate | Line # | Download | only in ffs
ffs_vnops.c revision 1.73
      1  1.73   thorpej /*	$NetBSD: ffs_vnops.c,v 1.73 2005/08/28 19:37:59 thorpej Exp $	*/
      2   1.3       cgd 
      3   1.1   mycroft /*
      4   1.1   mycroft  * Copyright (c) 1982, 1986, 1989, 1993
      5   1.1   mycroft  *	The Regents of the University of California.  All rights reserved.
      6   1.1   mycroft  *
      7   1.1   mycroft  * Redistribution and use in source and binary forms, with or without
      8   1.1   mycroft  * modification, are permitted provided that the following conditions
      9   1.1   mycroft  * are met:
     10   1.1   mycroft  * 1. Redistributions of source code must retain the above copyright
     11   1.1   mycroft  *    notice, this list of conditions and the following disclaimer.
     12   1.1   mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1   mycroft  *    notice, this list of conditions and the following disclaimer in the
     14   1.1   mycroft  *    documentation and/or other materials provided with the distribution.
     15  1.60       agc  * 3. Neither the name of the University nor the names of its contributors
     16   1.1   mycroft  *    may be used to endorse or promote products derived from this software
     17   1.1   mycroft  *    without specific prior written permission.
     18   1.1   mycroft  *
     19   1.1   mycroft  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     20   1.1   mycroft  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21   1.1   mycroft  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22   1.1   mycroft  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     23   1.1   mycroft  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24   1.1   mycroft  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     25   1.1   mycroft  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26   1.1   mycroft  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27   1.1   mycroft  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28   1.1   mycroft  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29   1.1   mycroft  * SUCH DAMAGE.
     30   1.1   mycroft  *
     31  1.12      fvdl  *	@(#)ffs_vnops.c	8.15 (Berkeley) 5/14/95
     32   1.1   mycroft  */
     33  1.44     lukem 
     34  1.44     lukem #include <sys/cdefs.h>
     35  1.73   thorpej __KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.73 2005/08/28 19:37:59 thorpej Exp $");
     36  1.11       mrg 
     37   1.1   mycroft #include <sys/param.h>
     38   1.1   mycroft #include <sys/systm.h>
     39   1.1   mycroft #include <sys/resourcevar.h>
     40   1.1   mycroft #include <sys/kernel.h>
     41   1.1   mycroft #include <sys/file.h>
     42   1.1   mycroft #include <sys/stat.h>
     43   1.1   mycroft #include <sys/buf.h>
     44  1.50  jdolecek #include <sys/event.h>
     45   1.1   mycroft #include <sys/proc.h>
     46   1.1   mycroft #include <sys/mount.h>
     47   1.1   mycroft #include <sys/vnode.h>
     48  1.16   thorpej #include <sys/pool.h>
     49   1.6  christos #include <sys/signalvar.h>
     50   1.1   mycroft 
     51   1.8   mycroft #include <miscfs/fifofs/fifo.h>
     52   1.8   mycroft #include <miscfs/genfs/genfs.h>
     53   1.1   mycroft #include <miscfs/specfs/specdev.h>
     54   1.1   mycroft 
     55   1.1   mycroft #include <ufs/ufs/inode.h>
     56   1.1   mycroft #include <ufs/ufs/dir.h>
     57   1.1   mycroft #include <ufs/ufs/ufs_extern.h>
     58   1.2   mycroft #include <ufs/ufs/ufsmount.h>
     59   1.1   mycroft 
     60   1.1   mycroft #include <ufs/ffs/fs.h>
     61   1.1   mycroft #include <ufs/ffs/ffs_extern.h>
     62   1.1   mycroft 
     63  1.49       chs #include <uvm/uvm.h>
     64  1.49       chs 
     65  1.33      fvdl static int ffs_full_fsync __P((void *));
     66  1.33      fvdl 
     67   1.1   mycroft /* Global vfs data structures for ufs. */
     68   1.6  christos int (**ffs_vnodeop_p) __P((void *));
     69  1.37  jdolecek const struct vnodeopv_entry_desc ffs_vnodeop_entries[] = {
     70   1.1   mycroft 	{ &vop_default_desc, vn_default_error },
     71   1.1   mycroft 	{ &vop_lookup_desc, ufs_lookup },		/* lookup */
     72   1.1   mycroft 	{ &vop_create_desc, ufs_create },		/* create */
     73   1.5   mycroft 	{ &vop_whiteout_desc, ufs_whiteout },		/* whiteout */
     74   1.1   mycroft 	{ &vop_mknod_desc, ufs_mknod },			/* mknod */
     75   1.1   mycroft 	{ &vop_open_desc, ufs_open },			/* open */
     76   1.1   mycroft 	{ &vop_close_desc, ufs_close },			/* close */
     77   1.1   mycroft 	{ &vop_access_desc, ufs_access },		/* access */
     78   1.1   mycroft 	{ &vop_getattr_desc, ufs_getattr },		/* getattr */
     79   1.1   mycroft 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
     80   1.1   mycroft 	{ &vop_read_desc, ffs_read },			/* read */
     81   1.1   mycroft 	{ &vop_write_desc, ffs_write },			/* write */
     82   1.4   mycroft 	{ &vop_lease_desc, ufs_lease_check },		/* lease */
     83   1.1   mycroft 	{ &vop_ioctl_desc, ufs_ioctl },			/* ioctl */
     84  1.19  wrstuden 	{ &vop_fcntl_desc, ufs_fcntl },			/* fcntl */
     85   1.9   mycroft 	{ &vop_poll_desc, ufs_poll },			/* poll */
     86  1.50  jdolecek 	{ &vop_kqfilter_desc, genfs_kqfilter },		/* kqfilter */
     87  1.12      fvdl 	{ &vop_revoke_desc, ufs_revoke },		/* revoke */
     88   1.1   mycroft 	{ &vop_mmap_desc, ufs_mmap },			/* mmap */
     89   1.1   mycroft 	{ &vop_fsync_desc, ffs_fsync },			/* fsync */
     90   1.1   mycroft 	{ &vop_seek_desc, ufs_seek },			/* seek */
     91   1.1   mycroft 	{ &vop_remove_desc, ufs_remove },		/* remove */
     92   1.1   mycroft 	{ &vop_link_desc, ufs_link },			/* link */
     93   1.1   mycroft 	{ &vop_rename_desc, ufs_rename },		/* rename */
     94   1.1   mycroft 	{ &vop_mkdir_desc, ufs_mkdir },			/* mkdir */
     95   1.1   mycroft 	{ &vop_rmdir_desc, ufs_rmdir },			/* rmdir */
     96   1.1   mycroft 	{ &vop_symlink_desc, ufs_symlink },		/* symlink */
     97   1.1   mycroft 	{ &vop_readdir_desc, ufs_readdir },		/* readdir */
     98   1.1   mycroft 	{ &vop_readlink_desc, ufs_readlink },		/* readlink */
     99   1.1   mycroft 	{ &vop_abortop_desc, ufs_abortop },		/* abortop */
    100   1.1   mycroft 	{ &vop_inactive_desc, ufs_inactive },		/* inactive */
    101   1.1   mycroft 	{ &vop_reclaim_desc, ffs_reclaim },		/* reclaim */
    102   1.1   mycroft 	{ &vop_lock_desc, ufs_lock },			/* lock */
    103   1.1   mycroft 	{ &vop_unlock_desc, ufs_unlock },		/* unlock */
    104   1.1   mycroft 	{ &vop_bmap_desc, ufs_bmap },			/* bmap */
    105   1.1   mycroft 	{ &vop_strategy_desc, ufs_strategy },		/* strategy */
    106   1.1   mycroft 	{ &vop_print_desc, ufs_print },			/* print */
    107   1.1   mycroft 	{ &vop_islocked_desc, ufs_islocked },		/* islocked */
    108   1.1   mycroft 	{ &vop_pathconf_desc, ufs_pathconf },		/* pathconf */
    109   1.1   mycroft 	{ &vop_advlock_desc, ufs_advlock },		/* advlock */
    110   1.1   mycroft 	{ &vop_blkatoff_desc, ffs_blkatoff },		/* blkatoff */
    111   1.1   mycroft 	{ &vop_valloc_desc, ffs_valloc },		/* valloc */
    112  1.20      fvdl 	{ &vop_balloc_desc, ffs_balloc },		/* balloc */
    113   1.1   mycroft 	{ &vop_reallocblks_desc, ffs_reallocblks },	/* reallocblks */
    114   1.1   mycroft 	{ &vop_vfree_desc, ffs_vfree },			/* vfree */
    115   1.1   mycroft 	{ &vop_truncate_desc, ffs_truncate },		/* truncate */
    116   1.1   mycroft 	{ &vop_update_desc, ffs_update },		/* update */
    117   1.8   mycroft 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
    118  1.39       chs 	{ &vop_getpages_desc, ffs_getpages },		/* getpages */
    119  1.49       chs 	{ &vop_putpages_desc, ffs_putpages },		/* putpages */
    120  1.73   thorpej 	{ &vop_openextattr_desc, ffs_openextattr },	/* openextattr */
    121  1.73   thorpej 	{ &vop_closeextattr_desc, ffs_closeextattr },	/* closeextattr */
    122  1.73   thorpej 	{ &vop_getextattr_desc, ffs_getextattr },	/* getextattr */
    123  1.73   thorpej 	{ &vop_setextattr_desc, ffs_setextattr },	/* setextattr */
    124  1.73   thorpej 	{ &vop_listextattr_desc, ffs_listextattr },	/* listextattr */
    125  1.73   thorpej 	{ &vop_deleteextattr_desc, ffs_deleteextattr },	/* deleteextattr */
    126  1.35       chs 	{ NULL, NULL }
    127   1.1   mycroft };
    128  1.37  jdolecek const struct vnodeopv_desc ffs_vnodeop_opv_desc =
    129   1.1   mycroft 	{ &ffs_vnodeop_p, ffs_vnodeop_entries };
    130   1.1   mycroft 
    131   1.6  christos int (**ffs_specop_p) __P((void *));
    132  1.37  jdolecek const struct vnodeopv_entry_desc ffs_specop_entries[] = {
    133   1.1   mycroft 	{ &vop_default_desc, vn_default_error },
    134   1.1   mycroft 	{ &vop_lookup_desc, spec_lookup },		/* lookup */
    135   1.1   mycroft 	{ &vop_create_desc, spec_create },		/* create */
    136   1.1   mycroft 	{ &vop_mknod_desc, spec_mknod },		/* mknod */
    137   1.1   mycroft 	{ &vop_open_desc, spec_open },			/* open */
    138   1.1   mycroft 	{ &vop_close_desc, ufsspec_close },		/* close */
    139   1.1   mycroft 	{ &vop_access_desc, ufs_access },		/* access */
    140   1.1   mycroft 	{ &vop_getattr_desc, ufs_getattr },		/* getattr */
    141   1.1   mycroft 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
    142   1.1   mycroft 	{ &vop_read_desc, ufsspec_read },		/* read */
    143   1.1   mycroft 	{ &vop_write_desc, ufsspec_write },		/* write */
    144   1.4   mycroft 	{ &vop_lease_desc, spec_lease_check },		/* lease */
    145   1.1   mycroft 	{ &vop_ioctl_desc, spec_ioctl },		/* ioctl */
    146  1.19  wrstuden 	{ &vop_fcntl_desc, ufs_fcntl },			/* fcntl */
    147   1.9   mycroft 	{ &vop_poll_desc, spec_poll },			/* poll */
    148  1.50  jdolecek 	{ &vop_kqfilter_desc, spec_kqfilter },		/* kqfilter */
    149  1.12      fvdl 	{ &vop_revoke_desc, spec_revoke },		/* revoke */
    150   1.1   mycroft 	{ &vop_mmap_desc, spec_mmap },			/* mmap */
    151   1.1   mycroft 	{ &vop_fsync_desc, ffs_fsync },			/* fsync */
    152   1.1   mycroft 	{ &vop_seek_desc, spec_seek },			/* seek */
    153   1.1   mycroft 	{ &vop_remove_desc, spec_remove },		/* remove */
    154   1.1   mycroft 	{ &vop_link_desc, spec_link },			/* link */
    155   1.1   mycroft 	{ &vop_rename_desc, spec_rename },		/* rename */
    156   1.1   mycroft 	{ &vop_mkdir_desc, spec_mkdir },		/* mkdir */
    157   1.1   mycroft 	{ &vop_rmdir_desc, spec_rmdir },		/* rmdir */
    158   1.1   mycroft 	{ &vop_symlink_desc, spec_symlink },		/* symlink */
    159   1.1   mycroft 	{ &vop_readdir_desc, spec_readdir },		/* readdir */
    160   1.1   mycroft 	{ &vop_readlink_desc, spec_readlink },		/* readlink */
    161   1.1   mycroft 	{ &vop_abortop_desc, spec_abortop },		/* abortop */
    162   1.1   mycroft 	{ &vop_inactive_desc, ufs_inactive },		/* inactive */
    163   1.1   mycroft 	{ &vop_reclaim_desc, ffs_reclaim },		/* reclaim */
    164   1.1   mycroft 	{ &vop_lock_desc, ufs_lock },			/* lock */
    165   1.1   mycroft 	{ &vop_unlock_desc, ufs_unlock },		/* unlock */
    166   1.1   mycroft 	{ &vop_bmap_desc, spec_bmap },			/* bmap */
    167   1.1   mycroft 	{ &vop_strategy_desc, spec_strategy },		/* strategy */
    168   1.1   mycroft 	{ &vop_print_desc, ufs_print },			/* print */
    169   1.1   mycroft 	{ &vop_islocked_desc, ufs_islocked },		/* islocked */
    170   1.1   mycroft 	{ &vop_pathconf_desc, spec_pathconf },		/* pathconf */
    171   1.1   mycroft 	{ &vop_advlock_desc, spec_advlock },		/* advlock */
    172   1.1   mycroft 	{ &vop_blkatoff_desc, spec_blkatoff },		/* blkatoff */
    173   1.1   mycroft 	{ &vop_valloc_desc, spec_valloc },		/* valloc */
    174   1.1   mycroft 	{ &vop_reallocblks_desc, spec_reallocblks },	/* reallocblks */
    175   1.1   mycroft 	{ &vop_vfree_desc, ffs_vfree },			/* vfree */
    176   1.1   mycroft 	{ &vop_truncate_desc, spec_truncate },		/* truncate */
    177   1.1   mycroft 	{ &vop_update_desc, ffs_update },		/* update */
    178   1.8   mycroft 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
    179  1.38       chs 	{ &vop_getpages_desc, spec_getpages },		/* getpages */
    180  1.38       chs 	{ &vop_putpages_desc, spec_putpages },		/* putpages */
    181  1.73   thorpej 	{ &vop_openextattr_desc, ffs_openextattr },	/* openextattr */
    182  1.73   thorpej 	{ &vop_closeextattr_desc, ffs_closeextattr },	/* closeextattr */
    183  1.73   thorpej 	{ &vop_getextattr_desc, ffs_getextattr },	/* getextattr */
    184  1.73   thorpej 	{ &vop_setextattr_desc, ffs_setextattr },	/* setextattr */
    185  1.73   thorpej 	{ &vop_listextattr_desc, ffs_listextattr },	/* listextattr */
    186  1.73   thorpej 	{ &vop_deleteextattr_desc, ffs_deleteextattr },	/* deleteextattr */
    187  1.35       chs 	{ NULL, NULL }
    188   1.1   mycroft };
    189  1.37  jdolecek const struct vnodeopv_desc ffs_specop_opv_desc =
    190   1.1   mycroft 	{ &ffs_specop_p, ffs_specop_entries };
    191   1.1   mycroft 
    192   1.6  christos int (**ffs_fifoop_p) __P((void *));
    193  1.37  jdolecek const struct vnodeopv_entry_desc ffs_fifoop_entries[] = {
    194   1.1   mycroft 	{ &vop_default_desc, vn_default_error },
    195   1.1   mycroft 	{ &vop_lookup_desc, fifo_lookup },		/* lookup */
    196   1.1   mycroft 	{ &vop_create_desc, fifo_create },		/* create */
    197   1.1   mycroft 	{ &vop_mknod_desc, fifo_mknod },		/* mknod */
    198   1.1   mycroft 	{ &vop_open_desc, fifo_open },			/* open */
    199   1.1   mycroft 	{ &vop_close_desc, ufsfifo_close },		/* close */
    200   1.1   mycroft 	{ &vop_access_desc, ufs_access },		/* access */
    201   1.1   mycroft 	{ &vop_getattr_desc, ufs_getattr },		/* getattr */
    202   1.1   mycroft 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
    203   1.1   mycroft 	{ &vop_read_desc, ufsfifo_read },		/* read */
    204   1.1   mycroft 	{ &vop_write_desc, ufsfifo_write },		/* write */
    205   1.4   mycroft 	{ &vop_lease_desc, fifo_lease_check },		/* lease */
    206   1.1   mycroft 	{ &vop_ioctl_desc, fifo_ioctl },		/* ioctl */
    207  1.19  wrstuden 	{ &vop_fcntl_desc, ufs_fcntl },			/* fcntl */
    208   1.9   mycroft 	{ &vop_poll_desc, fifo_poll },			/* poll */
    209  1.50  jdolecek 	{ &vop_kqfilter_desc, fifo_kqfilter },		/* kqfilter */
    210  1.12      fvdl 	{ &vop_revoke_desc, fifo_revoke },		/* revoke */
    211   1.1   mycroft 	{ &vop_mmap_desc, fifo_mmap },			/* mmap */
    212   1.1   mycroft 	{ &vop_fsync_desc, ffs_fsync },			/* fsync */
    213   1.1   mycroft 	{ &vop_seek_desc, fifo_seek },			/* seek */
    214   1.1   mycroft 	{ &vop_remove_desc, fifo_remove },		/* remove */
    215   1.1   mycroft 	{ &vop_link_desc, fifo_link },			/* link */
    216   1.1   mycroft 	{ &vop_rename_desc, fifo_rename },		/* rename */
    217   1.1   mycroft 	{ &vop_mkdir_desc, fifo_mkdir },		/* mkdir */
    218   1.1   mycroft 	{ &vop_rmdir_desc, fifo_rmdir },		/* rmdir */
    219   1.1   mycroft 	{ &vop_symlink_desc, fifo_symlink },		/* symlink */
    220   1.1   mycroft 	{ &vop_readdir_desc, fifo_readdir },		/* readdir */
    221   1.1   mycroft 	{ &vop_readlink_desc, fifo_readlink },		/* readlink */
    222   1.1   mycroft 	{ &vop_abortop_desc, fifo_abortop },		/* abortop */
    223   1.1   mycroft 	{ &vop_inactive_desc, ufs_inactive },		/* inactive */
    224   1.1   mycroft 	{ &vop_reclaim_desc, ffs_reclaim },		/* reclaim */
    225   1.1   mycroft 	{ &vop_lock_desc, ufs_lock },			/* lock */
    226   1.1   mycroft 	{ &vop_unlock_desc, ufs_unlock },		/* unlock */
    227   1.1   mycroft 	{ &vop_bmap_desc, fifo_bmap },			/* bmap */
    228   1.1   mycroft 	{ &vop_strategy_desc, fifo_strategy },		/* strategy */
    229   1.1   mycroft 	{ &vop_print_desc, ufs_print },			/* print */
    230   1.1   mycroft 	{ &vop_islocked_desc, ufs_islocked },		/* islocked */
    231   1.1   mycroft 	{ &vop_pathconf_desc, fifo_pathconf },		/* pathconf */
    232   1.1   mycroft 	{ &vop_advlock_desc, fifo_advlock },		/* advlock */
    233   1.1   mycroft 	{ &vop_blkatoff_desc, fifo_blkatoff },		/* blkatoff */
    234   1.1   mycroft 	{ &vop_valloc_desc, fifo_valloc },		/* valloc */
    235   1.1   mycroft 	{ &vop_reallocblks_desc, fifo_reallocblks },	/* reallocblks */
    236   1.1   mycroft 	{ &vop_vfree_desc, ffs_vfree },			/* vfree */
    237   1.1   mycroft 	{ &vop_truncate_desc, fifo_truncate },		/* truncate */
    238   1.1   mycroft 	{ &vop_update_desc, ffs_update },		/* update */
    239   1.8   mycroft 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
    240  1.40  sommerfe 	{ &vop_putpages_desc, fifo_putpages }, 		/* putpages */
    241  1.73   thorpej 	{ &vop_openextattr_desc, ffs_openextattr },	/* openextattr */
    242  1.73   thorpej 	{ &vop_closeextattr_desc, ffs_closeextattr },	/* closeextattr */
    243  1.73   thorpej 	{ &vop_getextattr_desc, ffs_getextattr },	/* getextattr */
    244  1.73   thorpej 	{ &vop_setextattr_desc, ffs_setextattr },	/* setextattr */
    245  1.73   thorpej 	{ &vop_listextattr_desc, ffs_listextattr },	/* listextattr */
    246  1.73   thorpej 	{ &vop_deleteextattr_desc, ffs_deleteextattr },	/* deleteextattr */
    247  1.35       chs 	{ NULL, NULL }
    248   1.1   mycroft };
    249  1.37  jdolecek const struct vnodeopv_desc ffs_fifoop_opv_desc =
    250   1.1   mycroft 	{ &ffs_fifoop_p, ffs_fifoop_entries };
    251   1.1   mycroft 
    252   1.1   mycroft #include <ufs/ufs/ufs_readwrite.c>
    253  1.20      fvdl 
    254  1.33      fvdl int
    255  1.70   thorpej ffs_fsync(void *v)
    256  1.33      fvdl {
    257  1.33      fvdl 	struct vop_fsync_args /* {
    258  1.33      fvdl 		struct vnode *a_vp;
    259  1.33      fvdl 		struct ucred *a_cred;
    260  1.33      fvdl 		int a_flags;
    261  1.46       chs 		off_t a_offlo;
    262  1.46       chs 		off_t a_offhi;
    263  1.59      fvdl 		struct proc *a_p;
    264  1.33      fvdl 	} */ *ap = v;
    265  1.35       chs 	struct buf *bp;
    266  1.33      fvdl 	int s, num, error, i;
    267  1.33      fvdl 	struct indir ia[NIADDR + 1];
    268  1.33      fvdl 	int bsize;
    269  1.45    simonb 	daddr_t blk_high;
    270  1.33      fvdl 	struct vnode *vp;
    271  1.33      fvdl 
    272  1.33      fvdl 	/*
    273  1.33      fvdl 	 * XXX no easy way to sync a range in a file with softdep.
    274  1.33      fvdl 	 */
    275  1.64       dbj 	if ((ap->a_offlo == 0 && ap->a_offhi == 0) || DOINGSOFTDEP(ap->a_vp) ||
    276  1.65  jdolecek 			(ap->a_vp->v_type != VREG))
    277  1.33      fvdl 		return ffs_full_fsync(v);
    278  1.33      fvdl 
    279  1.33      fvdl 	vp = ap->a_vp;
    280  1.33      fvdl 
    281  1.33      fvdl 	bsize = ap->a_vp->v_mount->mnt_stat.f_iosize;
    282  1.33      fvdl 	blk_high = ap->a_offhi / bsize;
    283  1.33      fvdl 	if (ap->a_offhi % bsize != 0)
    284  1.33      fvdl 		blk_high++;
    285  1.33      fvdl 
    286  1.33      fvdl 	/*
    287  1.35       chs 	 * First, flush all pages in range.
    288  1.33      fvdl 	 */
    289  1.35       chs 
    290  1.64       dbj 	simple_lock(&vp->v_interlock);
    291  1.64       dbj 	error = VOP_PUTPAGES(vp, trunc_page(ap->a_offlo),
    292  1.64       dbj 	    round_page(ap->a_offhi), PGO_CLEANIT |
    293  1.64       dbj 	    ((ap->a_flags & FSYNC_WAIT) ? PGO_SYNCIO : 0));
    294  1.64       dbj 	if (error) {
    295  1.64       dbj 		return error;
    296  1.39       chs 	}
    297  1.33      fvdl 
    298  1.33      fvdl 	/*
    299  1.35       chs 	 * Then, flush indirect blocks.
    300  1.33      fvdl 	 */
    301  1.35       chs 
    302  1.41       chs 	s = splbio();
    303  1.61    kleink 	if (blk_high >= NDADDR) {
    304  1.33      fvdl 		error = ufs_getlbns(vp, blk_high, ia, &num);
    305  1.42       chs 		if (error) {
    306  1.42       chs 			splx(s);
    307  1.33      fvdl 			return error;
    308  1.42       chs 		}
    309  1.33      fvdl 		for (i = 0; i < num; i++) {
    310  1.35       chs 			bp = incore(vp, ia[i].in_lbn);
    311  1.62       dbj 			if (bp != NULL) {
    312  1.62       dbj 				simple_lock(&bp->b_interlock);
    313  1.62       dbj 				if (!(bp->b_flags & B_BUSY) && (bp->b_flags & B_DELWRI)) {
    314  1.62       dbj 					bp->b_flags |= B_BUSY | B_VFLUSH;
    315  1.62       dbj 					simple_unlock(&bp->b_interlock);
    316  1.62       dbj 					splx(s);
    317  1.62       dbj 					bawrite(bp);
    318  1.62       dbj 					s = splbio();
    319  1.62       dbj 				} else {
    320  1.62       dbj 					simple_unlock(&bp->b_interlock);
    321  1.62       dbj 				}
    322  1.33      fvdl 			}
    323  1.33      fvdl 		}
    324  1.33      fvdl 	}
    325  1.33      fvdl 
    326  1.33      fvdl 	if (ap->a_flags & FSYNC_WAIT) {
    327  1.54        pk 		simple_lock(&global_v_numoutput_slock);
    328  1.33      fvdl 		while (vp->v_numoutput > 0) {
    329  1.33      fvdl 			vp->v_flag |= VBWAIT;
    330  1.54        pk 			ltsleep(&vp->v_numoutput, PRIBIO + 1, "fsync_range", 0,
    331  1.54        pk 				&global_v_numoutput_slock);
    332  1.33      fvdl 		}
    333  1.54        pk 		simple_unlock(&global_v_numoutput_slock);
    334  1.33      fvdl 	}
    335  1.34      fvdl 	splx(s);
    336  1.33      fvdl 
    337  1.67  wrstuden 	error = VOP_UPDATE(vp, NULL, NULL,
    338  1.66   thorpej 	    ((ap->a_flags & (FSYNC_WAIT | FSYNC_DATAONLY)) == FSYNC_WAIT)
    339  1.67  wrstuden 	    ? UPDATE_WAIT : 0);
    340  1.67  wrstuden 
    341  1.67  wrstuden 	if (error == 0 && ap->a_flags & FSYNC_CACHE) {
    342  1.67  wrstuden 		int l = 0;
    343  1.67  wrstuden 		VOP_IOCTL(VTOI(vp)->i_devvp, DIOCCACHESYNC, &l, FWRITE,
    344  1.67  wrstuden 			ap->a_p->p_ucred, ap->a_p);
    345  1.67  wrstuden 	}
    346  1.67  wrstuden 
    347  1.67  wrstuden 	return error;
    348  1.33      fvdl }
    349  1.33      fvdl 
    350  1.20      fvdl /*
    351  1.20      fvdl  * Synch an open file.
    352  1.20      fvdl  */
    353  1.20      fvdl /* ARGSUSED */
    354  1.33      fvdl static int
    355  1.70   thorpej ffs_full_fsync(void *v)
    356  1.20      fvdl {
    357  1.29   mycroft 	struct vop_fsync_args /* {
    358  1.20      fvdl 		struct vnode *a_vp;
    359  1.20      fvdl 		struct ucred *a_cred;
    360  1.20      fvdl 		int a_flags;
    361  1.46       chs 		off_t a_offlo;
    362  1.46       chs 		off_t a_offhi;
    363  1.59      fvdl 		struct proc *a_p;
    364  1.20      fvdl 	} */ *ap = v;
    365  1.20      fvdl 	struct vnode *vp = ap->a_vp;
    366  1.20      fvdl 	struct buf *bp, *nbp;
    367  1.47      fvdl 	int s, error, passes, skipmeta, inodedeps_only, waitfor;
    368  1.24      fvdl 
    369  1.20      fvdl 	if (vp->v_type == VBLK &&
    370  1.20      fvdl 	    vp->v_specmountpoint != NULL &&
    371  1.20      fvdl 	    (vp->v_specmountpoint->mnt_flag & MNT_SOFTDEP))
    372  1.20      fvdl 		softdep_fsync_mountdev(vp);
    373  1.21  perseant 
    374  1.47      fvdl 	inodedeps_only = DOINGSOFTDEP(vp) && (ap->a_flags & FSYNC_RECLAIM)
    375  1.48   thorpej 	    && vp->v_uobj.uo_npages == 0 && LIST_EMPTY(&vp->v_dirtyblkhd);
    376  1.47      fvdl 
    377  1.35       chs 	/*
    378  1.35       chs 	 * Flush all dirty data associated with a vnode.
    379  1.20      fvdl 	 */
    380  1.35       chs 
    381  1.72      yamt 	if (vp->v_type == VREG || vp->v_type == VBLK) {
    382  1.46       chs 		simple_lock(&vp->v_interlock);
    383  1.46       chs 		error = VOP_PUTPAGES(vp, 0, 0, PGO_ALLPAGES | PGO_CLEANIT |
    384  1.35       chs 		    ((ap->a_flags & FSYNC_WAIT) ? PGO_SYNCIO : 0));
    385  1.39       chs 		if (error) {
    386  1.39       chs 			return error;
    387  1.39       chs 		}
    388  1.35       chs 	}
    389  1.35       chs 
    390  1.20      fvdl 	passes = NIADDR + 1;
    391  1.20      fvdl 	skipmeta = 0;
    392  1.61    kleink 	if (ap->a_flags & FSYNC_WAIT)
    393  1.20      fvdl 		skipmeta = 1;
    394  1.20      fvdl 	s = splbio();
    395  1.35       chs 
    396  1.20      fvdl loop:
    397  1.35       chs 	LIST_FOREACH(bp, &vp->v_dirtyblkhd, b_vnbufs)
    398  1.20      fvdl 		bp->b_flags &= ~B_SCANNED;
    399  1.29   mycroft 	for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
    400  1.29   mycroft 		nbp = LIST_NEXT(bp, b_vnbufs);
    401  1.63       dbj 		simple_lock(&bp->b_interlock);
    402  1.63       dbj 		if (bp->b_flags & (B_BUSY | B_SCANNED)) {
    403  1.63       dbj 			simple_unlock(&bp->b_interlock);
    404  1.20      fvdl 			continue;
    405  1.63       dbj 		}
    406  1.20      fvdl 		if ((bp->b_flags & B_DELWRI) == 0)
    407  1.20      fvdl 			panic("ffs_fsync: not dirty");
    408  1.63       dbj 		if (skipmeta && bp->b_lblkno < 0) {
    409  1.63       dbj 			simple_unlock(&bp->b_interlock);
    410  1.20      fvdl 			continue;
    411  1.63       dbj 		}
    412  1.63       dbj 		simple_unlock(&bp->b_interlock);
    413  1.20      fvdl 		bp->b_flags |= B_BUSY | B_VFLUSH | B_SCANNED;
    414  1.20      fvdl 		splx(s);
    415  1.20      fvdl 		/*
    416  1.20      fvdl 		 * On our final pass through, do all I/O synchronously
    417  1.20      fvdl 		 * so that we can find out if our flush is failing
    418  1.20      fvdl 		 * because of write errors.
    419  1.20      fvdl 		 */
    420  1.20      fvdl 		if (passes > 0 || !(ap->a_flags & FSYNC_WAIT))
    421  1.20      fvdl 			(void) bawrite(bp);
    422  1.20      fvdl 		else if ((error = bwrite(bp)) != 0)
    423  1.20      fvdl 			return (error);
    424  1.20      fvdl 		s = splbio();
    425  1.20      fvdl 		/*
    426  1.20      fvdl 		 * Since we may have slept during the I/O, we need
    427  1.20      fvdl 		 * to start from a known point.
    428  1.20      fvdl 		 */
    429  1.29   mycroft 		nbp = LIST_FIRST(&vp->v_dirtyblkhd);
    430  1.20      fvdl 	}
    431  1.61    kleink 	if (skipmeta) {
    432  1.20      fvdl 		skipmeta = 0;
    433  1.20      fvdl 		goto loop;
    434  1.20      fvdl 	}
    435  1.20      fvdl 	if (ap->a_flags & FSYNC_WAIT) {
    436  1.54        pk 		simple_lock(&global_v_numoutput_slock);
    437  1.20      fvdl 		while (vp->v_numoutput) {
    438  1.20      fvdl 			vp->v_flag |= VBWAIT;
    439  1.54        pk 			(void) ltsleep(&vp->v_numoutput, PRIBIO + 1,
    440  1.54        pk 			    "ffsfsync", 0, &global_v_numoutput_slock);
    441  1.20      fvdl 		}
    442  1.54        pk 		simple_unlock(&global_v_numoutput_slock);
    443  1.29   mycroft 		splx(s);
    444  1.20      fvdl 
    445  1.69     perry 		/*
    446  1.20      fvdl 		 * Ensure that any filesystem metadata associated
    447  1.20      fvdl 		 * with the vnode has been written.
    448  1.20      fvdl 		 */
    449  1.31   mycroft 		if ((error = softdep_sync_metadata(ap)) != 0)
    450  1.20      fvdl 			return (error);
    451  1.29   mycroft 
    452  1.20      fvdl 		s = splbio();
    453  1.29   mycroft 		if (!LIST_EMPTY(&vp->v_dirtyblkhd)) {
    454  1.29   mycroft 			/*
    455  1.29   mycroft 			* Block devices associated with filesystems may
    456  1.29   mycroft 			* have new I/O requests posted for them even if
    457  1.29   mycroft 			* the vnode is locked, so no amount of trying will
    458  1.29   mycroft 			* get them clean. Thus we give block devices a
    459  1.29   mycroft 			* good effort, then just give up. For all other file
    460  1.29   mycroft 			* types, go around and try again until it is clean.
    461  1.29   mycroft 			*/
    462  1.29   mycroft 			if (passes > 0) {
    463  1.29   mycroft 				passes--;
    464  1.29   mycroft 				goto loop;
    465  1.29   mycroft 			}
    466  1.20      fvdl #ifdef DIAGNOSTIC
    467  1.29   mycroft 			if (vp->v_type != VBLK)
    468  1.29   mycroft 				vprint("ffs_fsync: dirty", vp);
    469  1.20      fvdl #endif
    470  1.29   mycroft 		}
    471  1.29   mycroft 	}
    472  1.29   mycroft 	splx(s);
    473  1.47      fvdl 
    474  1.47      fvdl 	if (inodedeps_only)
    475  1.47      fvdl 		waitfor = 0;
    476  1.47      fvdl 	else
    477  1.47      fvdl 		waitfor = (ap->a_flags & FSYNC_WAIT) ? UPDATE_WAIT : 0;
    478  1.67  wrstuden 	error = VOP_UPDATE(vp, NULL, NULL, waitfor);
    479  1.67  wrstuden 
    480  1.68  wrstuden 	if (error == 0 && ap->a_flags & FSYNC_CACHE) {
    481  1.67  wrstuden 		int i = 0;
    482  1.67  wrstuden 		VOP_IOCTL(VTOI(vp)->i_devvp, DIOCCACHESYNC, &i, FWRITE,
    483  1.67  wrstuden 			ap->a_p->p_ucred, ap->a_p);
    484  1.67  wrstuden 	}
    485  1.67  wrstuden 
    486  1.67  wrstuden 	return error;
    487  1.20      fvdl }
    488   1.1   mycroft 
    489   1.1   mycroft /*
    490   1.1   mycroft  * Reclaim an inode so that it can be used for other purposes.
    491   1.1   mycroft  */
    492   1.1   mycroft int
    493  1.70   thorpej ffs_reclaim(void *v)
    494   1.6  christos {
    495   1.1   mycroft 	struct vop_reclaim_args /* {
    496   1.1   mycroft 		struct vnode *a_vp;
    497  1.59      fvdl 		struct proc *a_p;
    498   1.6  christos 	} */ *ap = v;
    499  1.26  augustss 	struct vnode *vp = ap->a_vp;
    500  1.56      fvdl 	struct inode *ip = VTOI(vp);
    501  1.56      fvdl 	struct ufsmount *ump = ip->i_ump;
    502   1.1   mycroft 	int error;
    503   1.1   mycroft 
    504  1.59      fvdl 	if ((error = ufs_reclaim(vp, ap->a_p)) != 0)
    505   1.1   mycroft 		return (error);
    506  1.57      fvdl 	if (ip->i_din.ffs1_din != NULL) {
    507  1.57      fvdl 		if (ump->um_fstype == UFS1)
    508  1.57      fvdl 			pool_put(&ffs_dinode1_pool, ip->i_din.ffs1_din);
    509  1.57      fvdl 		else
    510  1.57      fvdl 			pool_put(&ffs_dinode2_pool, ip->i_din.ffs2_din);
    511  1.57      fvdl 	}
    512  1.16   thorpej 	/*
    513  1.16   thorpej 	 * XXX MFS ends up here, too, to free an inode.  Should we create
    514  1.16   thorpej 	 * XXX a separate pool for MFS inodes?
    515  1.16   thorpej 	 */
    516  1.16   thorpej 	pool_put(&ffs_inode_pool, vp->v_data);
    517   1.1   mycroft 	vp->v_data = NULL;
    518   1.1   mycroft 	return (0);
    519  1.35       chs }
    520  1.35       chs 
    521  1.39       chs int
    522  1.39       chs ffs_getpages(void *v)
    523  1.39       chs {
    524  1.39       chs 	struct vop_getpages_args /* {
    525  1.39       chs 		struct vnode *a_vp;
    526  1.39       chs 		voff_t a_offset;
    527  1.39       chs 		struct vm_page **a_m;
    528  1.39       chs 		int *a_count;
    529  1.39       chs 		int a_centeridx;
    530  1.39       chs 		vm_prot_t a_access_type;
    531  1.39       chs 		int a_advice;
    532  1.39       chs 		int a_flags;
    533  1.39       chs 	} */ *ap = v;
    534  1.39       chs 	struct vnode *vp = ap->a_vp;
    535  1.39       chs 	struct inode *ip = VTOI(vp);
    536  1.39       chs 	struct fs *fs = ip->i_fs;
    537  1.39       chs 
    538  1.39       chs 	/*
    539  1.39       chs 	 * don't allow a softdep write to create pages for only part of a block.
    540  1.39       chs 	 * the dependency tracking requires that all pages be in memory for
    541  1.39       chs 	 * a block involved in a dependency.
    542  1.39       chs 	 */
    543  1.39       chs 
    544  1.39       chs 	if (ap->a_flags & PGO_OVERWRITE &&
    545  1.39       chs 	    (blkoff(fs, ap->a_offset) != 0 ||
    546  1.39       chs 	     blkoff(fs, *ap->a_count << PAGE_SHIFT) != 0) &&
    547  1.39       chs 	    DOINGSOFTDEP(ap->a_vp)) {
    548  1.39       chs 		if ((ap->a_flags & PGO_LOCKED) == 0) {
    549  1.46       chs 			simple_unlock(&vp->v_interlock);
    550  1.39       chs 		}
    551  1.39       chs 		return EINVAL;
    552  1.39       chs 	}
    553  1.39       chs 	return genfs_getpages(v);
    554  1.49       chs }
    555  1.49       chs 
    556  1.49       chs int
    557  1.49       chs ffs_putpages(void *v)
    558  1.49       chs {
    559  1.49       chs 	struct vop_putpages_args /* {
    560  1.49       chs 		struct vnode *a_vp;
    561  1.49       chs 		voff_t a_offlo;
    562  1.49       chs 		voff_t a_offhi;
    563  1.49       chs 		int a_flags;
    564  1.49       chs 	} */ *ap = v;
    565  1.49       chs 	struct vnode *vp = ap->a_vp;
    566  1.49       chs 	struct uvm_object *uobj = &vp->v_uobj;
    567  1.49       chs 	struct inode *ip = VTOI(vp);
    568  1.49       chs 	struct fs *fs = ip->i_fs;
    569  1.49       chs 	struct vm_page *pg;
    570  1.49       chs 	off_t off;
    571  1.49       chs 
    572  1.49       chs 	if (!DOINGSOFTDEP(vp) || (ap->a_flags & PGO_CLEANIT) == 0) {
    573  1.49       chs 		return genfs_putpages(v);
    574  1.49       chs 	}
    575  1.49       chs 
    576  1.49       chs 	/*
    577  1.49       chs 	 * for softdep files, force the pages in a block to be written together.
    578  1.49       chs 	 * if we're the pagedaemon and we would have to wait for other pages,
    579  1.49       chs 	 * just fail the request.  the pagedaemon will pick a different page.
    580  1.49       chs 	 */
    581  1.49       chs 
    582  1.49       chs 	ap->a_offlo &= ~fs->fs_qbmask;
    583  1.49       chs 	ap->a_offhi = blkroundup(fs, ap->a_offhi);
    584  1.49       chs 	if (curproc == uvm.pagedaemon_proc) {
    585  1.49       chs 		for (off = ap->a_offlo; off < ap->a_offhi; off += PAGE_SIZE) {
    586  1.49       chs 			pg = uvm_pagelookup(uobj, off);
    587  1.49       chs 
    588  1.49       chs 			/*
    589  1.49       chs 			 * we only have missing pages here because the
    590  1.49       chs 			 * calculation of offhi above doesn't account for
    591  1.49       chs 			 * fragments.  so once we see one missing page,
    592  1.49       chs 			 * the rest should be missing as well, but we'll
    593  1.49       chs 			 * check for the rest just to be paranoid.
    594  1.49       chs 			 */
    595  1.49       chs 
    596  1.49       chs 			if (pg == NULL) {
    597  1.49       chs 				continue;
    598  1.49       chs 			}
    599  1.49       chs 			if (pg->flags & PG_BUSY) {
    600  1.49       chs 				simple_unlock(&uobj->vmobjlock);
    601  1.49       chs 				return EBUSY;
    602  1.49       chs 			}
    603  1.49       chs 		}
    604  1.49       chs 	}
    605  1.49       chs 	return genfs_putpages(v);
    606  1.39       chs }
    607  1.39       chs 
    608  1.35       chs /*
    609  1.35       chs  * Return the last logical file offset that should be written for this file
    610  1.35       chs  * if we're doing a write that ends at "size".
    611  1.35       chs  */
    612  1.39       chs 
    613  1.39       chs void
    614  1.55  perseant ffs_gop_size(struct vnode *vp, off_t size, off_t *eobp, int flags)
    615  1.35       chs {
    616  1.39       chs 	struct inode *ip = VTOI(vp);
    617  1.35       chs 	struct fs *fs = ip->i_fs;
    618  1.52      fvdl 	daddr_t olbn, nlbn;
    619  1.55  perseant 
    620  1.55  perseant 	KASSERT(flags & (GOP_SIZE_READ | GOP_SIZE_WRITE));
    621  1.69     perry 	KASSERT((flags & (GOP_SIZE_READ | GOP_SIZE_WRITE))
    622  1.55  perseant 		!= (GOP_SIZE_READ | GOP_SIZE_WRITE));
    623  1.35       chs 
    624  1.56      fvdl 	olbn = lblkno(fs, ip->i_size);
    625  1.39       chs 	nlbn = lblkno(fs, size);
    626  1.35       chs 	if (nlbn < NDADDR && olbn <= nlbn) {
    627  1.39       chs 		*eobp = fragroundup(fs, size);
    628  1.35       chs 	} else {
    629  1.39       chs 		*eobp = blkroundup(fs, size);
    630  1.35       chs 	}
    631   1.1   mycroft }
    632  1.73   thorpej 
    633  1.73   thorpej int
    634  1.73   thorpej ffs_openextattr(void *v)
    635  1.73   thorpej {
    636  1.73   thorpej 	struct vop_openextattr_args /* {
    637  1.73   thorpej 		struct vnode *a_vp;
    638  1.73   thorpej 		struct ucred *a_cred;
    639  1.73   thorpej 		struct proc *a_p;
    640  1.73   thorpej 	} */ *ap = v;
    641  1.73   thorpej 	struct inode *ip = VTOI(ap->a_vp);
    642  1.73   thorpej 	struct fs *fs = ip->i_fs;
    643  1.73   thorpej 
    644  1.73   thorpej 	/* Not supported for UFS1 file systems. */
    645  1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC)
    646  1.73   thorpej 		return (EOPNOTSUPP);
    647  1.73   thorpej 
    648  1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    649  1.73   thorpej 	return (EOPNOTSUPP);
    650  1.73   thorpej }
    651  1.73   thorpej 
    652  1.73   thorpej int
    653  1.73   thorpej ffs_closeextattr(void *v)
    654  1.73   thorpej {
    655  1.73   thorpej 	struct vop_closeextattr_args /* {
    656  1.73   thorpej 		struct vnode *a_vp;
    657  1.73   thorpej 		int a_commit;
    658  1.73   thorpej 		struct ucred *a_cred;
    659  1.73   thorpej 		struct proc *a_p;
    660  1.73   thorpej 	} */ *ap = v;
    661  1.73   thorpej 	struct inode *ip = VTOI(ap->a_vp);
    662  1.73   thorpej 	struct fs *fs = ip->i_fs;
    663  1.73   thorpej 
    664  1.73   thorpej 	/* Not supported for UFS1 file systems. */
    665  1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC)
    666  1.73   thorpej 		return (EOPNOTSUPP);
    667  1.73   thorpej 
    668  1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    669  1.73   thorpej 	return (EOPNOTSUPP);
    670  1.73   thorpej }
    671  1.73   thorpej 
    672  1.73   thorpej int
    673  1.73   thorpej ffs_getextattr(void *v)
    674  1.73   thorpej {
    675  1.73   thorpej 	struct vop_getextattr_args /* {
    676  1.73   thorpej 		struct vnode *a_vp;
    677  1.73   thorpej 		int a_attrnamespace;
    678  1.73   thorpej 		const char *a_name;
    679  1.73   thorpej 		struct uio *a_uio;
    680  1.73   thorpej 		size_t *a_size;
    681  1.73   thorpej 		struct ucred *a_cred;
    682  1.73   thorpej 		struct proc *a_p;
    683  1.73   thorpej 	} */ *ap = v;
    684  1.73   thorpej 	struct inode *ip = VTOI(ap->a_vp);
    685  1.73   thorpej 	struct fs *fs = ip->i_fs;
    686  1.73   thorpej 
    687  1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC) {
    688  1.73   thorpej #ifdef UFS_EXTATTR
    689  1.73   thorpej 		return (ufs_getextattr(ap));
    690  1.73   thorpej #else
    691  1.73   thorpej 		return (EOPNOTSUPP);
    692  1.73   thorpej #endif
    693  1.73   thorpej 	}
    694  1.73   thorpej 
    695  1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    696  1.73   thorpej 	return (EOPNOTSUPP);
    697  1.73   thorpej }
    698  1.73   thorpej 
    699  1.73   thorpej int
    700  1.73   thorpej ffs_setextattr(void *v)
    701  1.73   thorpej {
    702  1.73   thorpej 	struct vop_setextattr_args /* {
    703  1.73   thorpej 		struct vnode *a_vp;
    704  1.73   thorpej 		int a_attrnamespace;
    705  1.73   thorpej 		const char *a_name;
    706  1.73   thorpej 		struct uio *a_uio;
    707  1.73   thorpej 		struct ucred *a_cred;
    708  1.73   thorpej 		struct proc *a_p;
    709  1.73   thorpej 	} */ *ap = v;
    710  1.73   thorpej 	struct inode *ip = VTOI(ap->a_vp);
    711  1.73   thorpej 	struct fs *fs = ip->i_fs;
    712  1.73   thorpej 
    713  1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC) {
    714  1.73   thorpej #ifdef UFS_EXTATTR
    715  1.73   thorpej 		return (ufs_setextattr(ap));
    716  1.73   thorpej #else
    717  1.73   thorpej 		return (EOPNOTSUPP);
    718  1.73   thorpej #endif
    719  1.73   thorpej 	}
    720  1.73   thorpej 
    721  1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    722  1.73   thorpej 	return (EOPNOTSUPP);
    723  1.73   thorpej }
    724  1.73   thorpej 
    725  1.73   thorpej int
    726  1.73   thorpej ffs_listextattr(void *v)
    727  1.73   thorpej {
    728  1.73   thorpej 	struct vop_listextattr_args /* {
    729  1.73   thorpej 		struct vnode *a_vp;
    730  1.73   thorpej 		int a_attrnamespace;
    731  1.73   thorpej 		struct uio *a_uio;
    732  1.73   thorpej 		size_t *a_size;
    733  1.73   thorpej 		struct ucred *a_cred;
    734  1.73   thorpej 		struct proc *a_p;
    735  1.73   thorpej 	} */ *ap = v;
    736  1.73   thorpej 	struct inode *ip = VTOI(ap->a_vp);
    737  1.73   thorpej 	struct fs *fs = ip->i_fs;
    738  1.73   thorpej 
    739  1.73   thorpej 	/* Not supported for UFS1 file systems. */
    740  1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC)
    741  1.73   thorpej 		return (EOPNOTSUPP);
    742  1.73   thorpej 
    743  1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    744  1.73   thorpej 	return (EOPNOTSUPP);
    745  1.73   thorpej }
    746  1.73   thorpej 
    747  1.73   thorpej int
    748  1.73   thorpej ffs_deleteextattr(void *v)
    749  1.73   thorpej {
    750  1.73   thorpej 	struct vop_deleteextattr_args /* {
    751  1.73   thorpej 		struct vnode *a_vp;
    752  1.73   thorpej 		int a_attrnamespace;
    753  1.73   thorpej 		struct ucred *a_cred;
    754  1.73   thorpej 		struct proc *a_p;
    755  1.73   thorpej 	} */ *ap = v;
    756  1.73   thorpej 	struct inode *ip = VTOI(ap->a_vp);
    757  1.73   thorpej 	struct fs *fs = ip->i_fs;
    758  1.73   thorpej 
    759  1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC) {
    760  1.73   thorpej #ifdef UFS_EXTATTR
    761  1.73   thorpej 		return (ufs_deleteextattr(ap));
    762  1.73   thorpej #else
    763  1.73   thorpej 		return (EOPNOTSUPP);
    764  1.73   thorpej #endif
    765  1.73   thorpej 	}
    766  1.73   thorpej 
    767  1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    768  1.73   thorpej 	return (EOPNOTSUPP);
    769  1.73   thorpej }
    770