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