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