Home | History | Annotate | Line # | Download | only in ffs
ffs_vnops.c revision 1.129.10.1
      1  1.129.10.1    martin /*	$NetBSD: ffs_vnops.c,v 1.129.10.1 2020/04/08 14:09:03 martin Exp $	*/
      2       1.100    simonb 
      3       1.100    simonb /*-
      4       1.109        ad  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
      5       1.100    simonb  * All rights reserved.
      6       1.100    simonb  *
      7       1.100    simonb  * This code is derived from software contributed to The NetBSD Foundation
      8       1.109        ad  * by Wasabi Systems, Inc, and by Andrew Doran.
      9       1.100    simonb  *
     10       1.100    simonb  * Redistribution and use in source and binary forms, with or without
     11       1.100    simonb  * modification, are permitted provided that the following conditions
     12       1.100    simonb  * are met:
     13       1.100    simonb  * 1. Redistributions of source code must retain the above copyright
     14       1.100    simonb  *    notice, this list of conditions and the following disclaimer.
     15       1.100    simonb  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.100    simonb  *    notice, this list of conditions and the following disclaimer in the
     17       1.100    simonb  *    documentation and/or other materials provided with the distribution.
     18       1.100    simonb  *
     19       1.100    simonb  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20       1.100    simonb  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21       1.100    simonb  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22       1.100    simonb  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23       1.100    simonb  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24       1.100    simonb  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25       1.100    simonb  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26       1.100    simonb  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27       1.100    simonb  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28       1.100    simonb  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29       1.100    simonb  * POSSIBILITY OF SUCH DAMAGE.
     30       1.100    simonb  */
     31         1.3       cgd 
     32         1.1   mycroft /*
     33         1.1   mycroft  * Copyright (c) 1982, 1986, 1989, 1993
     34         1.1   mycroft  *	The Regents of the University of California.  All rights reserved.
     35         1.1   mycroft  *
     36         1.1   mycroft  * Redistribution and use in source and binary forms, with or without
     37         1.1   mycroft  * modification, are permitted provided that the following conditions
     38         1.1   mycroft  * are met:
     39         1.1   mycroft  * 1. Redistributions of source code must retain the above copyright
     40         1.1   mycroft  *    notice, this list of conditions and the following disclaimer.
     41         1.1   mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     42         1.1   mycroft  *    notice, this list of conditions and the following disclaimer in the
     43         1.1   mycroft  *    documentation and/or other materials provided with the distribution.
     44        1.60       agc  * 3. Neither the name of the University nor the names of its contributors
     45         1.1   mycroft  *    may be used to endorse or promote products derived from this software
     46         1.1   mycroft  *    without specific prior written permission.
     47         1.1   mycroft  *
     48         1.1   mycroft  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     49         1.1   mycroft  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     50         1.1   mycroft  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     51         1.1   mycroft  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     52         1.1   mycroft  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     53         1.1   mycroft  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     54         1.1   mycroft  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     55         1.1   mycroft  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     56         1.1   mycroft  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     57         1.1   mycroft  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     58         1.1   mycroft  * SUCH DAMAGE.
     59         1.1   mycroft  *
     60        1.12      fvdl  *	@(#)ffs_vnops.c	8.15 (Berkeley) 5/14/95
     61         1.1   mycroft  */
     62        1.44     lukem 
     63        1.44     lukem #include <sys/cdefs.h>
     64  1.129.10.1    martin __KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.129.10.1 2020/04/08 14:09:03 martin Exp $");
     65       1.100    simonb 
     66       1.100    simonb #if defined(_KERNEL_OPT)
     67       1.100    simonb #include "opt_ffs.h"
     68       1.100    simonb #include "opt_wapbl.h"
     69       1.100    simonb #endif
     70        1.11       mrg 
     71         1.1   mycroft #include <sys/param.h>
     72         1.1   mycroft #include <sys/systm.h>
     73         1.1   mycroft #include <sys/resourcevar.h>
     74         1.1   mycroft #include <sys/kernel.h>
     75         1.1   mycroft #include <sys/file.h>
     76         1.1   mycroft #include <sys/stat.h>
     77         1.1   mycroft #include <sys/buf.h>
     78        1.50  jdolecek #include <sys/event.h>
     79         1.1   mycroft #include <sys/proc.h>
     80         1.1   mycroft #include <sys/mount.h>
     81         1.1   mycroft #include <sys/vnode.h>
     82        1.16   thorpej #include <sys/pool.h>
     83         1.6  christos #include <sys/signalvar.h>
     84        1.80      elad #include <sys/kauth.h>
     85       1.100    simonb #include <sys/wapbl.h>
     86         1.1   mycroft 
     87         1.8   mycroft #include <miscfs/fifofs/fifo.h>
     88         1.8   mycroft #include <miscfs/genfs/genfs.h>
     89         1.1   mycroft #include <miscfs/specfs/specdev.h>
     90         1.1   mycroft 
     91         1.1   mycroft #include <ufs/ufs/inode.h>
     92         1.1   mycroft #include <ufs/ufs/dir.h>
     93         1.1   mycroft #include <ufs/ufs/ufs_extern.h>
     94         1.2   mycroft #include <ufs/ufs/ufsmount.h>
     95       1.100    simonb #include <ufs/ufs/ufs_wapbl.h>
     96         1.1   mycroft 
     97         1.1   mycroft #include <ufs/ffs/fs.h>
     98         1.1   mycroft #include <ufs/ffs/ffs_extern.h>
     99         1.1   mycroft 
    100        1.49       chs #include <uvm/uvm.h>
    101        1.49       chs 
    102         1.1   mycroft /* Global vfs data structures for ufs. */
    103        1.74   xtraeme int (**ffs_vnodeop_p)(void *);
    104        1.37  jdolecek const struct vnodeopv_entry_desc ffs_vnodeop_entries[] = {
    105         1.1   mycroft 	{ &vop_default_desc, vn_default_error },
    106         1.1   mycroft 	{ &vop_lookup_desc, ufs_lookup },		/* lookup */
    107         1.1   mycroft 	{ &vop_create_desc, ufs_create },		/* create */
    108         1.5   mycroft 	{ &vop_whiteout_desc, ufs_whiteout },		/* whiteout */
    109         1.1   mycroft 	{ &vop_mknod_desc, ufs_mknod },			/* mknod */
    110         1.1   mycroft 	{ &vop_open_desc, ufs_open },			/* open */
    111         1.1   mycroft 	{ &vop_close_desc, ufs_close },			/* close */
    112         1.1   mycroft 	{ &vop_access_desc, ufs_access },		/* access */
    113         1.1   mycroft 	{ &vop_getattr_desc, ufs_getattr },		/* getattr */
    114         1.1   mycroft 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
    115         1.1   mycroft 	{ &vop_read_desc, ffs_read },			/* read */
    116         1.1   mycroft 	{ &vop_write_desc, ffs_write },			/* write */
    117       1.125  dholland 	{ &vop_fallocate_desc, genfs_eopnotsupp },	/* fallocate */
    118       1.125  dholland 	{ &vop_fdiscard_desc, genfs_eopnotsupp },	/* fdiscard */
    119         1.1   mycroft 	{ &vop_ioctl_desc, ufs_ioctl },			/* ioctl */
    120        1.19  wrstuden 	{ &vop_fcntl_desc, ufs_fcntl },			/* fcntl */
    121         1.9   mycroft 	{ &vop_poll_desc, ufs_poll },			/* poll */
    122        1.50  jdolecek 	{ &vop_kqfilter_desc, genfs_kqfilter },		/* kqfilter */
    123        1.12      fvdl 	{ &vop_revoke_desc, ufs_revoke },		/* revoke */
    124         1.1   mycroft 	{ &vop_mmap_desc, ufs_mmap },			/* mmap */
    125         1.1   mycroft 	{ &vop_fsync_desc, ffs_fsync },			/* fsync */
    126         1.1   mycroft 	{ &vop_seek_desc, ufs_seek },			/* seek */
    127         1.1   mycroft 	{ &vop_remove_desc, ufs_remove },		/* remove */
    128         1.1   mycroft 	{ &vop_link_desc, ufs_link },			/* link */
    129         1.1   mycroft 	{ &vop_rename_desc, ufs_rename },		/* rename */
    130         1.1   mycroft 	{ &vop_mkdir_desc, ufs_mkdir },			/* mkdir */
    131         1.1   mycroft 	{ &vop_rmdir_desc, ufs_rmdir },			/* rmdir */
    132         1.1   mycroft 	{ &vop_symlink_desc, ufs_symlink },		/* symlink */
    133         1.1   mycroft 	{ &vop_readdir_desc, ufs_readdir },		/* readdir */
    134         1.1   mycroft 	{ &vop_readlink_desc, ufs_readlink },		/* readlink */
    135         1.1   mycroft 	{ &vop_abortop_desc, ufs_abortop },		/* abortop */
    136         1.1   mycroft 	{ &vop_inactive_desc, ufs_inactive },		/* inactive */
    137         1.1   mycroft 	{ &vop_reclaim_desc, ffs_reclaim },		/* reclaim */
    138       1.113   hannken 	{ &vop_lock_desc, ufs_lock },			/* lock */
    139       1.113   hannken 	{ &vop_unlock_desc, ufs_unlock },		/* unlock */
    140         1.1   mycroft 	{ &vop_bmap_desc, ufs_bmap },			/* bmap */
    141         1.1   mycroft 	{ &vop_strategy_desc, ufs_strategy },		/* strategy */
    142         1.1   mycroft 	{ &vop_print_desc, ufs_print },			/* print */
    143       1.113   hannken 	{ &vop_islocked_desc, ufs_islocked },		/* islocked */
    144         1.1   mycroft 	{ &vop_pathconf_desc, ufs_pathconf },		/* pathconf */
    145         1.1   mycroft 	{ &vop_advlock_desc, ufs_advlock },		/* advlock */
    146         1.8   mycroft 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
    147        1.88      yamt 	{ &vop_getpages_desc, genfs_getpages },		/* getpages */
    148        1.75      yamt 	{ &vop_putpages_desc, genfs_putpages },		/* putpages */
    149        1.73   thorpej 	{ &vop_openextattr_desc, ffs_openextattr },	/* openextattr */
    150        1.73   thorpej 	{ &vop_closeextattr_desc, ffs_closeextattr },	/* closeextattr */
    151        1.73   thorpej 	{ &vop_getextattr_desc, ffs_getextattr },	/* getextattr */
    152        1.73   thorpej 	{ &vop_setextattr_desc, ffs_setextattr },	/* setextattr */
    153        1.73   thorpej 	{ &vop_listextattr_desc, ffs_listextattr },	/* listextattr */
    154        1.73   thorpej 	{ &vop_deleteextattr_desc, ffs_deleteextattr },	/* deleteextattr */
    155        1.35       chs 	{ NULL, NULL }
    156         1.1   mycroft };
    157        1.37  jdolecek const struct vnodeopv_desc ffs_vnodeop_opv_desc =
    158         1.1   mycroft 	{ &ffs_vnodeop_p, ffs_vnodeop_entries };
    159         1.1   mycroft 
    160        1.74   xtraeme int (**ffs_specop_p)(void *);
    161        1.37  jdolecek const struct vnodeopv_entry_desc ffs_specop_entries[] = {
    162         1.1   mycroft 	{ &vop_default_desc, vn_default_error },
    163         1.1   mycroft 	{ &vop_lookup_desc, spec_lookup },		/* lookup */
    164         1.1   mycroft 	{ &vop_create_desc, spec_create },		/* create */
    165         1.1   mycroft 	{ &vop_mknod_desc, spec_mknod },		/* mknod */
    166         1.1   mycroft 	{ &vop_open_desc, spec_open },			/* open */
    167         1.1   mycroft 	{ &vop_close_desc, ufsspec_close },		/* close */
    168         1.1   mycroft 	{ &vop_access_desc, ufs_access },		/* access */
    169         1.1   mycroft 	{ &vop_getattr_desc, ufs_getattr },		/* getattr */
    170         1.1   mycroft 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
    171         1.1   mycroft 	{ &vop_read_desc, ufsspec_read },		/* read */
    172         1.1   mycroft 	{ &vop_write_desc, ufsspec_write },		/* write */
    173       1.125  dholland 	{ &vop_fallocate_desc, spec_fallocate },	/* fallocate */
    174       1.125  dholland 	{ &vop_fdiscard_desc, spec_fdiscard },		/* fdiscard */
    175         1.1   mycroft 	{ &vop_ioctl_desc, spec_ioctl },		/* ioctl */
    176        1.19  wrstuden 	{ &vop_fcntl_desc, ufs_fcntl },			/* fcntl */
    177         1.9   mycroft 	{ &vop_poll_desc, spec_poll },			/* poll */
    178        1.50  jdolecek 	{ &vop_kqfilter_desc, spec_kqfilter },		/* kqfilter */
    179        1.12      fvdl 	{ &vop_revoke_desc, spec_revoke },		/* revoke */
    180         1.1   mycroft 	{ &vop_mmap_desc, spec_mmap },			/* mmap */
    181       1.118   hannken 	{ &vop_fsync_desc, ffs_spec_fsync },		/* fsync */
    182         1.1   mycroft 	{ &vop_seek_desc, spec_seek },			/* seek */
    183         1.1   mycroft 	{ &vop_remove_desc, spec_remove },		/* remove */
    184         1.1   mycroft 	{ &vop_link_desc, spec_link },			/* link */
    185         1.1   mycroft 	{ &vop_rename_desc, spec_rename },		/* rename */
    186         1.1   mycroft 	{ &vop_mkdir_desc, spec_mkdir },		/* mkdir */
    187         1.1   mycroft 	{ &vop_rmdir_desc, spec_rmdir },		/* rmdir */
    188         1.1   mycroft 	{ &vop_symlink_desc, spec_symlink },		/* symlink */
    189         1.1   mycroft 	{ &vop_readdir_desc, spec_readdir },		/* readdir */
    190         1.1   mycroft 	{ &vop_readlink_desc, spec_readlink },		/* readlink */
    191         1.1   mycroft 	{ &vop_abortop_desc, spec_abortop },		/* abortop */
    192         1.1   mycroft 	{ &vop_inactive_desc, ufs_inactive },		/* inactive */
    193         1.1   mycroft 	{ &vop_reclaim_desc, ffs_reclaim },		/* reclaim */
    194       1.113   hannken 	{ &vop_lock_desc, ufs_lock },			/* lock */
    195       1.113   hannken 	{ &vop_unlock_desc, ufs_unlock },		/* unlock */
    196         1.1   mycroft 	{ &vop_bmap_desc, spec_bmap },			/* bmap */
    197         1.1   mycroft 	{ &vop_strategy_desc, spec_strategy },		/* strategy */
    198         1.1   mycroft 	{ &vop_print_desc, ufs_print },			/* print */
    199       1.113   hannken 	{ &vop_islocked_desc, ufs_islocked },		/* islocked */
    200         1.1   mycroft 	{ &vop_pathconf_desc, spec_pathconf },		/* pathconf */
    201         1.1   mycroft 	{ &vop_advlock_desc, spec_advlock },		/* advlock */
    202         1.8   mycroft 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
    203        1.38       chs 	{ &vop_getpages_desc, spec_getpages },		/* getpages */
    204        1.38       chs 	{ &vop_putpages_desc, spec_putpages },		/* putpages */
    205        1.73   thorpej 	{ &vop_openextattr_desc, ffs_openextattr },	/* openextattr */
    206        1.73   thorpej 	{ &vop_closeextattr_desc, ffs_closeextattr },	/* closeextattr */
    207        1.73   thorpej 	{ &vop_getextattr_desc, ffs_getextattr },	/* getextattr */
    208        1.73   thorpej 	{ &vop_setextattr_desc, ffs_setextattr },	/* setextattr */
    209        1.73   thorpej 	{ &vop_listextattr_desc, ffs_listextattr },	/* listextattr */
    210        1.73   thorpej 	{ &vop_deleteextattr_desc, ffs_deleteextattr },	/* deleteextattr */
    211        1.35       chs 	{ NULL, NULL }
    212         1.1   mycroft };
    213        1.37  jdolecek const struct vnodeopv_desc ffs_specop_opv_desc =
    214         1.1   mycroft 	{ &ffs_specop_p, ffs_specop_entries };
    215         1.1   mycroft 
    216        1.74   xtraeme int (**ffs_fifoop_p)(void *);
    217        1.37  jdolecek const struct vnodeopv_entry_desc ffs_fifoop_entries[] = {
    218         1.1   mycroft 	{ &vop_default_desc, vn_default_error },
    219       1.114     pooka 	{ &vop_lookup_desc, vn_fifo_bypass },		/* lookup */
    220       1.114     pooka 	{ &vop_create_desc, vn_fifo_bypass },		/* create */
    221       1.114     pooka 	{ &vop_mknod_desc, vn_fifo_bypass },		/* mknod */
    222       1.114     pooka 	{ &vop_open_desc, vn_fifo_bypass },		/* open */
    223         1.1   mycroft 	{ &vop_close_desc, ufsfifo_close },		/* close */
    224         1.1   mycroft 	{ &vop_access_desc, ufs_access },		/* access */
    225         1.1   mycroft 	{ &vop_getattr_desc, ufs_getattr },		/* getattr */
    226         1.1   mycroft 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
    227         1.1   mycroft 	{ &vop_read_desc, ufsfifo_read },		/* read */
    228         1.1   mycroft 	{ &vop_write_desc, ufsfifo_write },		/* write */
    229       1.125  dholland 	{ &vop_fallocate_desc, vn_fifo_bypass },	/* fallocate */
    230       1.125  dholland 	{ &vop_fdiscard_desc, vn_fifo_bypass },		/* fdiscard */
    231       1.114     pooka 	{ &vop_ioctl_desc, vn_fifo_bypass },		/* ioctl */
    232        1.19  wrstuden 	{ &vop_fcntl_desc, ufs_fcntl },			/* fcntl */
    233       1.114     pooka 	{ &vop_poll_desc, vn_fifo_bypass },		/* poll */
    234       1.114     pooka 	{ &vop_kqfilter_desc, vn_fifo_bypass },		/* kqfilter */
    235       1.114     pooka 	{ &vop_revoke_desc, vn_fifo_bypass },		/* revoke */
    236       1.114     pooka 	{ &vop_mmap_desc, vn_fifo_bypass },		/* mmap */
    237         1.1   mycroft 	{ &vop_fsync_desc, ffs_fsync },			/* fsync */
    238       1.114     pooka 	{ &vop_seek_desc, vn_fifo_bypass },		/* seek */
    239       1.114     pooka 	{ &vop_remove_desc, vn_fifo_bypass },		/* remove */
    240       1.114     pooka 	{ &vop_link_desc, vn_fifo_bypass },		/* link */
    241       1.114     pooka 	{ &vop_rename_desc, vn_fifo_bypass },		/* rename */
    242       1.114     pooka 	{ &vop_mkdir_desc, vn_fifo_bypass },		/* mkdir */
    243       1.114     pooka 	{ &vop_rmdir_desc, vn_fifo_bypass },		/* rmdir */
    244       1.114     pooka 	{ &vop_symlink_desc, vn_fifo_bypass },		/* symlink */
    245       1.114     pooka 	{ &vop_readdir_desc, vn_fifo_bypass },		/* readdir */
    246       1.114     pooka 	{ &vop_readlink_desc, vn_fifo_bypass },		/* readlink */
    247       1.114     pooka 	{ &vop_abortop_desc, vn_fifo_bypass },		/* abortop */
    248         1.1   mycroft 	{ &vop_inactive_desc, ufs_inactive },		/* inactive */
    249         1.1   mycroft 	{ &vop_reclaim_desc, ffs_reclaim },		/* reclaim */
    250       1.113   hannken 	{ &vop_lock_desc, ufs_lock },			/* lock */
    251       1.113   hannken 	{ &vop_unlock_desc, ufs_unlock },		/* unlock */
    252       1.114     pooka 	{ &vop_bmap_desc, vn_fifo_bypass },		/* bmap */
    253       1.114     pooka 	{ &vop_strategy_desc, vn_fifo_bypass },		/* strategy */
    254         1.1   mycroft 	{ &vop_print_desc, ufs_print },			/* print */
    255       1.113   hannken 	{ &vop_islocked_desc, ufs_islocked },		/* islocked */
    256       1.114     pooka 	{ &vop_pathconf_desc, vn_fifo_bypass },		/* pathconf */
    257       1.114     pooka 	{ &vop_advlock_desc, vn_fifo_bypass },		/* advlock */
    258         1.8   mycroft 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
    259       1.114     pooka 	{ &vop_putpages_desc, vn_fifo_bypass }, 	/* putpages */
    260        1.73   thorpej 	{ &vop_openextattr_desc, ffs_openextattr },	/* openextattr */
    261        1.73   thorpej 	{ &vop_closeextattr_desc, ffs_closeextattr },	/* closeextattr */
    262        1.73   thorpej 	{ &vop_getextattr_desc, ffs_getextattr },	/* getextattr */
    263        1.73   thorpej 	{ &vop_setextattr_desc, ffs_setextattr },	/* setextattr */
    264        1.73   thorpej 	{ &vop_listextattr_desc, ffs_listextattr },	/* listextattr */
    265        1.73   thorpej 	{ &vop_deleteextattr_desc, ffs_deleteextattr },	/* deleteextattr */
    266        1.35       chs 	{ NULL, NULL }
    267         1.1   mycroft };
    268        1.37  jdolecek const struct vnodeopv_desc ffs_fifoop_opv_desc =
    269         1.1   mycroft 	{ &ffs_fifoop_p, ffs_fifoop_entries };
    270         1.1   mycroft 
    271         1.1   mycroft #include <ufs/ufs/ufs_readwrite.c>
    272        1.20      fvdl 
    273        1.33      fvdl int
    274       1.118   hannken ffs_spec_fsync(void *v)
    275       1.118   hannken {
    276       1.118   hannken 	struct vop_fsync_args /* {
    277       1.118   hannken 		struct vnode *a_vp;
    278       1.118   hannken 		kauth_cred_t a_cred;
    279       1.118   hannken 		int a_flags;
    280       1.118   hannken 		off_t a_offlo;
    281       1.118   hannken 		off_t a_offhi;
    282       1.118   hannken 		struct lwp *a_l;
    283       1.118   hannken 	} */ *ap = v;
    284       1.118   hannken 	int error, flags, uflags;
    285       1.118   hannken 	struct vnode *vp;
    286       1.118   hannken 
    287       1.118   hannken 	flags = ap->a_flags;
    288       1.118   hannken 	uflags = UPDATE_CLOSE | ((flags & FSYNC_WAIT) ? UPDATE_WAIT : 0);
    289       1.118   hannken 	vp = ap->a_vp;
    290       1.118   hannken 
    291       1.118   hannken 	error = spec_fsync(v);
    292       1.118   hannken 	if (error)
    293       1.118   hannken 		goto out;
    294       1.118   hannken 
    295       1.118   hannken #ifdef WAPBL
    296       1.128  christos 	struct mount *mp = vp->v_mount;
    297       1.128  christos 
    298       1.118   hannken 	if (mp && mp->mnt_wapbl) {
    299       1.118   hannken 		/*
    300       1.118   hannken 		 * Don't bother writing out metadata if the syncer is
    301       1.118   hannken 		 * making the request.  We will let the sync vnode
    302       1.118   hannken 		 * write it out in a single burst through a call to
    303       1.118   hannken 		 * VFS_SYNC().
    304       1.118   hannken 		 */
    305       1.118   hannken 		if ((flags & (FSYNC_DATAONLY | FSYNC_LAZY)) != 0)
    306       1.118   hannken 			goto out;
    307       1.118   hannken 		if ((VTOI(vp)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE
    308       1.118   hannken 		    | IN_MODIFY | IN_MODIFIED | IN_ACCESSED)) != 0) {
    309       1.118   hannken 			error = UFS_WAPBL_BEGIN(mp);
    310       1.118   hannken 			if (error != 0)
    311       1.118   hannken 				goto out;
    312       1.118   hannken 			error = ffs_update(vp, NULL, NULL, uflags);
    313       1.118   hannken 			UFS_WAPBL_END(mp);
    314       1.118   hannken 		}
    315       1.118   hannken 		goto out;
    316       1.118   hannken 	}
    317       1.118   hannken #endif /* WAPBL */
    318       1.118   hannken 
    319       1.118   hannken 	error = ffs_update(vp, NULL, NULL, uflags);
    320       1.118   hannken 
    321       1.118   hannken out:
    322       1.118   hannken 	return error;
    323       1.118   hannken }
    324       1.118   hannken 
    325       1.118   hannken int
    326        1.70   thorpej ffs_fsync(void *v)
    327        1.33      fvdl {
    328        1.33      fvdl 	struct vop_fsync_args /* {
    329        1.33      fvdl 		struct vnode *a_vp;
    330        1.80      elad 		kauth_cred_t a_cred;
    331        1.33      fvdl 		int a_flags;
    332        1.46       chs 		off_t a_offlo;
    333        1.46       chs 		off_t a_offhi;
    334        1.77  christos 		struct lwp *a_l;
    335        1.33      fvdl 	} */ *ap = v;
    336        1.35       chs 	struct buf *bp;
    337        1.94        ad 	int num, error, i;
    338       1.122  dholland 	struct indir ia[UFS_NIADDR + 1];
    339        1.33      fvdl 	int bsize;
    340        1.45    simonb 	daddr_t blk_high;
    341        1.33      fvdl 	struct vnode *vp;
    342       1.100    simonb 	struct mount *mp;
    343        1.33      fvdl 
    344        1.84   hannken 	vp = ap->a_vp;
    345       1.117   hannken 	mp = vp->v_mount;
    346        1.84   hannken 
    347       1.111        ad 	if ((ap->a_offlo == 0 && ap->a_offhi == 0) || (vp->v_type != VREG)) {
    348       1.111        ad 		error = ffs_full_fsync(vp, ap->a_flags);
    349        1.84   hannken 		goto out;
    350        1.84   hannken 	}
    351        1.33      fvdl 
    352       1.117   hannken 	bsize = mp->mnt_stat.f_iosize;
    353        1.33      fvdl 	blk_high = ap->a_offhi / bsize;
    354        1.33      fvdl 	if (ap->a_offhi % bsize != 0)
    355        1.33      fvdl 		blk_high++;
    356        1.33      fvdl 
    357        1.33      fvdl 	/*
    358        1.35       chs 	 * First, flush all pages in range.
    359        1.33      fvdl 	 */
    360        1.35       chs 
    361  1.129.10.1    martin 	rw_enter(vp->v_uobj.vmobjlock, RW_WRITER);
    362        1.64       dbj 	error = VOP_PUTPAGES(vp, trunc_page(ap->a_offlo),
    363        1.64       dbj 	    round_page(ap->a_offhi), PGO_CLEANIT |
    364        1.64       dbj 	    ((ap->a_flags & FSYNC_WAIT) ? PGO_SYNCIO : 0));
    365        1.64       dbj 	if (error) {
    366        1.84   hannken 		goto out;
    367        1.39       chs 	}
    368        1.33      fvdl 
    369       1.100    simonb #ifdef WAPBL
    370       1.117   hannken 	KASSERT(vp->v_type == VREG);
    371       1.100    simonb 	if (mp->mnt_wapbl) {
    372       1.110        ad 		/*
    373       1.110        ad 		 * Don't bother writing out metadata if the syncer is
    374       1.110        ad 		 * making the request.  We will let the sync vnode
    375       1.110        ad 		 * write it out in a single burst through a call to
    376       1.110        ad 		 * VFS_SYNC().
    377       1.110        ad 		 */
    378       1.110        ad 		if ((ap->a_flags & (FSYNC_DATAONLY | FSYNC_LAZY)) != 0) {
    379       1.100    simonb 			return 0;
    380       1.100    simonb 		}
    381       1.100    simonb 		error = 0;
    382       1.100    simonb 		if (vp->v_tag == VT_UFS && VTOI(vp)->i_flag &
    383       1.100    simonb 		    (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY |
    384       1.100    simonb 				 IN_MODIFIED | IN_ACCESSED)) {
    385       1.100    simonb 			error = UFS_WAPBL_BEGIN(mp);
    386       1.100    simonb 			if (error) {
    387       1.100    simonb 				return error;
    388       1.100    simonb 			}
    389       1.112        ad 			error = ffs_update(vp, NULL, NULL, UPDATE_CLOSE |
    390       1.112        ad 			    ((ap->a_flags & FSYNC_WAIT) ? UPDATE_WAIT : 0));
    391       1.100    simonb 			UFS_WAPBL_END(mp);
    392       1.100    simonb 		}
    393       1.110        ad 		if (error || (ap->a_flags & FSYNC_NOLOG) != 0) {
    394       1.100    simonb 			return error;
    395       1.100    simonb 		}
    396       1.100    simonb 		error = wapbl_flush(mp->mnt_wapbl, 0);
    397       1.100    simonb 		return error;
    398       1.100    simonb 	}
    399       1.100    simonb #endif /* WAPBL */
    400       1.100    simonb 
    401        1.33      fvdl 	/*
    402        1.35       chs 	 * Then, flush indirect blocks.
    403        1.33      fvdl 	 */
    404        1.35       chs 
    405       1.122  dholland 	if (blk_high >= UFS_NDADDR) {
    406        1.33      fvdl 		error = ufs_getlbns(vp, blk_high, ia, &num);
    407        1.94        ad 		if (error)
    408        1.84   hannken 			goto out;
    409        1.94        ad 
    410        1.94        ad 		mutex_enter(&bufcache_lock);
    411        1.33      fvdl 		for (i = 0; i < num; i++) {
    412        1.94        ad 			if ((bp = incore(vp, ia[i].in_lbn)) == NULL)
    413        1.94        ad 				continue;
    414        1.94        ad 			if ((bp->b_cflags & BC_BUSY) != 0 ||
    415        1.94        ad 			    (bp->b_oflags & BO_DELWRI) == 0)
    416        1.94        ad 				continue;
    417        1.94        ad 			bp->b_cflags |= BC_BUSY | BC_VFLUSH;
    418        1.94        ad 			mutex_exit(&bufcache_lock);
    419        1.94        ad 			bawrite(bp);
    420        1.94        ad 			mutex_enter(&bufcache_lock);
    421        1.33      fvdl 		}
    422        1.94        ad 		mutex_exit(&bufcache_lock);
    423        1.33      fvdl 	}
    424        1.33      fvdl 
    425        1.33      fvdl 	if (ap->a_flags & FSYNC_WAIT) {
    426       1.119     rmind 		mutex_enter(vp->v_interlock);
    427        1.94        ad 		while (vp->v_numoutput > 0)
    428       1.119     rmind 			cv_wait(&vp->v_cv, vp->v_interlock);
    429       1.119     rmind 		mutex_exit(vp->v_interlock);
    430        1.33      fvdl 	}
    431        1.33      fvdl 
    432       1.112        ad 	error = ffs_update(vp, NULL, NULL, UPDATE_CLOSE |
    433       1.112        ad 	    (((ap->a_flags & (FSYNC_WAIT | FSYNC_DATAONLY)) == FSYNC_WAIT)
    434       1.112        ad 	    ? UPDATE_WAIT : 0));
    435        1.67  wrstuden 
    436        1.67  wrstuden 	if (error == 0 && ap->a_flags & FSYNC_CACHE) {
    437        1.67  wrstuden 		int l = 0;
    438        1.67  wrstuden 		VOP_IOCTL(VTOI(vp)->i_devvp, DIOCCACHESYNC, &l, FWRITE,
    439        1.93     pooka 			curlwp->l_cred);
    440        1.67  wrstuden 	}
    441        1.67  wrstuden 
    442        1.84   hannken out:
    443        1.67  wrstuden 	return error;
    444        1.33      fvdl }
    445        1.33      fvdl 
    446        1.20      fvdl /*
    447       1.110        ad  * Synch an open file.  Called for VOP_FSYNC().
    448        1.20      fvdl  */
    449        1.20      fvdl /* ARGSUSED */
    450        1.94        ad int
    451        1.94        ad ffs_full_fsync(struct vnode *vp, int flags)
    452        1.20      fvdl {
    453       1.118   hannken 	int error, i, uflags;
    454        1.99        ad 
    455       1.118   hannken 	KASSERT(vp->v_tag == VT_UFS);
    456       1.110        ad 	KASSERT(VTOI(vp) != NULL);
    457       1.118   hannken 	KASSERT(vp->v_type != VCHR && vp->v_type != VBLK);
    458       1.110        ad 
    459       1.118   hannken 	uflags = UPDATE_CLOSE | ((flags & FSYNC_WAIT) ? UPDATE_WAIT : 0);
    460        1.24      fvdl 
    461       1.121       chs #ifdef WAPBL
    462       1.121       chs 	struct mount *mp = vp->v_mount;
    463       1.128  christos 
    464       1.121       chs 	if (mp && mp->mnt_wapbl) {
    465       1.105        ad 
    466       1.121       chs 		/*
    467       1.121       chs 		 * Flush all dirty data associated with the vnode.
    468       1.121       chs 		 */
    469       1.121       chs 		if (vp->v_type == VREG) {
    470       1.121       chs 			int pflags = PGO_ALLPAGES | PGO_CLEANIT;
    471       1.101     oster 
    472       1.121       chs 			if ((flags & FSYNC_LAZY))
    473       1.121       chs 				pflags |= PGO_LAZY;
    474       1.121       chs 			if ((flags & FSYNC_WAIT))
    475       1.121       chs 				pflags |= PGO_SYNCIO;
    476  1.129.10.1    martin 			rw_enter(vp->v_uobj.vmobjlock, RW_WRITER);
    477       1.121       chs 			error = VOP_PUTPAGES(vp, 0, 0, pflags);
    478       1.121       chs 			if (error)
    479       1.121       chs 				return error;
    480       1.121       chs 		}
    481       1.100    simonb 
    482       1.110        ad 		/*
    483       1.110        ad 		 * Don't bother writing out metadata if the syncer is
    484       1.110        ad 		 * making the request.  We will let the sync vnode
    485       1.110        ad 		 * write it out in a single burst through a call to
    486       1.110        ad 		 * VFS_SYNC().
    487       1.110        ad 		 */
    488       1.110        ad 		if ((flags & (FSYNC_DATAONLY | FSYNC_LAZY)) != 0)
    489       1.110        ad 			return 0;
    490       1.100    simonb 
    491       1.110        ad 		if ((VTOI(vp)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE
    492       1.109        ad 		    | IN_MODIFY | IN_MODIFIED | IN_ACCESSED)) != 0) {
    493       1.100    simonb 			error = UFS_WAPBL_BEGIN(mp);
    494       1.100    simonb 			if (error)
    495       1.100    simonb 				return error;
    496       1.118   hannken 			error = ffs_update(vp, NULL, NULL, uflags);
    497       1.100    simonb 			UFS_WAPBL_END(mp);
    498       1.121       chs 		} else {
    499       1.121       chs 			error = 0;
    500       1.100    simonb 		}
    501       1.110        ad 		if (error || (flags & FSYNC_NOLOG) != 0)
    502       1.100    simonb 			return error;
    503       1.106        ad 
    504       1.100    simonb 		/*
    505       1.100    simonb 		 * Don't flush the log if the vnode being flushed
    506       1.100    simonb 		 * contains no dirty buffers that could be in the log.
    507       1.100    simonb 		 */
    508       1.109        ad 		if (!LIST_EMPTY(&vp->v_dirtyblkhd)) {
    509       1.100    simonb 			error = wapbl_flush(mp->mnt_wapbl, 0);
    510       1.100    simonb 			if (error)
    511       1.100    simonb 				return error;
    512       1.100    simonb 		}
    513       1.100    simonb 
    514       1.109        ad 		if ((flags & FSYNC_WAIT) != 0) {
    515       1.119     rmind 			mutex_enter(vp->v_interlock);
    516       1.110        ad 			while (vp->v_numoutput != 0)
    517       1.119     rmind 				cv_wait(&vp->v_cv, vp->v_interlock);
    518       1.119     rmind 			mutex_exit(vp->v_interlock);
    519       1.100    simonb 		}
    520       1.100    simonb 
    521       1.100    simonb 		return error;
    522       1.100    simonb 	}
    523       1.100    simonb #endif /* WAPBL */
    524        1.35       chs 
    525       1.121       chs 	error = vflushbuf(vp, flags);
    526       1.118   hannken 	if (error == 0)
    527       1.118   hannken 		error = ffs_update(vp, NULL, NULL, uflags);
    528       1.109        ad 	if (error == 0 && (flags & FSYNC_CACHE) != 0) {
    529       1.118   hannken 		i = 1;
    530       1.110        ad 		(void)VOP_IOCTL(VTOI(vp)->i_devvp, DIOCCACHESYNC, &i, FWRITE,
    531       1.110        ad 		    kauth_cred_get());
    532        1.67  wrstuden 	}
    533        1.67  wrstuden 
    534        1.67  wrstuden 	return error;
    535        1.20      fvdl }
    536         1.1   mycroft 
    537         1.1   mycroft /*
    538         1.1   mycroft  * Reclaim an inode so that it can be used for other purposes.
    539         1.1   mycroft  */
    540         1.1   mycroft int
    541        1.70   thorpej ffs_reclaim(void *v)
    542         1.6  christos {
    543       1.129  riastrad 	struct vop_reclaim_v2_args /* {
    544         1.1   mycroft 		struct vnode *a_vp;
    545        1.77  christos 		struct lwp *a_l;
    546         1.6  christos 	} */ *ap = v;
    547        1.26  augustss 	struct vnode *vp = ap->a_vp;
    548        1.56      fvdl 	struct inode *ip = VTOI(vp);
    549        1.84   hannken 	struct mount *mp = vp->v_mount;
    550        1.56      fvdl 	struct ufsmount *ump = ip->i_ump;
    551        1.94        ad 	void *data;
    552         1.1   mycroft 	int error;
    553         1.1   mycroft 
    554       1.129  riastrad 	VOP_UNLOCK(vp);
    555       1.129  riastrad 
    556       1.115   hannken 	/*
    557       1.115   hannken 	 * The inode must be freed and updated before being removed
    558       1.115   hannken 	 * from its hash chain.  Other threads trying to gain a hold
    559       1.124   hannken 	 * or lock on the inode will be stalled.
    560       1.115   hannken 	 */
    561       1.115   hannken 	error = UFS_WAPBL_BEGIN(mp);
    562       1.115   hannken 	if (error) {
    563       1.115   hannken 		return error;
    564       1.115   hannken 	}
    565       1.116   hannken 	if (ip->i_nlink <= 0 && ip->i_omode != 0 &&
    566       1.116   hannken 	    (vp->v_mount->mnt_flag & MNT_RDONLY) == 0)
    567       1.115   hannken 		ffs_vfree(vp, ip->i_number, ip->i_omode);
    568       1.115   hannken 	UFS_WAPBL_END(mp);
    569        1.93     pooka 	if ((error = ufs_reclaim(vp)) != 0) {
    570         1.1   mycroft 		return (error);
    571        1.84   hannken 	}
    572        1.57      fvdl 	if (ip->i_din.ffs1_din != NULL) {
    573        1.57      fvdl 		if (ump->um_fstype == UFS1)
    574        1.95        ad 			pool_cache_put(ffs_dinode1_cache, ip->i_din.ffs1_din);
    575        1.57      fvdl 		else
    576        1.95        ad 			pool_cache_put(ffs_dinode2_cache, ip->i_din.ffs2_din);
    577        1.57      fvdl 	}
    578        1.16   thorpej 	/*
    579        1.94        ad 	 * To interlock with ffs_sync().
    580        1.94        ad 	 */
    581        1.94        ad 	genfs_node_destroy(vp);
    582       1.119     rmind 	mutex_enter(vp->v_interlock);
    583        1.94        ad 	data = vp->v_data;
    584        1.94        ad 	vp->v_data = NULL;
    585       1.119     rmind 	mutex_exit(vp->v_interlock);
    586        1.94        ad 
    587        1.94        ad 	/*
    588        1.16   thorpej 	 * XXX MFS ends up here, too, to free an inode.  Should we create
    589        1.16   thorpej 	 * XXX a separate pool for MFS inodes?
    590        1.16   thorpej 	 */
    591        1.95        ad 	pool_cache_put(ffs_inode_cache, data);
    592         1.1   mycroft 	return (0);
    593        1.35       chs }
    594        1.35       chs 
    595        1.35       chs /*
    596        1.35       chs  * Return the last logical file offset that should be written for this file
    597        1.35       chs  * if we're doing a write that ends at "size".
    598        1.35       chs  */
    599        1.39       chs 
    600        1.39       chs void
    601        1.83  christos ffs_gop_size(struct vnode *vp, off_t size, off_t *eobp, int flags)
    602        1.35       chs {
    603        1.39       chs 	struct inode *ip = VTOI(vp);
    604        1.35       chs 	struct fs *fs = ip->i_fs;
    605        1.52      fvdl 	daddr_t olbn, nlbn;
    606        1.55  perseant 
    607       1.123  dholland 	olbn = ffs_lblkno(fs, ip->i_size);
    608       1.123  dholland 	nlbn = ffs_lblkno(fs, size);
    609       1.122  dholland 	if (nlbn < UFS_NDADDR && olbn <= nlbn) {
    610       1.123  dholland 		*eobp = ffs_fragroundup(fs, size);
    611        1.35       chs 	} else {
    612       1.123  dholland 		*eobp = ffs_blkroundup(fs, size);
    613        1.35       chs 	}
    614         1.1   mycroft }
    615        1.73   thorpej 
    616        1.73   thorpej int
    617        1.73   thorpej ffs_openextattr(void *v)
    618        1.73   thorpej {
    619        1.73   thorpej 	struct vop_openextattr_args /* {
    620        1.73   thorpej 		struct vnode *a_vp;
    621        1.80      elad 		kauth_cred_t a_cred;
    622        1.73   thorpej 		struct proc *a_p;
    623        1.73   thorpej 	} */ *ap = v;
    624        1.73   thorpej 	struct inode *ip = VTOI(ap->a_vp);
    625        1.73   thorpej 	struct fs *fs = ip->i_fs;
    626        1.73   thorpej 
    627        1.73   thorpej 	/* Not supported for UFS1 file systems. */
    628        1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC)
    629        1.73   thorpej 		return (EOPNOTSUPP);
    630        1.73   thorpej 
    631        1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    632        1.73   thorpej 	return (EOPNOTSUPP);
    633        1.73   thorpej }
    634        1.73   thorpej 
    635        1.73   thorpej int
    636        1.73   thorpej ffs_closeextattr(void *v)
    637        1.73   thorpej {
    638        1.73   thorpej 	struct vop_closeextattr_args /* {
    639        1.73   thorpej 		struct vnode *a_vp;
    640        1.73   thorpej 		int a_commit;
    641        1.80      elad 		kauth_cred_t a_cred;
    642        1.73   thorpej 		struct proc *a_p;
    643        1.73   thorpej 	} */ *ap = v;
    644        1.73   thorpej 	struct inode *ip = VTOI(ap->a_vp);
    645        1.73   thorpej 	struct fs *fs = ip->i_fs;
    646        1.73   thorpej 
    647        1.73   thorpej 	/* Not supported for UFS1 file systems. */
    648        1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC)
    649        1.73   thorpej 		return (EOPNOTSUPP);
    650        1.73   thorpej 
    651        1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    652        1.73   thorpej 	return (EOPNOTSUPP);
    653        1.73   thorpej }
    654        1.73   thorpej 
    655        1.73   thorpej int
    656        1.73   thorpej ffs_getextattr(void *v)
    657        1.73   thorpej {
    658        1.73   thorpej 	struct vop_getextattr_args /* {
    659        1.73   thorpej 		struct vnode *a_vp;
    660        1.73   thorpej 		int a_attrnamespace;
    661        1.73   thorpej 		const char *a_name;
    662        1.73   thorpej 		struct uio *a_uio;
    663        1.73   thorpej 		size_t *a_size;
    664        1.80      elad 		kauth_cred_t a_cred;
    665        1.73   thorpej 		struct proc *a_p;
    666        1.73   thorpej 	} */ *ap = v;
    667        1.84   hannken 	struct vnode *vp = ap->a_vp;
    668        1.84   hannken 	struct inode *ip = VTOI(vp);
    669        1.73   thorpej 	struct fs *fs = ip->i_fs;
    670        1.73   thorpej 
    671        1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC) {
    672        1.73   thorpej #ifdef UFS_EXTATTR
    673        1.84   hannken 		int error;
    674        1.84   hannken 
    675        1.84   hannken 		error = ufs_getextattr(ap);
    676        1.84   hannken 		return error;
    677        1.73   thorpej #else
    678        1.73   thorpej 		return (EOPNOTSUPP);
    679        1.73   thorpej #endif
    680        1.73   thorpej 	}
    681        1.73   thorpej 
    682        1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    683        1.73   thorpej 	return (EOPNOTSUPP);
    684        1.73   thorpej }
    685        1.73   thorpej 
    686        1.73   thorpej int
    687        1.73   thorpej ffs_setextattr(void *v)
    688        1.73   thorpej {
    689        1.73   thorpej 	struct vop_setextattr_args /* {
    690        1.73   thorpej 		struct vnode *a_vp;
    691        1.73   thorpej 		int a_attrnamespace;
    692        1.73   thorpej 		const char *a_name;
    693        1.73   thorpej 		struct uio *a_uio;
    694        1.80      elad 		kauth_cred_t a_cred;
    695        1.73   thorpej 		struct proc *a_p;
    696        1.73   thorpej 	} */ *ap = v;
    697        1.84   hannken 	struct vnode *vp = ap->a_vp;
    698        1.84   hannken 	struct inode *ip = VTOI(vp);
    699        1.73   thorpej 	struct fs *fs = ip->i_fs;
    700        1.73   thorpej 
    701        1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC) {
    702        1.73   thorpej #ifdef UFS_EXTATTR
    703        1.84   hannken 		int error;
    704        1.84   hannken 
    705        1.84   hannken 		error = ufs_setextattr(ap);
    706        1.84   hannken 		return error;
    707        1.73   thorpej #else
    708        1.73   thorpej 		return (EOPNOTSUPP);
    709        1.73   thorpej #endif
    710        1.73   thorpej 	}
    711        1.73   thorpej 
    712        1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    713        1.73   thorpej 	return (EOPNOTSUPP);
    714        1.73   thorpej }
    715        1.73   thorpej 
    716        1.73   thorpej int
    717        1.73   thorpej ffs_listextattr(void *v)
    718        1.73   thorpej {
    719        1.73   thorpej 	struct vop_listextattr_args /* {
    720        1.73   thorpej 		struct vnode *a_vp;
    721        1.73   thorpej 		int a_attrnamespace;
    722        1.73   thorpej 		struct uio *a_uio;
    723        1.73   thorpej 		size_t *a_size;
    724        1.80      elad 		kauth_cred_t a_cred;
    725        1.73   thorpej 		struct proc *a_p;
    726        1.73   thorpej 	} */ *ap = v;
    727        1.73   thorpej 	struct inode *ip = VTOI(ap->a_vp);
    728        1.73   thorpej 	struct fs *fs = ip->i_fs;
    729        1.73   thorpej 
    730       1.120      manu 	if (fs->fs_magic == FS_UFS1_MAGIC) {
    731       1.120      manu #ifdef UFS_EXTATTR
    732       1.120      manu 		int error;
    733       1.120      manu 
    734       1.120      manu 		error = ufs_listextattr(ap);
    735       1.120      manu 		return error;
    736       1.120      manu #else
    737        1.73   thorpej 		return (EOPNOTSUPP);
    738       1.120      manu #endif
    739       1.120      manu 	}
    740        1.73   thorpej 
    741        1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    742        1.73   thorpej 	return (EOPNOTSUPP);
    743        1.73   thorpej }
    744        1.73   thorpej 
    745        1.73   thorpej int
    746        1.73   thorpej ffs_deleteextattr(void *v)
    747        1.73   thorpej {
    748        1.73   thorpej 	struct vop_deleteextattr_args /* {
    749        1.73   thorpej 		struct vnode *a_vp;
    750        1.73   thorpej 		int a_attrnamespace;
    751        1.80      elad 		kauth_cred_t a_cred;
    752        1.73   thorpej 		struct proc *a_p;
    753        1.73   thorpej 	} */ *ap = v;
    754        1.84   hannken 	struct vnode *vp = ap->a_vp;
    755        1.84   hannken 	struct inode *ip = VTOI(vp);
    756        1.73   thorpej 	struct fs *fs = ip->i_fs;
    757        1.73   thorpej 
    758        1.73   thorpej 	if (fs->fs_magic == FS_UFS1_MAGIC) {
    759        1.73   thorpej #ifdef UFS_EXTATTR
    760        1.84   hannken 		int error;
    761        1.84   hannken 
    762        1.84   hannken 		error = ufs_deleteextattr(ap);
    763        1.84   hannken 		return error;
    764        1.73   thorpej #else
    765        1.73   thorpej 		return (EOPNOTSUPP);
    766        1.73   thorpej #endif
    767        1.73   thorpej 	}
    768        1.73   thorpej 
    769        1.73   thorpej 	/* XXX Not implemented for UFS2 file systems. */
    770        1.73   thorpej 	return (EOPNOTSUPP);
    771        1.73   thorpej }
    772