Get rid of the weird coda VOP function arguments and void casts and
[dragonfly.git] / sys / kern / vfs_vopops.c
CommitLineData
2d3e977e
MD
1/*
2 *
3 * Copyright (c) 2004 The DragonFly Project. All rights reserved.
4 *
5 * This code is derived from software contributed to The DragonFly Project
6 * by Matthew Dillon <dillon@backplane.com>
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * 3. Neither the name of The DragonFly Project nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific, prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
66a1ddf5 35 * $DragonFly: src/sys/kern/vfs_vopops.c,v 1.28 2006/07/18 22:22:12 dillon Exp $
2d3e977e
MD
36 */
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/buf.h>
41#include <sys/conf.h>
42#include <sys/dirent.h>
43#include <sys/domain.h>
44#include <sys/eventhandler.h>
45#include <sys/fcntl.h>
46#include <sys/kernel.h>
47#include <sys/kthread.h>
48#include <sys/malloc.h>
49#include <sys/mbuf.h>
50#include <sys/mount.h>
51#include <sys/proc.h>
52#include <sys/namei.h>
53#include <sys/reboot.h>
54#include <sys/socket.h>
55#include <sys/stat.h>
56#include <sys/sysctl.h>
57#include <sys/syslog.h>
58#include <sys/vmmeter.h>
59#include <sys/vnode.h>
0961aa92 60#include <sys/vfsops.h>
2d3e977e
MD
61
62#include <machine/limits.h>
63
64#include <vm/vm.h>
65#include <vm/vm_object.h>
66#include <vm/vm_extern.h>
67#include <vm/vm_kern.h>
68#include <vm/pmap.h>
69#include <vm/vm_map.h>
70#include <vm/vm_page.h>
71#include <vm/vm_pager.h>
72#include <vm/vnode_pager.h>
73#include <vm/vm_zone.h>
74
75#include <sys/buf2.h>
76#include <sys/thread2.h>
77
2d3e977e
MD
78#define VDESCNAME(name) __CONCAT(__CONCAT(vop_,name),_desc)
79#define VARGSSTRUCT(name) struct __CONCAT(__CONCAT(vop_,name),_args)
80
88e4088e 81#define VNODEOP_DESC_INIT(name) \
2d3e977e
MD
82 struct vnodeop_desc VDESCNAME(name) = { \
83 __offsetof(struct vop_ops, __CONCAT(vop_, name)), \
88e4088e 84 #name }
2d3e977e
MD
85
86#define VNODEOP_DESC_INIT_SIMPLE(name) \
88e4088e 87 VNODEOP_DESC_INIT(name)
2d3e977e
MD
88
89VNODEOP_DESC_INIT_SIMPLE(default);
88e4088e
MD
90VNODEOP_DESC_INIT_SIMPLE(islocked);
91VNODEOP_DESC_INIT_SIMPLE(old_lookup);
92VNODEOP_DESC_INIT_SIMPLE(old_create);
93VNODEOP_DESC_INIT_SIMPLE(old_whiteout);
94VNODEOP_DESC_INIT_SIMPLE(old_mknod);
95VNODEOP_DESC_INIT_SIMPLE(open);
96VNODEOP_DESC_INIT_SIMPLE(close);
97VNODEOP_DESC_INIT_SIMPLE(access);
98VNODEOP_DESC_INIT_SIMPLE(getattr);
99VNODEOP_DESC_INIT_SIMPLE(setattr);
100VNODEOP_DESC_INIT_SIMPLE(read);
101VNODEOP_DESC_INIT_SIMPLE(write);
102VNODEOP_DESC_INIT_SIMPLE(ioctl);
103VNODEOP_DESC_INIT_SIMPLE(poll);
104VNODEOP_DESC_INIT_SIMPLE(kqfilter);
105VNODEOP_DESC_INIT_SIMPLE(revoke);
106VNODEOP_DESC_INIT_SIMPLE(mmap);
107VNODEOP_DESC_INIT_SIMPLE(fsync);
108VNODEOP_DESC_INIT_SIMPLE(old_remove);
109VNODEOP_DESC_INIT_SIMPLE(old_link);
110VNODEOP_DESC_INIT_SIMPLE(old_rename);
111
112VNODEOP_DESC_INIT_SIMPLE(old_mkdir);
113VNODEOP_DESC_INIT_SIMPLE(old_rmdir);
114VNODEOP_DESC_INIT_SIMPLE(old_symlink);
115VNODEOP_DESC_INIT_SIMPLE(readdir);
116VNODEOP_DESC_INIT_SIMPLE(readlink);
117VNODEOP_DESC_INIT_SIMPLE(inactive);
118VNODEOP_DESC_INIT_SIMPLE(reclaim);
119VNODEOP_DESC_INIT_SIMPLE(lock);
120VNODEOP_DESC_INIT_SIMPLE(unlock);
121VNODEOP_DESC_INIT_SIMPLE(bmap);
122VNODEOP_DESC_INIT_SIMPLE(strategy);
123VNODEOP_DESC_INIT_SIMPLE(print);
124VNODEOP_DESC_INIT_SIMPLE(pathconf);
125VNODEOP_DESC_INIT_SIMPLE(advlock);
126VNODEOP_DESC_INIT_SIMPLE(balloc);
127VNODEOP_DESC_INIT_SIMPLE(reallocblks);
128VNODEOP_DESC_INIT_SIMPLE(getpages);
129VNODEOP_DESC_INIT_SIMPLE(putpages);
130VNODEOP_DESC_INIT_SIMPLE(freeblks);
131VNODEOP_DESC_INIT_SIMPLE(getacl);
132VNODEOP_DESC_INIT_SIMPLE(setacl);
133VNODEOP_DESC_INIT_SIMPLE(aclcheck);
134VNODEOP_DESC_INIT_SIMPLE(getextattr);
135VNODEOP_DESC_INIT_SIMPLE(setextattr);
949ecb9b 136VNODEOP_DESC_INIT_SIMPLE(mountctl);
cbe54d63 137
88e4088e
MD
138VNODEOP_DESC_INIT_SIMPLE(nresolve);
139VNODEOP_DESC_INIT_SIMPLE(nlookupdotdot);
140VNODEOP_DESC_INIT_SIMPLE(ncreate);
141VNODEOP_DESC_INIT_SIMPLE(nmkdir);
142VNODEOP_DESC_INIT_SIMPLE(nmknod);
143VNODEOP_DESC_INIT_SIMPLE(nlink);
144VNODEOP_DESC_INIT_SIMPLE(nsymlink);
145VNODEOP_DESC_INIT_SIMPLE(nwhiteout);
146VNODEOP_DESC_INIT_SIMPLE(nremove);
147VNODEOP_DESC_INIT_SIMPLE(nrmdir);
148VNODEOP_DESC_INIT_SIMPLE(nrename);
fad57d0e 149
6ddb7618
MD
150#define DO_OPS(ops, error, ap, vop_field) \
151 error = ops->vop_field(ap);
2d3e977e 152
0961aa92
MD
153/************************************************************************
154 * PRIMARY HIGH LEVEL VNODE OPERATIONS CALLS *
155 ************************************************************************
156 *
157 * These procedures are called directly from the kernel and/or fileops
158 * code to perform file/device operations on the system.
e62afb5f
MD
159 *
160 * NOTE: The old namespace api functions such as vop_rename() are no longer
161 * available for general use and have been renamed to vop_old_*(). Only
162 * the code in vfs_default.c is allowed to call those ops.
0961aa92
MD
163 */
164
2d3e977e 165int
0961aa92 166vop_islocked(struct vop_ops *ops, struct vnode *vp, struct thread *td)
2d3e977e
MD
167{
168 struct vop_islocked_args ap;
cbe54d63 169 int error;
2d3e977e
MD
170
171 ap.a_head.a_desc = &vop_islocked_desc;
0961aa92 172 ap.a_head.a_ops = ops;
2d3e977e
MD
173 ap.a_vp = vp;
174 ap.a_td = td;
cbe54d63
MD
175
176 DO_OPS(ops, error, &ap, vop_islocked);
177 return(error);
2d3e977e
MD
178}
179
180int
e62afb5f 181vop_old_lookup(struct vop_ops *ops, struct vnode *dvp,
26b67a34 182 struct vnode **vpp, struct componentname *cnp)
2d3e977e 183{
e62afb5f 184 struct vop_old_lookup_args ap;
cbe54d63 185 int error;
2d3e977e 186
e62afb5f 187 ap.a_head.a_desc = &vop_old_lookup_desc;
0961aa92 188 ap.a_head.a_ops = ops;
2d3e977e 189 ap.a_dvp = dvp;
2d3e977e 190 ap.a_vpp = vpp;
2d3e977e 191 ap.a_cnp = cnp;
cbe54d63 192
e62afb5f 193 DO_OPS(ops, error, &ap, vop_old_lookup);
cbe54d63 194 return(error);
2d3e977e
MD
195}
196
197int
e62afb5f 198vop_old_create(struct vop_ops *ops, struct vnode *dvp,
0961aa92 199 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
2d3e977e 200{
e62afb5f 201 struct vop_old_create_args ap;
cbe54d63 202 int error;
2d3e977e 203
e62afb5f 204 ap.a_head.a_desc = &vop_old_create_desc;
0961aa92 205 ap.a_head.a_ops = ops;
2d3e977e 206 ap.a_dvp = dvp;
2d3e977e
MD
207 ap.a_vpp = vpp;
208 ap.a_cnp = cnp;
209 ap.a_vap = vap;
cbe54d63 210
e62afb5f 211 DO_OPS(ops, error, &ap, vop_old_create);
cbe54d63 212 return(error);
2d3e977e
MD
213}
214
215int
e62afb5f 216vop_old_whiteout(struct vop_ops *ops, struct vnode *dvp,
0961aa92 217 struct componentname *cnp, int flags)
2d3e977e 218{
e62afb5f 219 struct vop_old_whiteout_args ap;
cbe54d63 220 int error;
2d3e977e 221
e62afb5f 222 ap.a_head.a_desc = &vop_old_whiteout_desc;
0961aa92 223 ap.a_head.a_ops = ops;
2d3e977e 224 ap.a_dvp = dvp;
2d3e977e
MD
225 ap.a_cnp = cnp;
226 ap.a_flags = flags;
cbe54d63 227
e62afb5f 228 DO_OPS(ops, error, &ap, vop_old_whiteout);
cbe54d63 229 return(error);
2d3e977e
MD
230}
231
232int
e62afb5f 233vop_old_mknod(struct vop_ops *ops, struct vnode *dvp,
0961aa92 234 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
2d3e977e 235{
e62afb5f 236 struct vop_old_mknod_args ap;
cbe54d63 237 int error;
2d3e977e 238
e62afb5f 239 ap.a_head.a_desc = &vop_old_mknod_desc;
0961aa92 240 ap.a_head.a_ops = ops;
2d3e977e 241 ap.a_dvp = dvp;
2d3e977e
MD
242 ap.a_vpp = vpp;
243 ap.a_cnp = cnp;
244 ap.a_vap = vap;
cbe54d63 245
e62afb5f 246 DO_OPS(ops, error, &ap, vop_old_mknod);
cbe54d63 247 return(error);
2d3e977e
MD
248}
249
250int
0961aa92 251vop_open(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred,
87de5057 252 struct file *fp)
2d3e977e
MD
253{
254 struct vop_open_args ap;
cbe54d63 255 int error;
2d3e977e
MD
256
257 ap.a_head.a_desc = &vop_open_desc;
0961aa92 258 ap.a_head.a_ops = ops;
2d3e977e 259 ap.a_vp = vp;
fad57d0e 260 ap.a_fp = fp;
2d3e977e
MD
261 ap.a_mode = mode;
262 ap.a_cred = cred;
cbe54d63
MD
263
264 DO_OPS(ops, error, &ap, vop_open);
265 return(error);
2d3e977e
MD
266}
267
268int
87de5057 269vop_close(struct vop_ops *ops, struct vnode *vp, int fflag)
2d3e977e
MD
270{
271 struct vop_close_args ap;
cbe54d63 272 int error;
2d3e977e
MD
273
274 ap.a_head.a_desc = &vop_close_desc;
0961aa92 275 ap.a_head.a_ops = ops;
2d3e977e
MD
276 ap.a_vp = vp;
277 ap.a_fflag = fflag;
cbe54d63
MD
278
279 DO_OPS(ops, error, &ap, vop_close);
280 return(error);
2d3e977e
MD
281}
282
283int
87de5057 284vop_access(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred)
2d3e977e
MD
285{
286 struct vop_access_args ap;
cbe54d63 287 int error;
2d3e977e
MD
288
289 ap.a_head.a_desc = &vop_access_desc;
0961aa92 290 ap.a_head.a_ops = ops;
2d3e977e
MD
291 ap.a_vp = vp;
292 ap.a_mode = mode;
293 ap.a_cred = cred;
cbe54d63
MD
294
295 DO_OPS(ops, error, &ap, vop_access);
296 return(error);
2d3e977e
MD
297}
298
299int
87de5057 300vop_getattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap)
2d3e977e
MD
301{
302 struct vop_getattr_args ap;
cbe54d63 303 int error;
2d3e977e
MD
304
305 ap.a_head.a_desc = &vop_getattr_desc;
0961aa92 306 ap.a_head.a_ops = ops;
2d3e977e
MD
307 ap.a_vp = vp;
308 ap.a_vap = vap;
cbe54d63
MD
309
310 DO_OPS(ops, error, &ap, vop_getattr);
66a1ddf5 311 if ((ops->head.vv_mount->mnt_kern_flag & MNTK_FSMID) == 0)
021f7340 312 vap->va_fsmid = cache_sync_fsmid_vp(vp);
cbe54d63 313 return(error);
2d3e977e
MD
314}
315
316int
0961aa92 317vop_setattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
87de5057 318 struct ucred *cred)
2d3e977e
MD
319{
320 struct vop_setattr_args ap;
cbe54d63 321 int error;
2d3e977e
MD
322
323 ap.a_head.a_desc = &vop_setattr_desc;
0961aa92 324 ap.a_head.a_ops = ops;
2d3e977e
MD
325 ap.a_vp = vp;
326 ap.a_vap = vap;
327 ap.a_cred = cred;
cbe54d63
MD
328
329 DO_OPS(ops, error, &ap, vop_setattr);
7d15906a
MD
330 if (error == 0)
331 cache_update_fsmid_vp(vp);
cbe54d63 332 return(error);
2d3e977e
MD
333}
334
335int
0961aa92
MD
336vop_read(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
337 struct ucred *cred)
2d3e977e
MD
338{
339 struct vop_read_args ap;
cbe54d63 340 int error;
2d3e977e
MD
341
342 ap.a_head.a_desc = &vop_read_desc;
0961aa92 343 ap.a_head.a_ops = ops;
2d3e977e
MD
344 ap.a_vp = vp;
345 ap.a_uio = uio;
346 ap.a_ioflag = ioflag;
347 ap.a_cred = cred;
cbe54d63
MD
348
349 DO_OPS(ops, error, &ap, vop_read);
350 return(error);
2d3e977e
MD
351}
352
353int
0961aa92
MD
354vop_write(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
355 struct ucred *cred)
2d3e977e
MD
356{
357 struct vop_write_args ap;
cbe54d63 358 int error;
2d3e977e
MD
359
360 ap.a_head.a_desc = &vop_write_desc;
0961aa92 361 ap.a_head.a_ops = ops;
2d3e977e
MD
362 ap.a_vp = vp;
363 ap.a_uio = uio;
364 ap.a_ioflag = ioflag;
365 ap.a_cred = cred;
cbe54d63
MD
366
367 DO_OPS(ops, error, &ap, vop_write);
7d15906a
MD
368 if (error == 0)
369 cache_update_fsmid_vp(vp);
cbe54d63 370 return(error);
2d3e977e
MD
371}
372
2d3e977e 373int
0961aa92 374vop_ioctl(struct vop_ops *ops, struct vnode *vp, u_long command, caddr_t data,
87de5057 375 int fflag, struct ucred *cred)
2d3e977e
MD
376{
377 struct vop_ioctl_args ap;
cbe54d63 378 int error;
2d3e977e
MD
379
380 ap.a_head.a_desc = &vop_ioctl_desc;
0961aa92 381 ap.a_head.a_ops = ops;
2d3e977e
MD
382 ap.a_vp = vp;
383 ap.a_command = command;
384 ap.a_data = data;
385 ap.a_fflag = fflag;
386 ap.a_cred = cred;
cbe54d63
MD
387
388 DO_OPS(ops, error, &ap, vop_ioctl);
389 return(error);
2d3e977e
MD
390}
391
392int
87de5057 393vop_poll(struct vop_ops *ops, struct vnode *vp, int events, struct ucred *cred)
2d3e977e
MD
394{
395 struct vop_poll_args ap;
cbe54d63 396 int error;
2d3e977e
MD
397
398 ap.a_head.a_desc = &vop_poll_desc;
0961aa92 399 ap.a_head.a_ops = ops;
2d3e977e
MD
400 ap.a_vp = vp;
401 ap.a_events = events;
402 ap.a_cred = cred;
cbe54d63
MD
403
404 DO_OPS(ops, error, &ap, vop_poll);
405 return(error);
2d3e977e
MD
406}
407
408int
0961aa92 409vop_kqfilter(struct vop_ops *ops, struct vnode *vp, struct knote *kn)
2d3e977e
MD
410{
411 struct vop_kqfilter_args ap;
cbe54d63 412 int error;
2d3e977e
MD
413
414 ap.a_head.a_desc = &vop_kqfilter_desc;
0961aa92 415 ap.a_head.a_ops = ops;
2d3e977e
MD
416 ap.a_vp = vp;
417 ap.a_kn = kn;
cbe54d63
MD
418
419 DO_OPS(ops, error, &ap, vop_kqfilter);
420 return(error);
2d3e977e
MD
421}
422
423int
0961aa92 424vop_revoke(struct vop_ops *ops, struct vnode *vp, int flags)
2d3e977e
MD
425{
426 struct vop_revoke_args ap;
cbe54d63 427 int error;
2d3e977e
MD
428
429 ap.a_head.a_desc = &vop_revoke_desc;
0961aa92 430 ap.a_head.a_ops = ops;
2d3e977e
MD
431 ap.a_vp = vp;
432 ap.a_flags = flags;
cbe54d63
MD
433
434 DO_OPS(ops, error, &ap, vop_revoke);
435 return(error);
2d3e977e
MD
436}
437
438int
87de5057 439vop_mmap(struct vop_ops *ops, struct vnode *vp, int fflags, struct ucred *cred)
2d3e977e
MD
440{
441 struct vop_mmap_args ap;
cbe54d63 442 int error;
2d3e977e
MD
443
444 ap.a_head.a_desc = &vop_mmap_desc;
0961aa92 445 ap.a_head.a_ops = ops;
2d3e977e
MD
446 ap.a_vp = vp;
447 ap.a_fflags = fflags;
448 ap.a_cred = cred;
cbe54d63
MD
449
450 DO_OPS(ops, error, &ap, vop_mmap);
451 return(error);
2d3e977e
MD
452}
453
454int
87de5057 455vop_fsync(struct vop_ops *ops, struct vnode *vp, int waitfor)
2d3e977e
MD
456{
457 struct vop_fsync_args ap;
cbe54d63 458 int error;
2d3e977e
MD
459
460 ap.a_head.a_desc = &vop_fsync_desc;
0961aa92 461 ap.a_head.a_ops = ops;
2d3e977e
MD
462 ap.a_vp = vp;
463 ap.a_waitfor = waitfor;
cbe54d63
MD
464
465 DO_OPS(ops, error, &ap, vop_fsync);
466 return(error);
2d3e977e
MD
467}
468
469int
e62afb5f 470vop_old_remove(struct vop_ops *ops, struct vnode *dvp,
0961aa92 471 struct vnode *vp, struct componentname *cnp)
2d3e977e 472{
e62afb5f 473 struct vop_old_remove_args ap;
cbe54d63 474 int error;
2d3e977e 475
e62afb5f 476 ap.a_head.a_desc = &vop_old_remove_desc;
0961aa92 477 ap.a_head.a_ops = ops;
2d3e977e 478 ap.a_dvp = dvp;
2d3e977e
MD
479 ap.a_vp = vp;
480 ap.a_cnp = cnp;
cbe54d63 481
e62afb5f 482 DO_OPS(ops, error, &ap, vop_old_remove);
cbe54d63 483 return(error);
2d3e977e
MD
484}
485
21739618 486int
e62afb5f 487vop_old_link(struct vop_ops *ops, struct vnode *tdvp,
0961aa92 488 struct vnode *vp, struct componentname *cnp)
2d3e977e 489{
e62afb5f 490 struct vop_old_link_args ap;
cbe54d63 491 int error;
2d3e977e 492
e62afb5f 493 ap.a_head.a_desc = &vop_old_link_desc;
0961aa92 494 ap.a_head.a_ops = ops;
2d3e977e 495 ap.a_tdvp = tdvp;
2d3e977e
MD
496 ap.a_vp = vp;
497 ap.a_cnp = cnp;
cbe54d63 498
e62afb5f 499 DO_OPS(ops, error, &ap, vop_old_link);
cbe54d63 500 return(error);
2d3e977e
MD
501}
502
503int
e62afb5f 504vop_old_rename(struct vop_ops *ops,
fad57d0e
MD
505 struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp,
506 struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp)
2d3e977e 507{
e62afb5f 508 struct vop_old_rename_args ap;
cbe54d63 509 int error;
2d3e977e 510
e62afb5f 511 ap.a_head.a_desc = &vop_old_rename_desc;
0961aa92 512 ap.a_head.a_ops = ops;
2d3e977e 513 ap.a_fdvp = fdvp;
2d3e977e
MD
514 ap.a_fvp = fvp;
515 ap.a_fcnp = fcnp;
516 ap.a_tdvp = tdvp;
2d3e977e
MD
517 ap.a_tvp = tvp;
518 ap.a_tcnp = tcnp;
cbe54d63 519
e62afb5f 520 DO_OPS(ops, error, &ap, vop_old_rename);
cbe54d63 521 return(error);
2d3e977e
MD
522}
523
524int
e62afb5f 525vop_old_mkdir(struct vop_ops *ops, struct vnode *dvp,
0961aa92 526 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
2d3e977e 527{
e62afb5f 528 struct vop_old_mkdir_args ap;
cbe54d63 529 int error;
2d3e977e 530
e62afb5f 531 ap.a_head.a_desc = &vop_old_mkdir_desc;
0961aa92 532 ap.a_head.a_ops = ops;
2d3e977e 533 ap.a_dvp = dvp;
2d3e977e
MD
534 ap.a_vpp = vpp;
535 ap.a_cnp = cnp;
536 ap.a_vap = vap;
cbe54d63 537
e62afb5f 538 DO_OPS(ops, error, &ap, vop_old_mkdir);
cbe54d63 539 return(error);
2d3e977e
MD
540}
541
542int
e62afb5f 543vop_old_rmdir(struct vop_ops *ops, struct vnode *dvp,
0961aa92 544 struct vnode *vp, struct componentname *cnp)
2d3e977e 545{
e62afb5f 546 struct vop_old_rmdir_args ap;
cbe54d63 547 int error;
2d3e977e 548
e62afb5f 549 ap.a_head.a_desc = &vop_old_rmdir_desc;
0961aa92 550 ap.a_head.a_ops = ops;
2d3e977e 551 ap.a_dvp = dvp;
2d3e977e
MD
552 ap.a_vp = vp;
553 ap.a_cnp = cnp;
cbe54d63 554
e62afb5f 555 DO_OPS(ops, error, &ap, vop_old_rmdir);
cbe54d63 556 return(error);
2d3e977e
MD
557}
558
559int
e62afb5f 560vop_old_symlink(struct vop_ops *ops, struct vnode *dvp,
0961aa92
MD
561 struct vnode **vpp, struct componentname *cnp,
562 struct vattr *vap, char *target)
2d3e977e 563{
e62afb5f 564 struct vop_old_symlink_args ap;
cbe54d63 565 int error;
2d3e977e 566
e62afb5f 567 ap.a_head.a_desc = &vop_old_symlink_desc;
0961aa92 568 ap.a_head.a_ops = ops;
2d3e977e 569 ap.a_dvp = dvp;
2d3e977e
MD
570 ap.a_vpp = vpp;
571 ap.a_cnp = cnp;
572 ap.a_vap = vap;
573 ap.a_target = target;
cbe54d63 574
e62afb5f 575 DO_OPS(ops, error, &ap, vop_old_symlink);
cbe54d63 576 return(error);
2d3e977e
MD
577}
578
579int
0961aa92
MD
580vop_readdir(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
581 struct ucred *cred, int *eofflag, int *ncookies, u_long **cookies)
2d3e977e
MD
582{
583 struct vop_readdir_args ap;
cbe54d63 584 int error;
2d3e977e
MD
585
586 ap.a_head.a_desc = &vop_readdir_desc;
0961aa92 587 ap.a_head.a_ops = ops;
2d3e977e
MD
588 ap.a_vp = vp;
589 ap.a_uio = uio;
590 ap.a_cred = cred;
591 ap.a_eofflag = eofflag;
592 ap.a_ncookies = ncookies;
593 ap.a_cookies = cookies;
cbe54d63
MD
594
595 DO_OPS(ops, error, &ap, vop_readdir);
596 return(error);
2d3e977e
MD
597}
598
599int
0961aa92
MD
600vop_readlink(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
601 struct ucred *cred)
2d3e977e
MD
602{
603 struct vop_readlink_args ap;
cbe54d63 604 int error;
2d3e977e
MD
605
606 ap.a_head.a_desc = &vop_readlink_desc;
0961aa92 607 ap.a_head.a_ops = ops;
2d3e977e
MD
608 ap.a_vp = vp;
609 ap.a_uio = uio;
610 ap.a_cred = cred;
cbe54d63
MD
611
612 DO_OPS(ops, error, &ap, vop_readlink);
613 return(error);
2d3e977e
MD
614}
615
616int
87de5057 617vop_inactive(struct vop_ops *ops, struct vnode *vp)
2d3e977e
MD
618{
619 struct vop_inactive_args ap;
cbe54d63 620 int error;
2d3e977e
MD
621
622 ap.a_head.a_desc = &vop_inactive_desc;
0961aa92 623 ap.a_head.a_ops = ops;
2d3e977e 624 ap.a_vp = vp;
cbe54d63
MD
625
626 DO_OPS(ops, error, &ap, vop_inactive);
627 return(error);
2d3e977e
MD
628}
629
630int
87de5057 631vop_reclaim(struct vop_ops *ops, struct vnode *vp)
2d3e977e
MD
632{
633 struct vop_reclaim_args ap;
cbe54d63 634 int error;
2d3e977e
MD
635
636 ap.a_head.a_desc = &vop_reclaim_desc;
0961aa92 637 ap.a_head.a_ops = ops;
2d3e977e 638 ap.a_vp = vp;
cbe54d63
MD
639
640 DO_OPS(ops, error, &ap, vop_reclaim);
641 return(error);
2d3e977e
MD
642}
643
644int
ca466bae 645vop_lock(struct vop_ops *ops, struct vnode *vp, int flags)
2d3e977e
MD
646{
647 struct vop_lock_args ap;
cbe54d63 648 int error;
2d3e977e
MD
649
650 ap.a_head.a_desc = &vop_lock_desc;
0961aa92 651 ap.a_head.a_ops = ops;
2d3e977e 652 ap.a_vp = vp;
2d3e977e 653 ap.a_flags = flags;
cbe54d63
MD
654
655 DO_OPS(ops, error, &ap, vop_lock);
656 return(error);
2d3e977e
MD
657}
658
659int
ca466bae 660vop_unlock(struct vop_ops *ops, struct vnode *vp, int flags)
2d3e977e
MD
661{
662 struct vop_unlock_args ap;
cbe54d63 663 int error;
2d3e977e
MD
664
665 ap.a_head.a_desc = &vop_unlock_desc;
0961aa92 666 ap.a_head.a_ops = ops;
2d3e977e 667 ap.a_vp = vp;
2d3e977e 668 ap.a_flags = flags;
cbe54d63
MD
669
670 DO_OPS(ops, error, &ap, vop_unlock);
671 return(error);
2d3e977e
MD
672}
673
674int
54078292
MD
675vop_bmap(struct vop_ops *ops, struct vnode *vp, off_t loffset,
676 struct vnode **vpp, off_t *doffsetp, int *runp, int *runb)
2d3e977e
MD
677{
678 struct vop_bmap_args ap;
cbe54d63 679 int error;
2d3e977e
MD
680
681 ap.a_head.a_desc = &vop_bmap_desc;
0961aa92 682 ap.a_head.a_ops = ops;
2d3e977e 683 ap.a_vp = vp;
54078292 684 ap.a_loffset = loffset;
2d3e977e 685 ap.a_vpp = vpp;
54078292 686 ap.a_doffsetp = doffsetp;
2d3e977e
MD
687 ap.a_runp = runp;
688 ap.a_runb = runb;
cbe54d63
MD
689
690 DO_OPS(ops, error, &ap, vop_bmap);
691 return(error);
2d3e977e
MD
692}
693
694int
81b5c339 695vop_strategy(struct vop_ops *ops, struct vnode *vp, struct bio *bio)
2d3e977e
MD
696{
697 struct vop_strategy_args ap;
cbe54d63 698 int error;
2d3e977e
MD
699
700 ap.a_head.a_desc = &vop_strategy_desc;
0961aa92 701 ap.a_head.a_ops = ops;
2d3e977e 702 ap.a_vp = vp;
81b5c339 703 ap.a_bio = bio;
cbe54d63
MD
704
705 DO_OPS(ops, error, &ap, vop_strategy);
10f3fee5 706 if (error == 0 && bio->bio_buf->b_cmd != BUF_CMD_READ)
7d15906a 707 cache_update_fsmid_vp(vp);
cbe54d63 708 return(error);
2d3e977e
MD
709}
710
711int
0961aa92 712vop_print(struct vop_ops *ops, struct vnode *vp)
2d3e977e
MD
713{
714 struct vop_print_args ap;
cbe54d63 715 int error;
2d3e977e
MD
716
717 ap.a_head.a_desc = &vop_print_desc;
0961aa92 718 ap.a_head.a_ops = ops;
2d3e977e 719 ap.a_vp = vp;
cbe54d63
MD
720
721 DO_OPS(ops, error, &ap, vop_print);
722 return(error);
2d3e977e
MD
723}
724
725int
0961aa92
MD
726vop_pathconf(struct vop_ops *ops, struct vnode *vp, int name,
727 register_t *retval)
2d3e977e
MD
728{
729 struct vop_pathconf_args ap;
cbe54d63 730 int error;
2d3e977e
MD
731
732 ap.a_head.a_desc = &vop_pathconf_desc;
0961aa92 733 ap.a_head.a_ops = ops;
2d3e977e
MD
734 ap.a_vp = vp;
735 ap.a_name = name;
736 ap.a_retval = retval;
cbe54d63
MD
737
738 DO_OPS(ops, error, &ap, vop_pathconf);
739 return(error);
2d3e977e
MD
740}
741
742int
0961aa92
MD
743vop_advlock(struct vop_ops *ops, struct vnode *vp, caddr_t id, int op,
744 struct flock *fl, int flags)
2d3e977e
MD
745{
746 struct vop_advlock_args ap;
cbe54d63 747 int error;
2d3e977e
MD
748
749 ap.a_head.a_desc = &vop_advlock_desc;
0961aa92 750 ap.a_head.a_ops = ops;
2d3e977e
MD
751 ap.a_vp = vp;
752 ap.a_id = id;
753 ap.a_op = op;
754 ap.a_fl = fl;
755 ap.a_flags = flags;
cbe54d63
MD
756
757 DO_OPS(ops, error, &ap, vop_advlock);
758 return(error);
2d3e977e
MD
759}
760
761int
0961aa92
MD
762vop_balloc(struct vop_ops *ops, struct vnode *vp, off_t startoffset,
763 int size, struct ucred *cred, int flags,
764 struct buf **bpp)
2d3e977e
MD
765{
766 struct vop_balloc_args ap;
cbe54d63 767 int error;
2d3e977e
MD
768
769 ap.a_head.a_desc = &vop_balloc_desc;
0961aa92 770 ap.a_head.a_ops = ops;
2d3e977e
MD
771 ap.a_vp = vp;
772 ap.a_startoffset = startoffset;
773 ap.a_size = size;
774 ap.a_cred = cred;
775 ap.a_flags = flags;
776 ap.a_bpp = bpp;
cbe54d63
MD
777
778 DO_OPS(ops, error, &ap, vop_balloc);
779 return(error);
2d3e977e
MD
780}
781
782int
0961aa92
MD
783vop_reallocblks(struct vop_ops *ops, struct vnode *vp,
784 struct cluster_save *buflist)
2d3e977e
MD
785{
786 struct vop_reallocblks_args ap;
cbe54d63 787 int error;
2d3e977e
MD
788
789 ap.a_head.a_desc = &vop_reallocblks_desc;
0961aa92 790 ap.a_head.a_ops = ops;
2d3e977e
MD
791 ap.a_vp = vp;
792 ap.a_buflist = buflist;
cbe54d63
MD
793
794 DO_OPS(ops, error, &ap, vop_reallocblks);
795 return(error);
2d3e977e
MD
796}
797
798int
0961aa92
MD
799vop_getpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
800 int reqpage, vm_ooffset_t offset)
2d3e977e
MD
801{
802 struct vop_getpages_args ap;
cbe54d63 803 int error;
2d3e977e
MD
804
805 ap.a_head.a_desc = &vop_getpages_desc;
0961aa92 806 ap.a_head.a_ops = ops;
2d3e977e
MD
807 ap.a_vp = vp;
808 ap.a_m = m;
809 ap.a_count = count;
810 ap.a_reqpage = reqpage;
811 ap.a_offset = offset;
cbe54d63
MD
812
813 DO_OPS(ops, error, &ap, vop_getpages);
814 return(error);
2d3e977e
MD
815}
816
817int
0961aa92
MD
818vop_putpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
819 int sync, int *rtvals, vm_ooffset_t offset)
2d3e977e
MD
820{
821 struct vop_putpages_args ap;
cbe54d63 822 int error;
2d3e977e
MD
823
824 ap.a_head.a_desc = &vop_putpages_desc;
0961aa92 825 ap.a_head.a_ops = ops;
2d3e977e
MD
826 ap.a_vp = vp;
827 ap.a_m = m;
828 ap.a_count = count;
829 ap.a_sync = sync;
830 ap.a_rtvals = rtvals;
831 ap.a_offset = offset;
cbe54d63
MD
832
833 DO_OPS(ops, error, &ap, vop_putpages);
7d15906a
MD
834 if (error == 0)
835 cache_update_fsmid_vp(vp);
cbe54d63 836 return(error);
2d3e977e
MD
837}
838
839int
54078292 840vop_freeblks(struct vop_ops *ops, struct vnode *vp, off_t offset, int length)
2d3e977e
MD
841{
842 struct vop_freeblks_args ap;
cbe54d63 843 int error;
2d3e977e
MD
844
845 ap.a_head.a_desc = &vop_freeblks_desc;
0961aa92 846 ap.a_head.a_ops = ops;
2d3e977e 847 ap.a_vp = vp;
54078292 848 ap.a_offset = offset;
2d3e977e 849 ap.a_length = length;
cbe54d63
MD
850
851 DO_OPS(ops, error, &ap, vop_freeblks);
852 return(error);
2d3e977e
MD
853}
854
2d3e977e 855int
0961aa92 856vop_getacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
87de5057 857 struct acl *aclp, struct ucred *cred)
2d3e977e
MD
858{
859 struct vop_getacl_args ap;
cbe54d63 860 int error;
2d3e977e
MD
861
862 ap.a_head.a_desc = &vop_getacl_desc;
0961aa92 863 ap.a_head.a_ops = ops;
2d3e977e
MD
864 ap.a_vp = vp;
865 ap.a_type = type;
866 ap.a_aclp = aclp;
867 ap.a_cred = cred;
cbe54d63
MD
868
869 DO_OPS(ops, error, &ap, vop_getacl);
870 return(error);
2d3e977e
MD
871}
872
873int
0961aa92 874vop_setacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
87de5057 875 struct acl *aclp, struct ucred *cred)
2d3e977e
MD
876{
877 struct vop_setacl_args ap;
cbe54d63 878 int error;
2d3e977e
MD
879
880 ap.a_head.a_desc = &vop_setacl_desc;
0961aa92 881 ap.a_head.a_ops = ops;
2d3e977e
MD
882 ap.a_vp = vp;
883 ap.a_type = type;
884 ap.a_aclp = aclp;
885 ap.a_cred = cred;
cbe54d63
MD
886
887 DO_OPS(ops, error, &ap, vop_setacl);
7d15906a
MD
888 if (error == 0)
889 cache_update_fsmid_vp(vp);
cbe54d63 890 return(error);
2d3e977e
MD
891}
892
893int
0961aa92 894vop_aclcheck(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
87de5057 895 struct acl *aclp, struct ucred *cred)
2d3e977e
MD
896{
897 struct vop_aclcheck_args ap;
cbe54d63 898 int error;
2d3e977e
MD
899
900 ap.a_head.a_desc = &vop_aclcheck_desc;
0961aa92 901 ap.a_head.a_ops = ops;
2d3e977e
MD
902 ap.a_vp = vp;
903 ap.a_type = type;
904 ap.a_aclp = aclp;
905 ap.a_cred = cred;
cbe54d63
MD
906
907 DO_OPS(ops, error, &ap, vop_aclcheck);
908 return(error);
2d3e977e
MD
909}
910
911int
0961aa92 912vop_getextattr(struct vop_ops *ops, struct vnode *vp, char *name,
87de5057 913 struct uio *uio, struct ucred *cred)
2d3e977e
MD
914{
915 struct vop_getextattr_args ap;
cbe54d63 916 int error;
2d3e977e
MD
917
918 ap.a_head.a_desc = &vop_getextattr_desc;
0961aa92 919 ap.a_head.a_ops = ops;
2d3e977e
MD
920 ap.a_vp = vp;
921 ap.a_name = name;
922 ap.a_uio = uio;
923 ap.a_cred = cred;
cbe54d63
MD
924
925 DO_OPS(ops, error, &ap, vop_getextattr);
926 return(error);
2d3e977e
MD
927}
928
929int
0961aa92 930vop_setextattr(struct vop_ops *ops, struct vnode *vp, char *name,
87de5057 931 struct uio *uio, struct ucred *cred)
2d3e977e
MD
932{
933 struct vop_setextattr_args ap;
cbe54d63 934 int error;
2d3e977e
MD
935
936 ap.a_head.a_desc = &vop_setextattr_desc;
0961aa92 937 ap.a_head.a_ops = ops;
2d3e977e
MD
938 ap.a_vp = vp;
939 ap.a_name = name;
940 ap.a_uio = uio;
941 ap.a_cred = cred;
cbe54d63
MD
942
943 DO_OPS(ops, error, &ap, vop_setextattr);
7d15906a
MD
944 if (error == 0)
945 cache_update_fsmid_vp(vp);
cbe54d63 946 return(error);
2d3e977e
MD
947}
948
cbe54d63 949int
2281065e
MD
950vop_mountctl(struct vop_ops *ops, int op, struct file *fp,
951 const void *ctl, int ctllen, void *buf, int buflen, int *res)
cbe54d63 952{
949ecb9b 953 struct vop_mountctl_args ap;
cbe54d63
MD
954 int error;
955
949ecb9b 956 ap.a_head.a_desc = &vop_mountctl_desc;
cbe54d63
MD
957 ap.a_head.a_ops = ops;
958 ap.a_op = op;
949ecb9b 959 ap.a_ctl = ctl;
2281065e 960 ap.a_fp = fp;
949ecb9b
MD
961 ap.a_ctllen = ctllen;
962 ap.a_buf = buf;
963 ap.a_buflen = buflen;
964 ap.a_res = res;
cbe54d63 965
949ecb9b 966 DO_OPS(ops, error, &ap, vop_mountctl);
cbe54d63 967 return(error);
0961aa92
MD
968}
969
fad57d0e
MD
970/*
971 * NEW API FUNCTIONS
972 *
973 * nresolve takes a locked ncp and a cred and resolves the ncp into a
974 * positive or negative hit.
975 *
976 * The namecache is automatically adjusted by this function. The ncp
977 * is left locked on return.
978 */
979int
980vop_nresolve(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
981{
982 struct vop_nresolve_args ap;
983 int error;
984
985 ap.a_head.a_desc = &vop_nresolve_desc;
986 ap.a_head.a_ops = ops;
987 ap.a_ncp = ncp;
988 ap.a_cred = cred;
989
990 DO_OPS(ops, error, &ap, vop_nresolve);
991 return(error);
992}
993
994/*
995 * nlookupdotdot takes an unlocked directory, dvp, and looks up "..", returning
996 * a locked parent directory in *vpp. If an error occurs *vpp will be NULL.
997 */
998int
999vop_nlookupdotdot(struct vop_ops *ops, struct vnode *dvp,
1000 struct vnode **vpp, struct ucred *cred)
1001{
1002 struct vop_nlookupdotdot_args ap;
1003 int error;
1004
1005 ap.a_head.a_desc = &vop_nlookupdotdot_desc;
1006 ap.a_head.a_ops = ops;
1007 ap.a_dvp = dvp;
1008 ap.a_vpp = vpp;
1009 ap.a_cred = cred;
1010
1011 DO_OPS(ops, error, &ap, vop_nlookupdotdot);
1012 return(error);
1013}
1014
1015/*
1016 * ncreate takes a locked, resolved ncp that typically represents a negative
1017 * cache hit and creates the file or node specified by the ncp, cred, and
1018 * vattr. If no error occurs a locked vnode is returned in *vpp.
1019 *
1020 * The namecache is automatically adjusted by this function. The ncp
1021 * is left locked on return.
1022 */
1023int
1024vop_ncreate(struct vop_ops *ops, struct namecache *ncp,
1025 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1026{
1027 struct vop_ncreate_args ap;
1028 int error;
1029
1030 ap.a_head.a_desc = &vop_ncreate_desc;
1031 ap.a_head.a_ops = ops;
1032 ap.a_ncp = ncp;
1033 ap.a_vpp = vpp;
1034 ap.a_cred = cred;
1035 ap.a_vap = vap;
1036
1037 DO_OPS(ops, error, &ap, vop_ncreate);
7d15906a
MD
1038 if (error == 0 && *vpp)
1039 cache_update_fsmid_vp(*vpp);
fad57d0e
MD
1040 return(error);
1041}
1042
1043/*
1044 * nmkdir takes a locked, resolved ncp that typically represents a negative
1045 * cache hit and creates the directory specified by the ncp, cred, and
1046 * vattr. If no error occurs a locked vnode is returned in *vpp.
1047 *
1048 * The namecache is automatically adjusted by this function. The ncp
1049 * is left locked on return.
1050 */
1051int
1052vop_nmkdir(struct vop_ops *ops, struct namecache *ncp,
1053 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1054{
1055 struct vop_nmkdir_args ap;
1056 int error;
1057
1058 ap.a_head.a_desc = &vop_nmkdir_desc;
1059 ap.a_head.a_ops = ops;
1060 ap.a_ncp = ncp;
1061 ap.a_vpp = vpp;
1062 ap.a_cred = cred;
1063 ap.a_vap = vap;
1064
1065 DO_OPS(ops, error, &ap, vop_nmkdir);
7d15906a
MD
1066 if (error == 0 && *vpp)
1067 cache_update_fsmid_vp(*vpp);
fad57d0e
MD
1068 return(error);
1069}
1070
1071/*
1072 * nmknod takes a locked, resolved ncp that typically represents a negative
1073 * cache hit and creates the node specified by the ncp, cred, and
1074 * vattr. If no error occurs a locked vnode is returned in *vpp.
1075 *
1076 * The namecache is automatically adjusted by this function. The ncp
1077 * is left locked on return.
1078 */
1079int
1080vop_nmknod(struct vop_ops *ops, struct namecache *ncp,
1081 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1082{
1083 struct vop_nmknod_args ap;
1084 int error;
1085
1086 ap.a_head.a_desc = &vop_nmknod_desc;
1087 ap.a_head.a_ops = ops;
1088 ap.a_ncp = ncp;
1089 ap.a_vpp = vpp;
1090 ap.a_cred = cred;
1091 ap.a_vap = vap;
1092
1093 DO_OPS(ops, error, &ap, vop_nmknod);
7d15906a
MD
1094 if (error == 0 && *vpp)
1095 cache_update_fsmid_vp(*vpp);
fad57d0e
MD
1096 return(error);
1097}
1098
1099/*
1100 * nlink takes a locked, resolved ncp that typically represents a negative
1101 * cache hit and creates the node specified by the ncp, cred, and
1102 * existing vnode. The passed vp must be locked and will remain locked
1103 * on return, as does the ncp, whether an error occurs or not.
1104 *
1105 * The namecache is automatically adjusted by this function. The ncp
1106 * is left locked on return.
1107 */
1108int
1109vop_nlink(struct vop_ops *ops, struct namecache *ncp,
1110 struct vnode *vp, struct ucred *cred)
1111{
1112 struct vop_nlink_args ap;
1113 int error;
1114
1115 ap.a_head.a_desc = &vop_nlink_desc;
1116 ap.a_head.a_ops = ops;
1117 ap.a_ncp = ncp;
1118 ap.a_vp = vp;
1119 ap.a_cred = cred;
1120
1121 DO_OPS(ops, error, &ap, vop_nlink);
7d15906a
MD
1122 if (error == 0)
1123 cache_update_fsmid(ncp);
fad57d0e
MD
1124 return(error);
1125}
1126
1127/*
1128 * nsymlink takes a locked, resolved ncp that typically represents a negative
1129 * cache hit and creates a symbolic link based on cred, vap, and target (the
1130 * contents of the link). If no error occurs a locked vnode is returned in
1131 * *vpp.
1132 *
1133 * The namecache is automatically adjusted by this function. The ncp
1134 * is left locked on return.
1135 */
1136int
1137vop_nsymlink(struct vop_ops *ops, struct namecache *ncp,
1138 struct vnode **vpp, struct ucred *cred,
1139 struct vattr *vap, char *target)
1140{
1141 struct vop_nsymlink_args ap;
1142 int error;
1143
1144 ap.a_head.a_desc = &vop_nsymlink_desc;
1145 ap.a_head.a_ops = ops;
1146 ap.a_ncp = ncp;
1147 ap.a_vpp = vpp;
1148 ap.a_cred = cred;
1149 ap.a_vap = vap;
1150 ap.a_target = target;
1151
1152 DO_OPS(ops, error, &ap, vop_nsymlink);
7d15906a
MD
1153 if (error == 0)
1154 cache_update_fsmid(ncp);
fad57d0e
MD
1155 return(error);
1156}
1157
1158/*
1159 * nwhiteout takes a locked, resolved ncp that can represent a positive or
1160 * negative hit and executes the whiteout function specified in flags.
1161 *
1162 * The namecache is automatically adjusted by this function. The ncp
1163 * is left locked on return.
1164 */
1165int
1166vop_nwhiteout(struct vop_ops *ops, struct namecache *ncp,
1167 struct ucred *cred, int flags)
1168{
1169 struct vop_nwhiteout_args ap;
1170 int error;
1171
1172 ap.a_head.a_desc = &vop_nwhiteout_desc;
1173 ap.a_head.a_ops = ops;
1174 ap.a_ncp = ncp;
1175 ap.a_cred = cred;
1176 ap.a_flags = flags;
1177
1178 DO_OPS(ops, error, &ap, vop_nwhiteout);
7d15906a
MD
1179 if (error == 0)
1180 cache_update_fsmid(ncp);
fad57d0e
MD
1181 return(error);
1182}
1183
1184/*
1185 * nremove takes a locked, resolved ncp that generally represents a
1186 * positive hit and removes the file.
1187 *
1188 * The namecache is automatically adjusted by this function. The ncp
1189 * is left locked on return.
1190 */
1191int
1192vop_nremove(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1193{
1194 struct vop_nremove_args ap;
1195 int error;
1196
1197 ap.a_head.a_desc = &vop_nremove_desc;
1198 ap.a_head.a_ops = ops;
1199 ap.a_ncp = ncp;
1200 ap.a_cred = cred;
1201
1202 DO_OPS(ops, error, &ap, vop_nremove);
7d15906a
MD
1203 if (error == 0)
1204 cache_update_fsmid(ncp);
fad57d0e
MD
1205 return(error);
1206}
1207
1208/*
1209 * nrmdir takes a locked, resolved ncp that generally represents a
1210 * directory and removes the directory.
1211 *
1212 * The namecache is automatically adjusted by this function. The ncp
1213 * is left locked on return.
1214 */
1215int
1216vop_nrmdir(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1217{
1218 struct vop_nrmdir_args ap;
1219 int error;
1220
1221 ap.a_head.a_desc = &vop_nrmdir_desc;
1222 ap.a_head.a_ops = ops;
1223 ap.a_ncp = ncp;
1224 ap.a_cred = cred;
1225
1226 DO_OPS(ops, error, &ap, vop_nrmdir);
7d15906a
MD
1227 if (error == 0)
1228 cache_update_fsmid(ncp);
fad57d0e
MD
1229 return(error);
1230}
1231
1232/*
1233 * nrename takes TWO locked, resolved ncp's and the cred of the caller
1234 * and renames the source ncp to the target ncp. The target ncp may
1235 * represent a positive or negative hit.
1236 *
1237 * The namecache is automatically adjusted by this function. The ncp
1238 * is left locked on return. The source ncp is typically changed to
1239 * a negative cache hit and the target ncp typically takes on the
1240 * source ncp's underlying file.
1241 */
1242int
1243vop_nrename(struct vop_ops *ops, struct namecache *fncp,
1244 struct namecache *tncp, struct ucred *cred)
1245{
1246 struct vop_nrename_args ap;
1247 int error;
1248
1249 ap.a_head.a_desc = &vop_nrename_desc;
1250 ap.a_head.a_ops = ops;
1251 ap.a_fncp = fncp;
1252 ap.a_tncp = tncp;
1253 ap.a_cred = cred;
1254
1255 DO_OPS(ops, error, &ap, vop_nrename);
7d15906a
MD
1256 if (error == 0) {
1257 cache_update_fsmid(fncp);
1258 cache_update_fsmid(tncp);
1259 }
fad57d0e
MD
1260 return(error);
1261}
1262
0961aa92
MD
1263/************************************************************************
1264 * PRIMARY VNODE OPERATIONS FORWARDING CALLS *
1265 ************************************************************************
1266 *
1267 * These procedures are called from VFSs such as unionfs and nullfs
1268 * when they wish to forward an operation on one VFS to another. The
1269 * argument structure/message is modified and then directly passed to the
1270 * appropriate routine. This routines may also be called by initiators
1271 * who have an argument structure in hand rather then discreet arguments.
1272 */
1273int
1274vop_vnoperate_ap(struct vop_generic_args *ap)
1275{
cbe54d63
MD
1276 struct vop_ops *ops;
1277 int error;
1278
1279 ops = ap->a_ops;
6ddb7618
MD
1280 error = VOCALL(ops, ap);
1281
1282 return (error);
1283}
1284
1285/*
1286 * This routine is called by the cache coherency layer to execute the actual
1287 * VFS operation. If a journaling layer is present we call though it, else
1288 * we call the native VOP functions.
1289 */
1290int
1291vop_cache_operate_ap(struct vop_generic_args *ap)
1292{
1293 struct vop_ops *ops;
1294 int error;
1295
1296 ops = ap->a_ops;
66a1ddf5
MD
1297 if (ops->head.vv_mount->mnt_vn_journal_ops)
1298 error = VOCALL(ops->head.vv_mount->mnt_vn_journal_ops, ap);
6ddb7618 1299 else
66a1ddf5 1300 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
6ddb7618
MD
1301 return (error);
1302}
1303
1304
1305/*
1306 * This routine is called by the journaling layer to execute the actual
1307 * VFS operation.
1308 */
1309int
1310vop_journal_operate_ap(struct vop_generic_args *ap)
1311{
1312 struct vop_ops *ops;
1313 int error;
1314
1315 ops = ap->a_ops;
66a1ddf5 1316 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
6ddb7618 1317
cbe54d63 1318 return (error);
0961aa92
MD
1319}
1320
1321int
1322vop_islocked_ap(struct vop_islocked_args *ap)
1323{
cbe54d63
MD
1324 int error;
1325
1326 DO_OPS(ap->a_head.a_ops, error, ap, vop_islocked);
1327 return(error);
0961aa92
MD
1328}
1329
0961aa92
MD
1330int
1331vop_open_ap(struct vop_open_args *ap)
1332{
cbe54d63
MD
1333 int error;
1334
1335 DO_OPS(ap->a_head.a_ops, error, ap, vop_open);
1336 return(error);
0961aa92
MD
1337}
1338
1339int
1340vop_close_ap(struct vop_close_args *ap)
1341{
cbe54d63
MD
1342 int error;
1343
1344 DO_OPS(ap->a_head.a_ops, error, ap, vop_close);
1345 return(error);
0961aa92
MD
1346}
1347
1348int
1349vop_access_ap(struct vop_access_args *ap)
1350{
cbe54d63
MD
1351 int error;
1352
1353 DO_OPS(ap->a_head.a_ops, error, ap, vop_access);
1354 return(error);
0961aa92
MD
1355}
1356
1357int
1358vop_getattr_ap(struct vop_getattr_args *ap)
1359{
cbe54d63
MD
1360 int error;
1361
1362 DO_OPS(ap->a_head.a_ops, error, ap, vop_getattr);
1363 return(error);
0961aa92
MD
1364}
1365
1366int
1367vop_setattr_ap(struct vop_setattr_args *ap)
1368{
cbe54d63
MD
1369 int error;
1370
1371 DO_OPS(ap->a_head.a_ops, error, ap, vop_setattr);
1372 return(error);
0961aa92
MD
1373}
1374
1375int
1376vop_read_ap(struct vop_read_args *ap)
1377{
cbe54d63
MD
1378 int error;
1379
1380 DO_OPS(ap->a_head.a_ops, error, ap, vop_read);
1381 return(error);
0961aa92
MD
1382}
1383
1384int
1385vop_write_ap(struct vop_write_args *ap)
1386{
cbe54d63
MD
1387 int error;
1388
1389 DO_OPS(ap->a_head.a_ops, error, ap, vop_write);
1390 return(error);
0961aa92
MD
1391}
1392
0961aa92
MD
1393int
1394vop_ioctl_ap(struct vop_ioctl_args *ap)
1395{
cbe54d63
MD
1396 int error;
1397
1398 DO_OPS(ap->a_head.a_ops, error, ap, vop_ioctl);
1399 return(error);
0961aa92
MD
1400}
1401
1402int
1403vop_poll_ap(struct vop_poll_args *ap)
1404{
cbe54d63
MD
1405 int error;
1406
1407 DO_OPS(ap->a_head.a_ops, error, ap, vop_poll);
1408 return(error);
0961aa92
MD
1409}
1410
1411int
1412vop_kqfilter_ap(struct vop_kqfilter_args *ap)
1413{
cbe54d63
MD
1414 int error;
1415
1416 DO_OPS(ap->a_head.a_ops, error, ap, vop_kqfilter);
1417 return(error);
0961aa92
MD
1418}
1419
1420int
1421vop_revoke_ap(struct vop_revoke_args *ap)
1422{
cbe54d63
MD
1423 int error;
1424
1425 DO_OPS(ap->a_head.a_ops, error, ap, vop_revoke);
1426 return(error);
0961aa92
MD
1427}
1428
1429int
1430vop_mmap_ap(struct vop_mmap_args *ap)
1431{
cbe54d63
MD
1432 int error;
1433
1434 DO_OPS(ap->a_head.a_ops, error, ap, vop_mmap);
1435 return(error);
0961aa92
MD
1436}
1437
1438int
1439vop_fsync_ap(struct vop_fsync_args *ap)
1440{
cbe54d63
MD
1441 int error;
1442
1443 DO_OPS(ap->a_head.a_ops, error, ap, vop_fsync);
1444 return(error);
0961aa92
MD
1445}
1446
0961aa92
MD
1447int
1448vop_readdir_ap(struct vop_readdir_args *ap)
1449{
cbe54d63
MD
1450 int error;
1451
1452 DO_OPS(ap->a_head.a_ops, error, ap, vop_readdir);
1453 return(error);
0961aa92
MD
1454}
1455
1456int
1457vop_readlink_ap(struct vop_readlink_args *ap)
1458{
cbe54d63
MD
1459 int error;
1460
1461 DO_OPS(ap->a_head.a_ops, error, ap, vop_readlink);
1462 return(error);
0961aa92
MD
1463}
1464
1465int
1466vop_inactive_ap(struct vop_inactive_args *ap)
1467{
cbe54d63
MD
1468 int error;
1469
1470 DO_OPS(ap->a_head.a_ops, error, ap, vop_inactive);
1471 return(error);
0961aa92
MD
1472}
1473
1474int
1475vop_reclaim_ap(struct vop_reclaim_args *ap)
1476{
cbe54d63
MD
1477 int error;
1478
1479 DO_OPS(ap->a_head.a_ops, error, ap, vop_reclaim);
1480 return(error);
0961aa92
MD
1481}
1482
1483int
1484vop_lock_ap(struct vop_lock_args *ap)
1485{
cbe54d63
MD
1486 int error;
1487
1488 DO_OPS(ap->a_head.a_ops, error, ap, vop_lock);
1489 return(error);
0961aa92
MD
1490}
1491
1492int
1493vop_unlock_ap(struct vop_unlock_args *ap)
1494{
cbe54d63
MD
1495 int error;
1496
1497 DO_OPS(ap->a_head.a_ops, error, ap, vop_unlock);
1498 return(error);
0961aa92
MD
1499}
1500
1501int
1502vop_bmap_ap(struct vop_bmap_args *ap)
1503{
cbe54d63
MD
1504 int error;
1505
1506 DO_OPS(ap->a_head.a_ops, error, ap, vop_bmap);
1507 return(error);
0961aa92
MD
1508}
1509
1510int
1511vop_strategy_ap(struct vop_strategy_args *ap)
1512{
cbe54d63
MD
1513 int error;
1514
1515 DO_OPS(ap->a_head.a_ops, error, ap, vop_strategy);
1516 return(error);
0961aa92
MD
1517}
1518
1519int
1520vop_print_ap(struct vop_print_args *ap)
1521{
cbe54d63
MD
1522 int error;
1523
1524 DO_OPS(ap->a_head.a_ops, error, ap, vop_print);
1525 return(error);
0961aa92
MD
1526}
1527
1528int
1529vop_pathconf_ap(struct vop_pathconf_args *ap)
1530{
cbe54d63
MD
1531 int error;
1532
1533 DO_OPS(ap->a_head.a_ops, error, ap, vop_pathconf);
1534 return(error);
0961aa92
MD
1535}
1536
1537int
1538vop_advlock_ap(struct vop_advlock_args *ap)
1539{
cbe54d63
MD
1540 int error;
1541
1542 DO_OPS(ap->a_head.a_ops, error, ap, vop_advlock);
1543 return(error);
0961aa92
MD
1544}
1545
1546int
1547vop_balloc_ap(struct vop_balloc_args *ap)
1548{
cbe54d63
MD
1549 int error;
1550
1551 DO_OPS(ap->a_head.a_ops, error, ap, vop_balloc);
1552 return(error);
0961aa92
MD
1553}
1554
1555int
1556vop_reallocblks_ap(struct vop_reallocblks_args *ap)
1557{
cbe54d63
MD
1558 int error;
1559
1560 DO_OPS(ap->a_head.a_ops, error, ap, vop_reallocblks);
1561 return(error);
0961aa92
MD
1562}
1563
1564int
1565vop_getpages_ap(struct vop_getpages_args *ap)
1566{
cbe54d63
MD
1567 int error;
1568
1569 DO_OPS(ap->a_head.a_ops, error, ap, vop_getpages);
1570 return(error);
0961aa92
MD
1571}
1572
1573int
1574vop_putpages_ap(struct vop_putpages_args *ap)
1575{
cbe54d63
MD
1576 int error;
1577
1578 DO_OPS(ap->a_head.a_ops, error, ap, vop_putpages);
1579 return(error);
0961aa92
MD
1580}
1581
1582int
1583vop_freeblks_ap(struct vop_freeblks_args *ap)
1584{
cbe54d63
MD
1585 int error;
1586
1587 DO_OPS(ap->a_head.a_ops, error, ap, vop_freeblks);
1588 return(error);
0961aa92
MD
1589}
1590
0961aa92
MD
1591int
1592vop_getacl_ap(struct vop_getacl_args *ap)
1593{
cbe54d63
MD
1594 int error;
1595
1596 DO_OPS(ap->a_head.a_ops, error, ap, vop_getacl);
1597 return(error);
0961aa92
MD
1598}
1599
1600int
1601vop_setacl_ap(struct vop_setacl_args *ap)
1602{
cbe54d63
MD
1603 int error;
1604
1605 DO_OPS(ap->a_head.a_ops, error, ap, vop_setacl);
1606 return(error);
0961aa92
MD
1607}
1608
1609int
1610vop_aclcheck_ap(struct vop_aclcheck_args *ap)
1611{
cbe54d63
MD
1612 int error;
1613
1614 DO_OPS(ap->a_head.a_ops, error, ap, vop_aclcheck);
1615 return(error);
0961aa92
MD
1616}
1617
1618int
1619vop_getextattr_ap(struct vop_getextattr_args *ap)
1620{
cbe54d63
MD
1621 int error;
1622
1623 DO_OPS(ap->a_head.a_ops, error, ap, vop_getextattr);
1624 return(error);
0961aa92
MD
1625}
1626
1627int
1628vop_setextattr_ap(struct vop_setextattr_args *ap)
1629{
cbe54d63
MD
1630 int error;
1631
1632 DO_OPS(ap->a_head.a_ops, error, ap, vop_setextattr);
1633 return(error);
0961aa92
MD
1634}
1635
cbe54d63 1636int
949ecb9b 1637vop_mountctl_ap(struct vop_mountctl_args *ap)
cbe54d63
MD
1638{
1639 int error;
1640
949ecb9b 1641 DO_OPS(ap->a_head.a_ops, error, ap, vop_mountctl);
cbe54d63 1642 return(error);
2d3e977e
MD
1643}
1644
fad57d0e
MD
1645int
1646vop_nresolve_ap(struct vop_nresolve_args *ap)
1647{
1648 int error;
1649
1650 DO_OPS(ap->a_head.a_ops, error, ap, vop_nresolve);
1651 return(error);
1652}
1653
1654int
1655vop_nlookupdotdot_ap(struct vop_nlookupdotdot_args *ap)
1656{
1657 int error;
1658
1659 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlookupdotdot);
1660 return(error);
1661}
1662
1663int
1664vop_ncreate_ap(struct vop_ncreate_args *ap)
1665{
1666 int error;
1667
1668 DO_OPS(ap->a_head.a_ops, error, ap, vop_ncreate);
1669 return(error);
1670}
1671
1672int
1673vop_nmkdir_ap(struct vop_nmkdir_args *ap)
1674{
1675 int error;
1676
1677 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmkdir);
1678 return(error);
1679}
1680
1681int
1682vop_nmknod_ap(struct vop_nmknod_args *ap)
1683{
1684 int error;
1685
1686 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmknod);
1687 return(error);
1688}
1689
1690int
1691vop_nlink_ap(struct vop_nlink_args *ap)
1692{
1693 int error;
1694
1695 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlink);
1696 return(error);
1697}
1698
1699int
1700vop_nsymlink_ap(struct vop_nsymlink_args *ap)
1701{
1702 int error;
1703
1704 DO_OPS(ap->a_head.a_ops, error, ap, vop_nsymlink);
1705 return(error);
1706}
1707
1708int
1709vop_nwhiteout_ap(struct vop_nwhiteout_args *ap)
1710{
1711 int error;
1712
1713 DO_OPS(ap->a_head.a_ops, error, ap, vop_nwhiteout);
1714 return(error);
1715}
1716
1717int
1718vop_nremove_ap(struct vop_nremove_args *ap)
1719{
1720 int error;
1721
1722 DO_OPS(ap->a_head.a_ops, error, ap, vop_nremove);
1723 return(error);
1724}
1725
1726int
1727vop_nrmdir_ap(struct vop_nrmdir_args *ap)
1728{
1729 int error;
1730
1731 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrmdir);
1732 return(error);
1733}
1734
1735int
1736vop_nrename_ap(struct vop_nrename_args *ap)
1737{
1738 int error;
1739
1740 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrename);
1741 return(error);
1742}
1743