xref: /original-bsd/sys/ufs/lfs/lfs_vnops.c (revision bdfadfff)
1 /*
2  * Copyright (c) 1986, 1989, 1991 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)lfs_vnops.c	7.86 (Berkeley) 07/05/92
8  */
9 
10 #include <sys/param.h>
11 #include <sys/systm.h>
12 #include <sys/namei.h>
13 #include <sys/resourcevar.h>
14 #include <sys/kernel.h>
15 #include <sys/file.h>
16 #include <sys/stat.h>
17 #include <sys/buf.h>
18 #include <sys/proc.h>
19 #include <sys/conf.h>
20 #include <sys/mount.h>
21 #include <sys/vnode.h>
22 #include <sys/specdev.h>
23 #include <sys/fifo.h>
24 #include <sys/malloc.h>
25 
26 #include <vm/vm.h>
27 
28 #include <ufs/ufs/quota.h>
29 #include <ufs/ufs/inode.h>
30 #include <ufs/ufs/dir.h>
31 #include <ufs/ufs/ufs_extern.h>
32 
33 #include <ufs/lfs/lfs.h>
34 #include <ufs/lfs/lfs_extern.h>
35 
36 /* Global vfs data structures for lfs. */
37 int (**lfs_vnodeop_p)();
38 struct vnodeopv_entry_desc lfs_vnodeop_entries[] = {
39 	{ &vop_default_desc, vn_default_error },
40 	{ &vop_lookup_desc, ufs_lookup },		/* lookup */
41 	{ &vop_create_desc, lfs_create },		/* create */
42 	{ &vop_mknod_desc, lfs_mknod },			/* mknod */
43 	{ &vop_open_desc, ufs_open },			/* open */
44 	{ &vop_close_desc, ufs_close },			/* close */
45 	{ &vop_access_desc, ufs_access },		/* access */
46 	{ &vop_getattr_desc, ufs_getattr },		/* getattr */
47 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
48 	{ &vop_read_desc, lfs_read },			/* read */
49 	{ &vop_write_desc, lfs_write },			/* write */
50 	{ &vop_ioctl_desc, ufs_ioctl },			/* ioctl */
51 	{ &vop_select_desc, ufs_select },		/* select */
52 	{ &vop_mmap_desc, ufs_mmap },			/* mmap */
53 	{ &vop_fsync_desc, lfs_fsync },			/* fsync */
54 	{ &vop_seek_desc, ufs_seek },			/* seek */
55 	{ &vop_remove_desc, lfs_remove },		/* remove */
56 	{ &vop_link_desc, lfs_link },			/* link */
57 	{ &vop_rename_desc, lfs_rename },		/* rename */
58 	{ &vop_mkdir_desc, lfs_mkdir },			/* mkdir */
59 	{ &vop_rmdir_desc, lfs_rmdir },			/* rmdir */
60 	{ &vop_symlink_desc, lfs_symlink },		/* symlink */
61 	{ &vop_readdir_desc, ufs_readdir },		/* readdir */
62 	{ &vop_readlink_desc, ufs_readlink },		/* readlink */
63 	{ &vop_abortop_desc, ufs_abortop },		/* abortop */
64 	{ &vop_inactive_desc, lfs_inactive },		/* inactive */
65 	{ &vop_reclaim_desc, ufs_reclaim },		/* reclaim */
66 	{ &vop_lock_desc, ufs_lock },			/* lock */
67 	{ &vop_unlock_desc, ufs_unlock },		/* unlock */
68 	{ &vop_bmap_desc, lfs_bmap },			/* bmap */
69 	{ &vop_strategy_desc, ufs_strategy },		/* strategy */
70 	{ &vop_print_desc, ufs_print },			/* print */
71 	{ &vop_islocked_desc, ufs_islocked },		/* islocked */
72 	{ &vop_advlock_desc, ufs_advlock },		/* advlock */
73 	{ &vop_blkatoff_desc, lfs_blkatoff },		/* blkatoff */
74 	{ &vop_valloc_desc, lfs_valloc },		/* valloc */
75 	{ &vop_vfree_desc, lfs_vfree },			/* vfree */
76 	{ &vop_truncate_desc, lfs_truncate },		/* truncate */
77 	{ &vop_update_desc, lfs_update },		/* update */
78 	{ &vop_bwrite_desc, lfs_bwrite },		/* bwrite */
79 	{ (struct vnodeop_desc*)NULL, (int(*)())NULL }
80 };
81 struct vnodeopv_desc lfs_vnodeop_opv_desc =
82 	{ &lfs_vnodeop_p, lfs_vnodeop_entries };
83 
84 int (**lfs_specop_p)();
85 struct vnodeopv_entry_desc lfs_specop_entries[] = {
86 	{ &vop_default_desc, vn_default_error },
87 	{ &vop_lookup_desc, spec_lookup },		/* lookup */
88 	{ &vop_create_desc, spec_create },		/* create */
89 	{ &vop_mknod_desc, spec_mknod },		/* mknod */
90 	{ &vop_open_desc, spec_open },			/* open */
91 	{ &vop_close_desc, ufsspec_close },		/* close */
92 	{ &vop_access_desc, ufs_access },		/* access */
93 	{ &vop_getattr_desc, ufs_getattr },		/* getattr */
94 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
95 	{ &vop_read_desc, ufsspec_read },		/* read */
96 	{ &vop_write_desc, ufsspec_write },		/* write */
97 	{ &vop_ioctl_desc, spec_ioctl },		/* ioctl */
98 	{ &vop_select_desc, spec_select },		/* select */
99 	{ &vop_mmap_desc, spec_mmap },			/* mmap */
100 	{ &vop_fsync_desc, spec_fsync },		/* fsync */
101 	{ &vop_seek_desc, spec_seek },			/* seek */
102 	{ &vop_remove_desc, spec_remove },		/* remove */
103 	{ &vop_link_desc, spec_link },			/* link */
104 	{ &vop_rename_desc, spec_rename },		/* rename */
105 	{ &vop_mkdir_desc, spec_mkdir },		/* mkdir */
106 	{ &vop_rmdir_desc, spec_rmdir },		/* rmdir */
107 	{ &vop_symlink_desc, spec_symlink },		/* symlink */
108 	{ &vop_readdir_desc, spec_readdir },		/* readdir */
109 	{ &vop_readlink_desc, spec_readlink },		/* readlink */
110 	{ &vop_abortop_desc, spec_abortop },		/* abortop */
111 	{ &vop_inactive_desc, lfs_inactive },		/* inactive */
112 	{ &vop_reclaim_desc, ufs_reclaim },		/* reclaim */
113 	{ &vop_lock_desc, ufs_lock },			/* lock */
114 	{ &vop_unlock_desc, ufs_unlock },		/* unlock */
115 	{ &vop_bmap_desc, spec_bmap },			/* bmap */
116 	{ &vop_strategy_desc, spec_strategy },		/* strategy */
117 	{ &vop_print_desc, ufs_print },			/* print */
118 	{ &vop_islocked_desc, ufs_islocked },		/* islocked */
119 	{ &vop_advlock_desc, spec_advlock },		/* advlock */
120 	{ &vop_blkatoff_desc, spec_blkatoff },		/* blkatoff */
121 	{ &vop_valloc_desc, spec_valloc },		/* valloc */
122 	{ &vop_vfree_desc, lfs_vfree },			/* vfree */
123 	{ &vop_truncate_desc, spec_truncate },		/* truncate */
124 	{ &vop_update_desc, lfs_update },		/* update */
125 	{ &vop_bwrite_desc, lfs_bwrite },		/* bwrite */
126 	{ (struct vnodeop_desc*)NULL, (int(*)())NULL }
127 };
128 struct vnodeopv_desc lfs_specop_opv_desc =
129 	{ &lfs_specop_p, lfs_specop_entries };
130 
131 #ifdef FIFO
132 int (**lfs_fifoop_p)();
133 struct vnodeopv_entry_desc lfs_fifoop_entries[] = {
134 	{ &vop_default_desc, vn_default_error },
135 	{ &vop_lookup_desc, fifo_lookup },		/* lookup */
136 	{ &vop_create_desc, fifo_create },		/* create */
137 	{ &vop_mknod_desc, fifo_mknod },		/* mknod */
138 	{ &vop_open_desc, fifo_open },			/* open */
139 	{ &vop_close_desc, ufsfifo_close },		/* close */
140 	{ &vop_access_desc, ufs_access },		/* access */
141 	{ &vop_getattr_desc, ufs_getattr },		/* getattr */
142 	{ &vop_setattr_desc, ufs_setattr },		/* setattr */
143 	{ &vop_read_desc, ufsfifo_read },		/* read */
144 	{ &vop_write_desc, ufsfifo_write },		/* write */
145 	{ &vop_ioctl_desc, fifo_ioctl },		/* ioctl */
146 	{ &vop_select_desc, fifo_select },		/* select */
147 	{ &vop_mmap_desc, fifo_mmap },			/* mmap */
148 	{ &vop_fsync_desc, fifo_fsync },		/* fsync */
149 	{ &vop_seek_desc, fifo_seek },			/* seek */
150 	{ &vop_remove_desc, fifo_remove },		/* remove */
151 	{ &vop_link_desc, fifo_link },			/* link */
152 	{ &vop_rename_desc, fifo_rename },		/* rename */
153 	{ &vop_mkdir_desc, fifo_mkdir },		/* mkdir */
154 	{ &vop_rmdir_desc, fifo_rmdir },		/* rmdir */
155 	{ &vop_symlink_desc, fifo_symlink },		/* symlink */
156 	{ &vop_readdir_desc, fifo_readdir },		/* readdir */
157 	{ &vop_readlink_desc, fifo_readlink },		/* readlink */
158 	{ &vop_abortop_desc, fifo_abortop },		/* abortop */
159 	{ &vop_inactive_desc, lfs_inactive },		/* inactive */
160 	{ &vop_reclaim_desc, ufs_reclaim },		/* reclaim */
161 	{ &vop_lock_desc, ufs_lock },			/* lock */
162 	{ &vop_unlock_desc, ufs_unlock },		/* unlock */
163 	{ &vop_bmap_desc, fifo_bmap },			/* bmap */
164 	{ &vop_strategy_desc, fifo_strategy },		/* strategy */
165 	{ &vop_print_desc, ufs_print },			/* print */
166 	{ &vop_islocked_desc, ufs_islocked },		/* islocked */
167 	{ &vop_advlock_desc, fifo_advlock },		/* advlock */
168 	{ &vop_blkatoff_desc, fifo_blkatoff },		/* blkatoff */
169 	{ &vop_valloc_desc, fifo_valloc },		/* valloc */
170 	{ &vop_vfree_desc, lfs_vfree },			/* vfree */
171 	{ &vop_truncate_desc, fifo_truncate },		/* truncate */
172 	{ &vop_update_desc, lfs_update },		/* update */
173 	{ &vop_bwrite_desc, lfs_bwrite },		/* bwrite */
174 	{ (struct vnodeop_desc*)NULL, (int(*)())NULL }
175 };
176 struct vnodeopv_desc lfs_fifoop_opv_desc =
177 	{ &lfs_fifoop_p, lfs_fifoop_entries };
178 #endif /* FIFO */
179 
180 /*
181  * Vnode op for reading.
182  */
183 /* ARGSUSED */
184 lfs_read(ap)
185 	struct vop_read_args /* {
186 		struct vnode *a_vp;
187 		struct uio *a_uio;
188 		int a_ioflag;
189 		struct ucred *a_cred;
190 	} */ *ap;
191 {
192 	register struct uio *uio = ap->a_uio;
193 	register struct inode *ip = VTOI(ap->a_vp);
194 	register struct lfs *fs;				/* LFS */
195 	struct buf *bp;
196 	daddr_t lbn, bn, rablock;
197 	int size, error = 0;
198 	long n, on, type;
199 	off_t diff;
200 
201 #ifdef VERBOSE
202 	printf("lfs_read: ino %d\n", ip->i_number);
203 #endif
204 #ifdef DIAGNOSTIC
205 	if (uio->uio_rw != UIO_READ)
206 		panic("ufs_read mode");
207 	type = ip->i_mode & IFMT;
208 	if (type != IFDIR && type != IFREG && type != IFLNK)
209 		panic("ufs_read type");
210 #endif
211 	if (uio->uio_resid == 0)
212 		return (0);
213 	if (uio->uio_offset < 0)
214 		return (EINVAL);
215 	ip->i_flag |= IACC;
216 
217 	fs = ip->i_lfs;						/* LFS */
218 	do {
219 		lbn = lblkno(fs, uio->uio_offset);
220 		on = blkoff(fs, uio->uio_offset);
221 		n = MIN((unsigned)(fs->lfs_bsize - on), uio->uio_resid);
222 		diff = ip->i_size - uio->uio_offset;
223 		if (diff <= 0)
224 			return (0);
225 		if (diff < n)
226 			n = diff;
227 		size = blksize(fs);				/* LFS */
228 		rablock = lbn + 1;
229 		if (ap->a_vp->v_lastr + 1 == lbn &&
230 		    lblktosize(fs, rablock) < ip->i_size)
231 			error = breadn(ITOV(ip), lbn, size, &rablock,
232 				&size, 1, NOCRED, &bp);
233 		else
234 			error = bread(ITOV(ip), lbn, size, NOCRED, &bp);
235 		ap->a_vp->v_lastr = lbn;
236 		n = MIN(n, size - bp->b_resid);
237 		if (error) {
238 			brelse(bp);
239 			return (error);
240 		}
241 		error = uiomove(bp->b_un.b_addr + on, (int)n, uio);
242 		if (n + on == fs->lfs_bsize || uio->uio_offset == ip->i_size)
243 			bp->b_flags |= B_AGE;
244 		brelse(bp);
245 	} while (error == 0 && uio->uio_resid > 0 && n != 0);
246 	return (error);
247 }
248 
249 /*
250  * Vnode op for writing.
251  */
252 lfs_write(ap)
253 	struct vop_write_args /* {
254 		struct vnode *a_vp;
255 		struct uio *a_uio;
256 		int a_ioflag;
257 		struct ucred *a_cred;
258 	} */ *ap;
259 {
260 	register struct vnode *vp = ap->a_vp;
261 	register struct uio *uio = ap->a_uio;
262 	struct proc *p = uio->uio_procp;
263 	register struct inode *ip = VTOI(vp);
264 	register struct lfs *fs;
265 	register ioflag = ap->a_ioflag;
266 	struct buf *bp;
267 	daddr_t lbn;
268 	off_t osize;
269 	int n, on, flags, newblock;
270 	int size, resid, error = 0;
271 
272 #ifdef VERBOSE
273 	printf("lfs_write ino %d\n", ip->i_number);
274 #endif
275 #ifdef DIAGNOSTIC
276 	if (uio->uio_rw != UIO_WRITE)
277 		panic("lfs_write mode");
278 #endif
279 	switch (vp->v_type) {
280 	case VREG:
281 		if (ioflag & IO_APPEND)
282 			uio->uio_offset = ip->i_size;
283 		/* fall through */
284 	case VLNK:
285 		break;
286 
287 	case VDIR:
288 		/* XXX This may not be correct for LFS. */
289 		if ((ioflag & IO_SYNC) == 0)
290 			panic("lfs_write nonsync dir write");
291 		break;
292 
293 	default:
294 		panic("lfs_write type");
295 	}
296 	if (uio->uio_offset < 0)
297 		return (EINVAL);
298 	if (uio->uio_resid == 0)
299 		return (0);
300 	/*
301 	 * Maybe this should be above the vnode op call, but so long as
302 	 * file servers have no limits, i don't think it matters
303 	 */
304 	if (vp->v_type == VREG && p &&
305 	    uio->uio_offset + uio->uio_resid >
306 	      p->p_rlimit[RLIMIT_FSIZE].rlim_cur) {
307 		psignal(p, SIGXFSZ);
308 		return (EFBIG);
309 	}
310 	resid = uio->uio_resid;
311 	osize = ip->i_size;
312 	fs = ip->i_lfs;						/* LFS */
313 	flags = 0;
314 #ifdef NOTLFS
315 	if (ioflag & IO_SYNC)
316 		flags = B_SYNC;
317 #endif
318 	do {
319 		lbn = lblkno(fs, uio->uio_offset);
320 		on = blkoff(fs, uio->uio_offset);
321 		n = MIN((unsigned)(fs->lfs_bsize - on), uio->uio_resid);
322 		if (error = lfs_balloc(vp, n, lbn, &bp))
323 			break;
324 		if (uio->uio_offset + n > ip->i_size) {
325 			ip->i_size = uio->uio_offset + n;
326 			vnode_pager_setsize(vp, (u_long)ip->i_size);
327 		}
328 		size = blksize(fs);
329 		(void) vnode_pager_uncache(vp);
330 		n = MIN(n, size - bp->b_resid);
331 		error = uiomove(bp->b_un.b_addr + on, n, uio);
332 #ifdef NOTLFS							/* LFS */
333 		if (ioflag & IO_SYNC)
334 			(void) bwrite(bp);
335 		else if (n + on == fs->fs_bsize) {
336 			bp->b_flags |= B_AGE;
337 			bawrite(bp);
338 		} else
339 			bdwrite(bp);
340 		ip->i_flag |= IUPD|ICHG;
341 #else
342 		/* XXX This doesn't handle IO_SYNC. */
343 		LFS_UBWRITE(bp);
344 #endif
345 		if (ap->a_cred->cr_uid != 0)
346 			ip->i_mode &= ~(ISUID|ISGID);
347 	} while (error == 0 && uio->uio_resid > 0 && n != 0);
348 	if (error && (ioflag & IO_UNIT)) {
349 		(void)VOP_TRUNCATE(vp, osize, ioflag & IO_SYNC, ap->a_cred,
350 		    uio->uio_procp);
351 		uio->uio_offset -= resid - uio->uio_resid;
352 		uio->uio_resid = resid;
353 	}
354 	if (!error && (ioflag & IO_SYNC))
355 		error = VOP_UPDATE(vp, &time, &time, 1);
356 	return (error);
357 }
358 
359 /*
360  * Synch an open file.
361  */
362 /* ARGSUSED */
363 lfs_fsync(ap)
364 	struct vop_fsync_args /* {
365 		struct vnode *a_vp;
366 		struct ucred *a_cred;
367 		int a_waitfor;
368 		struct proc *a_p;
369 	} */ *ap;
370 {
371 
372 #ifdef VERBOSE
373 	printf("lfs_fsync\n");
374 #endif
375 	return (VOP_UPDATE(ap->a_vp, &time, &time, ap->a_waitfor == MNT_WAIT));
376 }
377 
378 /*
379  * Last reference to an inode, write the inode out and if necessary,
380  * truncate and deallocate the file.
381  */
382 int
383 lfs_inactive(ap)
384 	struct vop_inactive_args /* {
385 		struct vnode *a_vp;
386 	} */ *ap;
387 {
388 	extern int prtactive;
389 	register struct vnode *vp = ap->a_vp;
390 	register struct inode *ip;
391 	int mode, error;
392 
393 #ifdef VERBOSE
394 	printf("lfs_inactive\n");
395 #endif
396 	if (prtactive && vp->v_usecount != 0)
397 		vprint("lfs_inactive: pushing active", vp);
398 
399 	/* Get rid of inodes related to stale file handles. */
400 	ip = VTOI(vp);
401 	if (ip->i_mode == 0) {
402 		if ((vp->v_flag & VXLOCK) == 0)
403 			vgone(vp);
404 		return (0);
405 	}
406 
407 	error = 0;
408 	ILOCK(ip);
409 	if (ip->i_nlink <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) {
410 #ifdef QUOTA
411 		if (!getinoquota(ip))
412 			(void)chkiq(ip, -1, NOCRED, 0);
413 #endif
414 		error = VOP_TRUNCATE(vp, (off_t)0, 0, NOCRED, NULL);
415 		mode = ip->i_mode;
416 		ip->i_mode = 0;
417 		ip->i_rdev = 0;
418 		ip->i_flag |= IUPD|ICHG;
419 		VOP_VFREE(vp, ip->i_number, mode);
420 	}
421 	if (ip->i_flag&(IUPD|IACC|ICHG|IMOD))
422 		VOP_UPDATE(vp, &time, &time, 0);
423 	IUNLOCK(ip);
424 	ip->i_flag = 0;
425 	/*
426 	 * If we are done with the inode, reclaim it
427 	 * so that it can be reused immediately.
428 	 */
429 	if (vp->v_usecount == 0 && ip->i_mode == 0)
430 		vgone(vp);
431 	return (error);
432 }
433 
434 /*
435  * These macros are used to bracket UFS directory ops, so that we can
436  * identify all the pages touched during directory ops which need to
437  * be ordered and flushed atomically, so that they may be recovered.
438  */
439 #define	SET_DIROP(fs) {							\
440 	int __s;							\
441 	__s = splbio();							\
442 	if ((fs)->lfs_writer)						\
443 		tsleep(&(fs)->lfs_dirops, PRIBIO + 1, "lfs dirop", 0);	\
444 	++(fs)->lfs_dirops;						\
445 	(fs)->lfs_doifile = 1;						\
446 	splx(__s);							\
447 }
448 
449 #define	SET_ENDOP(fs) {							\
450 	int __s;							\
451 	__s = splbio();							\
452 	--(fs)->lfs_dirops;						\
453 	if (!(fs)->lfs_dirops)						\
454 		wakeup(&(fs)->lfs_writer);				\
455 	splx(__s);							\
456 }
457 
458 #define	MARK_VNODE(dvp)	(dvp)->v_flag |= VDIROP
459 
460 int
461 lfs_symlink(ap)
462 	struct vop_symlink_args /* {
463 		struct vnode *a_dvp;
464 		struct vnode **a_vpp;
465 		struct componentname *a_cnp;
466 		struct vattr *a_vap;
467 		char *a_target;
468 	} */ *ap;
469 {
470 	int ret;
471 
472 	SET_DIROP(VTOI(ap->a_dvp)->i_lfs);
473 	MARK_VNODE(ap->a_dvp);
474 	ret = ufs_symlink(ap);
475 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs);
476 	return (ret);
477 }
478 
479 int
480 lfs_mknod(ap)
481 	struct vop_mknod_args /* {
482 		struct vnode *a_dvp;
483 		struct vnode **a_vpp;
484 		struct componentname *a_cnp;
485 		struct vattr *a_vap;
486 	} */ *ap;
487 {
488 	int ret;
489 
490 	SET_DIROP(VTOI(ap->a_dvp)->i_lfs);
491 	MARK_VNODE(ap->a_dvp);
492 	ret = ufs_mknod(ap);
493 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs);
494 	return (ret);
495 }
496 
497 int
498 lfs_create(ap)
499 	struct vop_create_args /* {
500 		struct vnode *a_dvp;
501 		struct vnode **a_vpp;
502 		struct componentname *a_cnp;
503 		struct vattr *a_vap;
504 	} */ *ap;
505 {
506 	int ret;
507 
508 	SET_DIROP(VTOI(ap->a_dvp)->i_lfs);
509 	MARK_VNODE(ap->a_dvp);
510 	ret = ufs_create(ap);
511 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs);
512 	return (ret);
513 }
514 
515 int
516 lfs_mkdir(ap)
517 	struct vop_mkdir_args /* {
518 		struct vnode *a_dvp;
519 		struct vnode **a_vpp;
520 		struct componentname *a_cnp;
521 		struct vattr *a_vap;
522 	} */ *ap;
523 {
524 	int ret;
525 
526 	SET_DIROP(VTOI(ap->a_dvp)->i_lfs);
527 	MARK_VNODE(ap->a_dvp);
528 	ret = ufs_mkdir(ap);
529 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs);
530 	return (ret);
531 }
532 
533 int
534 lfs_remove(ap)
535 	struct vop_remove_args /* {
536 		struct vnode *a_dvp;
537 		struct vnode *a_vp;
538 		struct componentname *a_cnp;
539 	} */ *ap;
540 {
541 	int ret;
542 
543 	SET_DIROP(VTOI(ap->a_dvp)->i_lfs);
544 	MARK_VNODE(ap->a_dvp);
545 	MARK_VNODE(ap->a_vp);
546 	ret = ufs_remove(ap);
547 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs);
548 	return (ret);
549 }
550 
551 int
552 lfs_rmdir(ap)
553 	struct vop_rmdir_args /* {
554 		struct vnodeop_desc *a_desc;
555 		struct vnode *a_dvp;
556 		struct vnode *a_vp;
557 		struct componentname *a_cnp;
558 	} */ *ap;
559 {
560 	int ret;
561 
562 	SET_DIROP(VTOI(ap->a_dvp)->i_lfs);
563 	MARK_VNODE(ap->a_dvp);
564 	MARK_VNODE(ap->a_vp);
565 	ret = ufs_rmdir(ap);
566 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs);
567 	return (ret);
568 }
569 
570 int
571 lfs_link(ap)
572 	struct vop_link_args /* {
573 		struct vnode *a_vp;
574 		struct vnode *a_tdvp;
575 		struct componentname *a_cnp;
576 	} */ *ap;
577 {
578 	int ret;
579 
580 	SET_DIROP(VTOI(ap->a_vp)->i_lfs);
581 	MARK_VNODE(ap->a_vp);
582 	ret = ufs_link(ap);
583 	SET_ENDOP(VTOI(ap->a_vp)->i_lfs);
584 	return (ret);
585 }
586 
587 int
588 lfs_rename(ap)
589 	struct vop_rename_args  /* {
590 		struct vnode *a_fdvp;
591 		struct vnode *a_fvp;
592 		struct componentname *a_fcnp;
593 		struct vnode *a_tdvp;
594 		struct vnode *a_tvp;
595 		struct componentname *a_tcnp;
596 	} */ *ap;
597 {
598 	int ret;
599 
600 	SET_DIROP(VTOI(ap->a_fdvp)->i_lfs);
601 	MARK_VNODE(ap->a_fdvp);
602 	MARK_VNODE(ap->a_tdvp);
603 	ret = ufs_rename(ap);
604 	SET_ENDOP(VTOI(ap->a_fdvp)->i_lfs);
605 	return (ret);
606 }
607