Annotation of src/sys/ufs/ext2fs/ext2fs_vnops.c, Revision 1.82
1.82 ! ad 1: /* $NetBSD: ext2fs_vnops.c,v 1.81 2008/01/25 14:32:16 ad Exp $ */
1.1 bouyer 2:
3: /*
4: * Copyright (c) 1982, 1986, 1989, 1993
5: * The Regents of the University of California. All rights reserved.
6: * (c) UNIX System Laboratories, Inc.
7: * All or some portions of this file are derived from material licensed
8: * to the University of California by American Telephone and Telegraph
9: * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10: * the permission of UNIX System Laboratories, Inc.
11: *
12: * Redistribution and use in source and binary forms, with or without
13: * modification, are permitted provided that the following conditions
14: * are met:
15: * 1. Redistributions of source code must retain the above copyright
16: * notice, this list of conditions and the following disclaimer.
17: * 2. Redistributions in binary form must reproduce the above copyright
18: * notice, this list of conditions and the following disclaimer in the
19: * documentation and/or other materials provided with the distribution.
1.49 agc 20: * 3. Neither the name of the University nor the names of its contributors
21: * may be used to endorse or promote products derived from this software
22: * without specific prior written permission.
23: *
24: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34: * SUCH DAMAGE.
35: *
36: * @(#)ufs_vnops.c 8.14 (Berkeley) 10/26/94
37: * Modified for ext2fs by Manuel Bouyer.
38: */
39:
40: /*
41: * Copyright (c) 1997 Manuel Bouyer.
42: *
43: * Redistribution and use in source and binary forms, with or without
44: * modification, are permitted provided that the following conditions
45: * are met:
46: * 1. Redistributions of source code must retain the above copyright
47: * notice, this list of conditions and the following disclaimer.
48: * 2. Redistributions in binary form must reproduce the above copyright
49: * notice, this list of conditions and the following disclaimer in the
50: * documentation and/or other materials provided with the distribution.
1.1 bouyer 51: * 3. All advertising materials mentioning features or use of this software
52: * must display the following acknowledgement:
1.51 bouyer 53: * This product includes software developed by Manuel Bouyer.
54: * 4. The name of the author may not be used to endorse or promote products
55: * derived from this software without specific prior written permission.
1.1 bouyer 56: *
1.52 bouyer 57: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
58: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
59: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
60: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
61: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
63: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
64: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
65: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
66: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.1 bouyer 67: *
68: * @(#)ufs_vnops.c 8.14 (Berkeley) 10/26/94
69: * Modified for ext2fs by Manuel Bouyer.
70: */
1.40 lukem 71:
72: #include <sys/cdefs.h>
1.82 ! ad 73: __KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.81 2008/01/25 14:32:16 ad Exp $");
1.7 mrg 74:
1.1 bouyer 75: #include <sys/param.h>
76: #include <sys/systm.h>
77: #include <sys/resourcevar.h>
78: #include <sys/kernel.h>
79: #include <sys/file.h>
80: #include <sys/stat.h>
81: #include <sys/buf.h>
82: #include <sys/proc.h>
83: #include <sys/mount.h>
84: #include <sys/namei.h>
85: #include <sys/vnode.h>
86: #include <sys/lockf.h>
87: #include <sys/malloc.h>
1.14 thorpej 88: #include <sys/pool.h>
1.1 bouyer 89: #include <sys/signalvar.h>
1.65 elad 90: #include <sys/kauth.h>
1.1 bouyer 91:
92: #include <miscfs/fifofs/fifo.h>
93: #include <miscfs/genfs/genfs.h>
94: #include <miscfs/specfs/specdev.h>
95:
96: #include <ufs/ufs/inode.h>
97: #include <ufs/ufs/ufs_extern.h>
98: #include <ufs/ufs/ufsmount.h>
99:
100: #include <ufs/ext2fs/ext2fs.h>
101: #include <ufs/ext2fs/ext2fs_extern.h>
102: #include <ufs/ext2fs/ext2fs_dir.h>
103:
1.32 tsutsui 104: extern int prtactive;
1.1 bouyer 105:
1.67 ad 106: static int ext2fs_chmod(struct vnode *, int, kauth_cred_t, struct lwp *);
1.65 elad 107: static int ext2fs_chown(struct vnode *, uid_t, gid_t, kauth_cred_t,
1.67 ad 108: struct lwp *);
1.1 bouyer 109:
110: union _qcvt {
111: int64_t qcvt;
112: int32_t val[2];
113: };
1.61 xtraeme 114:
1.1 bouyer 115: #define SETHIGH(q, h) { \
116: union _qcvt tmp; \
117: tmp.qcvt = (q); \
118: tmp.val[_QUAD_HIGHWORD] = (h); \
119: (q) = tmp.qcvt; \
120: }
121: #define SETLOW(q, l) { \
122: union _qcvt tmp; \
123: tmp.qcvt = (q); \
124: tmp.val[_QUAD_LOWWORD] = (l); \
125: (q) = tmp.qcvt; \
126: }
127:
128: /*
129: * Create a regular file
130: */
131: int
1.61 xtraeme 132: ext2fs_create(void *v)
1.1 bouyer 133: {
134: struct vop_create_args /* {
135: struct vnode *a_dvp;
136: struct vnode **a_vpp;
137: struct componentname *a_cnp;
138: struct vattr *a_vap;
139: } */ *ap = v;
1.42 jdolecek 140: int error;
141:
142: error =
143: ext2fs_makeinode(MAKEIMODE(ap->a_vap->va_type, ap->a_vap->va_mode),
144: ap->a_dvp, ap->a_vpp, ap->a_cnp);
145:
146: if (error)
147: return (error);
148: VN_KNOTE(ap->a_dvp, NOTE_WRITE);
149: return (0);
1.1 bouyer 150: }
151:
152: /*
153: * Mknod vnode call
154: */
155: /* ARGSUSED */
156: int
1.61 xtraeme 157: ext2fs_mknod(void *v)
1.1 bouyer 158: {
159: struct vop_mknod_args /* {
160: struct vnode *a_dvp;
161: struct vnode **a_vpp;
162: struct componentname *a_cnp;
163: struct vattr *a_vap;
164: } */ *ap = v;
1.25 augustss 165: struct vattr *vap = ap->a_vap;
166: struct vnode **vpp = ap->a_vpp;
167: struct inode *ip;
1.1 bouyer 168: int error;
1.59 perry 169: struct mount *mp;
1.34 assar 170: ino_t ino;
1.1 bouyer 171:
1.8 fvdl 172: if ((error = ext2fs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode),
173: ap->a_dvp, vpp, ap->a_cnp)) != 0)
1.1 bouyer 174: return (error);
1.42 jdolecek 175: VN_KNOTE(ap->a_dvp, NOTE_WRITE);
1.1 bouyer 176: ip = VTOI(*vpp);
1.34 assar 177: mp = (*vpp)->v_mount;
178: ino = ip->i_number;
1.1 bouyer 179: ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
180: if (vap->va_rdev != VNOVAL) {
181: /*
182: * Want to be able to use this to make badblock
183: * inodes, so don't truncate the dev number.
184: */
1.44 fvdl 185: ip->i_din.e2fs_din->e2di_rdev = h2fs32(vap->va_rdev);
1.1 bouyer 186: }
187: /*
188: * Remove inode so that it will be reloaded by VFS_VGET and
189: * checked to see if it is an alias of an existing entry in
190: * the inode cache.
191: */
1.78 ad 192: VOP_UNLOCK(*vpp, 0);
1.1 bouyer 193: (*vpp)->v_type = VNON;
194: vgone(*vpp);
1.47 thorpej 195: error = VFS_VGET(mp, ino, vpp);
1.34 assar 196: if (error != 0) {
197: *vpp = NULL;
198: return (error);
199: }
1.1 bouyer 200: return (0);
201: }
202:
203: /*
204: * Open called.
205: *
206: * Just check the APPEND flag.
207: */
208: /* ARGSUSED */
209: int
1.61 xtraeme 210: ext2fs_open(void *v)
1.1 bouyer 211: {
212: struct vop_open_args /* {
213: struct vnode *a_vp;
214: int a_mode;
1.65 elad 215: kauth_cred_t a_cred;
1.1 bouyer 216: } */ *ap = v;
217:
218: /*
219: * Files marked append-only must be opened for appending.
220: */
221: if ((VTOI(ap->a_vp)->i_e2fs_flags & EXT2_APPEND) &&
222: (ap->a_mode & (FWRITE | O_APPEND)) == FWRITE)
223: return (EPERM);
224: return (0);
225: }
226:
227: int
1.61 xtraeme 228: ext2fs_access(void *v)
1.1 bouyer 229: {
230: struct vop_access_args /* {
231: struct vnode *a_vp;
232: int a_mode;
1.65 elad 233: kauth_cred_t a_cred;
1.1 bouyer 234: } */ *ap = v;
1.8 fvdl 235: struct vnode *vp = ap->a_vp;
236: struct inode *ip = VTOI(vp);
1.1 bouyer 237: mode_t mode = ap->a_mode;
238:
1.8 fvdl 239: /*
240: * Disallow write attempts on read-only file systems;
241: * unless the file is a socket, fifo, or a block or
242: * character device resident on the file system.
243: */
244: if (mode & VWRITE) {
245: switch (vp->v_type) {
246: case VDIR:
247: case VLNK:
248: case VREG:
249: if (vp->v_mount->mnt_flag & MNT_RDONLY)
250: return (EROFS);
251: break;
252: default:
253: break;
254: }
1.1 bouyer 255: }
256:
257: /* If immutable bit set, nobody gets to write it. */
258: if ((mode & VWRITE) && (ip->i_e2fs_flags & EXT2_IMMUTABLE))
259: return (EPERM);
260:
261: return (vaccess(vp->v_type, ip->i_e2fs_mode & ALLPERMS,
262: ip->i_e2fs_uid, ip->i_e2fs_gid, mode, ap->a_cred));
263: }
264:
265: /* ARGSUSED */
266: int
1.61 xtraeme 267: ext2fs_getattr(void *v)
1.1 bouyer 268: {
269: struct vop_getattr_args /* {
270: struct vnode *a_vp;
271: struct vattr *a_vap;
1.65 elad 272: kauth_cred_t a_cred;
1.1 bouyer 273: } */ *ap = v;
1.25 augustss 274: struct vnode *vp = ap->a_vp;
275: struct inode *ip = VTOI(vp);
276: struct vattr *vap = ap->a_vap;
1.1 bouyer 277:
1.62 christos 278: EXT2FS_ITIMES(ip, NULL, NULL, NULL);
1.1 bouyer 279: /*
280: * Copy from inode table
281: */
282: vap->va_fsid = ip->i_dev;
283: vap->va_fileid = ip->i_number;
284: vap->va_mode = ip->i_e2fs_mode & ALLPERMS;
285: vap->va_nlink = ip->i_e2fs_nlink;
286: vap->va_uid = ip->i_e2fs_uid;
287: vap->va_gid = ip->i_e2fs_gid;
1.44 fvdl 288: vap->va_rdev = (dev_t)fs2h32(ip->i_din.e2fs_din->e2di_rdev);
1.37 chs 289: vap->va_size = vp->v_size;
1.1 bouyer 290: vap->va_atime.tv_sec = ip->i_e2fs_atime;
291: vap->va_atime.tv_nsec = 0;
292: vap->va_mtime.tv_sec = ip->i_e2fs_mtime;
293: vap->va_mtime.tv_nsec = 0;
294: vap->va_ctime.tv_sec = ip->i_e2fs_ctime;
295: vap->va_ctime.tv_nsec = 0;
296: #ifdef EXT2FS_SYSTEM_FLAGS
297: vap->va_flags = (ip->i_e2fs_flags & EXT2_APPEND) ? SF_APPEND : 0;
298: vap->va_flags |= (ip->i_e2fs_flags & EXT2_IMMUTABLE) ? SF_IMMUTABLE : 0;
299: #else
300: vap->va_flags = (ip->i_e2fs_flags & EXT2_APPEND) ? UF_APPEND : 0;
301: vap->va_flags |= (ip->i_e2fs_flags & EXT2_IMMUTABLE) ? UF_IMMUTABLE : 0;
302: #endif
303: vap->va_gen = ip->i_e2fs_gen;
304: /* this doesn't belong here */
305: if (vp->v_type == VBLK)
306: vap->va_blocksize = BLKDEV_IOSIZE;
307: else if (vp->v_type == VCHR)
308: vap->va_blocksize = MAXBSIZE;
309: else
310: vap->va_blocksize = vp->v_mount->mnt_stat.f_iosize;
1.8 fvdl 311: vap->va_bytes = dbtob((u_quad_t)ip->i_e2fs_nblock);
1.1 bouyer 312: vap->va_type = vp->v_type;
313: vap->va_filerev = ip->i_modrev;
314: return (0);
315: }
316:
317: /*
318: * Set attribute vnode op. called from several syscalls
319: */
320: int
1.61 xtraeme 321: ext2fs_setattr(void *v)
1.1 bouyer 322: {
323: struct vop_setattr_args /* {
324: struct vnode *a_vp;
325: struct vattr *a_vap;
1.65 elad 326: kauth_cred_t a_cred;
1.1 bouyer 327: } */ *ap = v;
1.8 fvdl 328: struct vattr *vap = ap->a_vap;
329: struct vnode *vp = ap->a_vp;
330: struct inode *ip = VTOI(vp);
1.65 elad 331: kauth_cred_t cred = ap->a_cred;
1.76 pooka 332: struct lwp *l = curlwp;
1.1 bouyer 333: int error;
334:
335: /*
336: * Check for unsettable attributes.
337: */
1.5 christos 338: if ((vap->va_type != VNON) || (vap->va_nlink != (nlink_t)VNOVAL) ||
1.24 thorpej 339: (vap->va_fsid != VNOVAL) || (vap->va_fileid != VNOVAL) ||
340: (vap->va_blocksize != VNOVAL) || (vap->va_rdev != VNOVAL) ||
341: ((int)vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL)) {
1.1 bouyer 342: return (EINVAL);
343: }
344: if (vap->va_flags != VNOVAL) {
1.8 fvdl 345: if (vp->v_mount->mnt_flag & MNT_RDONLY)
346: return (EROFS);
1.65 elad 347: if (kauth_cred_geteuid(cred) != ip->i_e2fs_uid &&
1.67 ad 348: (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER,
1.72 elad 349: NULL)))
1.1 bouyer 350: return (error);
351: #ifdef EXT2FS_SYSTEM_FLAGS
1.72 elad 352: if (kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER,
353: NULL) == 0) {
1.24 thorpej 354: if ((ip->i_e2fs_flags &
1.71 elad 355: (EXT2_APPEND | EXT2_IMMUTABLE)) &&
356: kauth_authorize_system(l->l_cred,
357: KAUTH_SYSTEM_CHSYSFLAGS, 0, NULL, NULL, NULL))
1.1 bouyer 358: return (EPERM);
359: ip->i_e2fs_flags &= ~(EXT2_APPEND | EXT2_IMMUTABLE);
1.24 thorpej 360: ip->i_e2fs_flags |=
361: (vap->va_flags & SF_APPEND) ? EXT2_APPEND : 0 |
362: (vap->va_flags & SF_IMMUTABLE) ? EXT2_IMMUTABLE : 0;
363: } else
1.1 bouyer 364: return (EPERM);
365: #else
366: ip->i_e2fs_flags &= ~(EXT2_APPEND | EXT2_IMMUTABLE);
1.24 thorpej 367: ip->i_e2fs_flags |=
368: (vap->va_flags & UF_APPEND) ? EXT2_APPEND : 0 |
369: (vap->va_flags & UF_IMMUTABLE) ? EXT2_IMMUTABLE : 0;
1.1 bouyer 370: #endif
371: ip->i_flag |= IN_CHANGE;
372: if (vap->va_flags & (IMMUTABLE | APPEND))
373: return (0);
374: }
375: if (ip->i_e2fs_flags & (EXT2_APPEND | EXT2_IMMUTABLE))
376: return (EPERM);
377: /*
378: * Go through the fields and update iff not VNOVAL.
379: */
380: if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) {
1.8 fvdl 381: if (vp->v_mount->mnt_flag & MNT_RDONLY)
382: return (EROFS);
1.67 ad 383: error = ext2fs_chown(vp, vap->va_uid, vap->va_gid, cred, l);
1.1 bouyer 384: if (error)
385: return (error);
386: }
387: if (vap->va_size != VNOVAL) {
1.8 fvdl 388: /*
389: * Disallow write attempts on read-only file systems;
390: * unless the file is a socket, fifo, or a block or
391: * character device resident on the file system.
392: */
393: switch (vp->v_type) {
394: case VDIR:
1.1 bouyer 395: return (EISDIR);
1.8 fvdl 396: case VLNK:
397: case VREG:
398: if (vp->v_mount->mnt_flag & MNT_RDONLY)
399: return (EROFS);
400: default:
401: break;
402: }
1.77 pooka 403: error = ext2fs_truncate(vp, vap->va_size, 0, cred);
1.1 bouyer 404: if (error)
405: return (error);
406: }
407: ip = VTOI(vp);
408: if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
1.8 fvdl 409: if (vp->v_mount->mnt_flag & MNT_RDONLY)
410: return (EROFS);
1.65 elad 411: if (kauth_cred_geteuid(cred) != ip->i_e2fs_uid &&
412: (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER,
1.72 elad 413: NULL)) &&
1.59 perry 414: ((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||
1.76 pooka 415: (error = VOP_ACCESS(vp, VWRITE, cred))))
1.1 bouyer 416: return (error);
417: if (vap->va_atime.tv_sec != VNOVAL)
418: if (!(vp->v_mount->mnt_flag & MNT_NOATIME))
419: ip->i_flag |= IN_ACCESS;
420: if (vap->va_mtime.tv_sec != VNOVAL)
421: ip->i_flag |= IN_CHANGE | IN_UPDATE;
1.63 yamt 422: error = ext2fs_update(vp, &vap->va_atime, &vap->va_mtime,
1.26 perseant 423: UPDATE_WAIT);
1.1 bouyer 424: if (error)
425: return (error);
426: }
427: error = 0;
1.8 fvdl 428: if (vap->va_mode != (mode_t)VNOVAL) {
429: if (vp->v_mount->mnt_flag & MNT_RDONLY)
430: return (EROFS);
1.67 ad 431: error = ext2fs_chmod(vp, (int)vap->va_mode, cred, l);
1.8 fvdl 432: }
1.42 jdolecek 433: VN_KNOTE(vp, NOTE_ATTRIB);
1.1 bouyer 434: return (error);
435: }
436:
437: /*
438: * Change the mode on a file.
439: * Inode must be locked before calling.
440: */
441: static int
1.67 ad 442: ext2fs_chmod(struct vnode *vp, int mode, kauth_cred_t cred, struct lwp *l)
1.1 bouyer 443: {
1.25 augustss 444: struct inode *ip = VTOI(vp);
1.65 elad 445: int error, ismember = 0;
1.1 bouyer 446:
1.65 elad 447: if (kauth_cred_geteuid(cred) != ip->i_e2fs_uid &&
1.67 ad 448: (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER,
1.72 elad 449: NULL)))
1.1 bouyer 450: return (error);
1.72 elad 451: if (kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL)) {
1.1 bouyer 452: if (vp->v_type != VDIR && (mode & S_ISTXT))
453: return (EFTYPE);
1.65 elad 454: if ((kauth_cred_ismember_gid(cred, ip->i_e2fs_gid, &ismember) != 0 ||
455: !ismember) && (mode & ISGID))
1.1 bouyer 456: return (EPERM);
457: }
458: ip->i_e2fs_mode &= ~ALLPERMS;
459: ip->i_e2fs_mode |= (mode & ALLPERMS);
460: ip->i_flag |= IN_CHANGE;
461: return (0);
462: }
463:
464: /*
465: * Perform chown operation on inode ip;
466: * inode must be locked prior to call.
467: */
468: static int
1.65 elad 469: ext2fs_chown(struct vnode *vp, uid_t uid, gid_t gid, kauth_cred_t cred,
1.67 ad 470: struct lwp *l)
1.1 bouyer 471: {
1.25 augustss 472: struct inode *ip = VTOI(vp);
1.1 bouyer 473: uid_t ouid;
474: gid_t ogid;
1.65 elad 475: int error = 0, ismember = 0;
1.1 bouyer 476:
477: if (uid == (uid_t)VNOVAL)
478: uid = ip->i_e2fs_uid;
479: if (gid == (gid_t)VNOVAL)
480: gid = ip->i_e2fs_gid;
481: /*
482: * If we don't own the file, are trying to change the owner
483: * of the file, or are not a member of the target group,
484: * the caller must be superuser or the call fails.
485: */
1.65 elad 486: if ((kauth_cred_geteuid(cred) != ip->i_e2fs_uid || uid != ip->i_e2fs_uid ||
1.67 ad 487: (gid != ip->i_e2fs_gid &&
488: !(kauth_cred_getegid(cred) == gid ||
489: (kauth_cred_ismember_gid(cred, gid, &ismember) == 0 && ismember)))) &&
1.72 elad 490: (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL)))
1.1 bouyer 491: return (error);
492: ogid = ip->i_e2fs_gid;
493: ouid = ip->i_e2fs_uid;
494:
495: ip->i_e2fs_gid = gid;
496: ip->i_e2fs_uid = uid;
497: if (ouid != uid || ogid != gid)
498: ip->i_flag |= IN_CHANGE;
1.72 elad 499: if (ouid != uid && kauth_authorize_generic(cred,
500: KAUTH_GENERIC_ISSUSER, NULL) != 0)
1.1 bouyer 501: ip->i_e2fs_mode &= ~ISUID;
1.72 elad 502: if (ogid != gid && kauth_authorize_generic(cred,
503: KAUTH_GENERIC_ISSUSER, NULL) != 0)
1.1 bouyer 504: ip->i_e2fs_mode &= ~ISGID;
505: return (0);
506: }
507:
508: int
1.61 xtraeme 509: ext2fs_remove(void *v)
1.1 bouyer 510: {
511: struct vop_remove_args /* {
512: struct vnode *a_dvp;
513: struct vnode *a_vp;
514: struct componentname *a_cnp;
515: } */ *ap = v;
1.8 fvdl 516: struct inode *ip;
517: struct vnode *vp = ap->a_vp;
518: struct vnode *dvp = ap->a_dvp;
1.1 bouyer 519: int error;
520:
521: ip = VTOI(vp);
1.2 fvdl 522: if (vp->v_type == VDIR ||
523: (ip->i_e2fs_flags & (EXT2_IMMUTABLE | EXT2_APPEND)) ||
1.1 bouyer 524: (VTOI(dvp)->i_e2fs_flags & EXT2_APPEND)) {
525: error = EPERM;
1.43 jdolecek 526: } else {
527: error = ext2fs_dirremove(dvp, ap->a_cnp);
528: if (error == 0) {
529: ip->i_e2fs_nlink--;
530: ip->i_flag |= IN_CHANGE;
531: }
1.1 bouyer 532: }
1.43 jdolecek 533:
1.42 jdolecek 534: VN_KNOTE(vp, NOTE_DELETE);
535: VN_KNOTE(dvp, NOTE_WRITE);
1.1 bouyer 536: if (dvp == vp)
537: vrele(vp);
538: else
539: vput(vp);
540: vput(dvp);
541: return (error);
542: }
543:
544: /*
545: * link vnode call
546: */
547: int
1.61 xtraeme 548: ext2fs_link(void *v)
1.1 bouyer 549: {
550: struct vop_link_args /* {
551: struct vnode *a_dvp;
552: struct vnode *a_vp;
553: struct componentname *a_cnp;
554: } */ *ap = v;
1.8 fvdl 555: struct vnode *dvp = ap->a_dvp;
556: struct vnode *vp = ap->a_vp;
557: struct componentname *cnp = ap->a_cnp;
558: struct inode *ip;
1.1 bouyer 559: int error;
560:
561: #ifdef DIAGNOSTIC
562: if ((cnp->cn_flags & HASBUF) == 0)
563: panic("ext2fs_link: no name");
564: #endif
565: if (vp->v_type == VDIR) {
566: VOP_ABORTOP(dvp, cnp);
567: error = EISDIR;
568: goto out2;
569: }
570: if (dvp->v_mount != vp->v_mount) {
571: VOP_ABORTOP(dvp, cnp);
572: error = EXDEV;
573: goto out2;
574: }
1.8 fvdl 575: if (dvp != vp && (error = vn_lock(vp, LK_EXCLUSIVE))) {
1.1 bouyer 576: VOP_ABORTOP(dvp, cnp);
577: goto out2;
578: }
579: ip = VTOI(vp);
580: if ((nlink_t)ip->i_e2fs_nlink >= LINK_MAX) {
581: VOP_ABORTOP(dvp, cnp);
582: error = EMLINK;
583: goto out1;
584: }
585: if (ip->i_e2fs_flags & (EXT2_IMMUTABLE | EXT2_APPEND)) {
586: VOP_ABORTOP(dvp, cnp);
587: error = EPERM;
588: goto out1;
589: }
590: ip->i_e2fs_nlink++;
591: ip->i_flag |= IN_CHANGE;
1.63 yamt 592: error = ext2fs_update(vp, NULL, NULL, UPDATE_WAIT);
1.1 bouyer 593: if (!error)
594: error = ext2fs_direnter(ip, dvp, cnp);
595: if (error) {
596: ip->i_e2fs_nlink--;
597: ip->i_flag |= IN_CHANGE;
598: }
1.29 thorpej 599: PNBUF_PUT(cnp->cn_pnbuf);
1.1 bouyer 600: out1:
601: if (dvp != vp)
1.8 fvdl 602: VOP_UNLOCK(vp, 0);
1.1 bouyer 603: out2:
1.42 jdolecek 604: VN_KNOTE(vp, NOTE_LINK);
605: VN_KNOTE(dvp, NOTE_WRITE);
1.1 bouyer 606: vput(dvp);
607: return (error);
608: }
609:
610: /*
611: * Rename system call.
612: * rename("foo", "bar");
613: * is essentially
614: * unlink("bar");
615: * link("foo", "bar");
616: * unlink("foo");
617: * but ``atomically''. Can't do full commit without saving state in the
618: * inode on disk which isn't feasible at this time. Best we can do is
619: * always guarantee the target exists.
620: *
621: * Basic algorithm is:
622: *
623: * 1) Bump link count on source while we're linking it to the
624: * target. This also ensure the inode won't be deleted out
625: * from underneath us while we work (it may be truncated by
626: * a concurrent `trunc' or `open' for creation).
627: * 2) Link source to destination. If destination already exists,
628: * delete it first.
629: * 3) Unlink source reference to inode if still around. If a
630: * directory was moved and the parent of the destination
631: * is different from the source, patch the ".." entry in the
632: * directory.
633: */
634: int
1.61 xtraeme 635: ext2fs_rename(void *v)
1.1 bouyer 636: {
637: struct vop_rename_args /* {
638: struct vnode *a_fdvp;
639: struct vnode *a_fvp;
640: struct componentname *a_fcnp;
641: struct vnode *a_tdvp;
642: struct vnode *a_tvp;
643: struct componentname *a_tcnp;
644: } */ *ap = v;
645: struct vnode *tvp = ap->a_tvp;
1.25 augustss 646: struct vnode *tdvp = ap->a_tdvp;
1.1 bouyer 647: struct vnode *fvp = ap->a_fvp;
1.8 fvdl 648: struct vnode *fdvp = ap->a_fdvp;
649: struct componentname *tcnp = ap->a_tcnp;
650: struct componentname *fcnp = ap->a_fcnp;
651: struct inode *ip, *xp, *dp;
1.1 bouyer 652: struct ext2fs_dirtemplate dirbuf;
653: int doingdirectory = 0, oldparent = 0, newparent = 0;
654: int error = 0;
655: u_char namlen;
656:
657: #ifdef DIAGNOSTIC
658: if ((tcnp->cn_flags & HASBUF) == 0 ||
659: (fcnp->cn_flags & HASBUF) == 0)
660: panic("ext2fs_rename: no name");
661: #endif
662: /*
663: * Check for cross-device rename.
664: */
665: if ((fvp->v_mount != tdvp->v_mount) ||
666: (tvp && (fvp->v_mount != tvp->v_mount))) {
667: error = EXDEV;
668: abortit:
669: VOP_ABORTOP(tdvp, tcnp); /* XXX, why not in NFS? */
670: if (tdvp == tvp)
671: vrele(tdvp);
672: else
673: vput(tdvp);
674: if (tvp)
675: vput(tvp);
676: VOP_ABORTOP(fdvp, fcnp); /* XXX, why not in NFS? */
677: vrele(fdvp);
678: vrele(fvp);
679: return (error);
680: }
681:
682: /*
683: * Check if just deleting a link name.
684: */
685: if (tvp && ((VTOI(tvp)->i_e2fs_flags & (EXT2_IMMUTABLE | EXT2_APPEND)) ||
686: (VTOI(tdvp)->i_e2fs_flags & EXT2_APPEND))) {
687: error = EPERM;
688: goto abortit;
689: }
690: if (fvp == tvp) {
691: if (fvp->v_type == VDIR) {
692: error = EINVAL;
693: goto abortit;
694: }
695:
696: /* Release destination completely. */
697: VOP_ABORTOP(tdvp, tcnp);
698: vput(tdvp);
699: vput(tvp);
700:
701: /* Delete source. */
702: vrele(fvp);
1.70 chs 703: fcnp->cn_flags &= ~(MODMASK | SAVESTART);
1.1 bouyer 704: fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
705: fcnp->cn_nameiop = DELETE;
1.70 chs 706: vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
707: if ((error = relookup(fdvp, &fvp, fcnp))) {
708: vput(fdvp);
709: return (error);
710: }
1.1 bouyer 711: return (VOP_REMOVE(fdvp, fvp, fcnp));
712: }
1.8 fvdl 713: if ((error = vn_lock(fvp, LK_EXCLUSIVE)) != 0)
1.1 bouyer 714: goto abortit;
715: dp = VTOI(fdvp);
716: ip = VTOI(fvp);
1.17 mrg 717: if ((nlink_t) ip->i_e2fs_nlink >= LINK_MAX) {
718: VOP_UNLOCK(fvp, 0);
719: error = EMLINK;
720: goto abortit;
721: }
1.1 bouyer 722: if ((ip->i_e2fs_flags & (EXT2_IMMUTABLE | EXT2_APPEND)) ||
723: (dp->i_e2fs_flags & EXT2_APPEND)) {
1.8 fvdl 724: VOP_UNLOCK(fvp, 0);
1.1 bouyer 725: error = EPERM;
726: goto abortit;
727: }
728: if ((ip->i_e2fs_mode & IFMT) == IFDIR) {
1.76 pooka 729: error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred);
1.16 bouyer 730: if (!error && tvp)
1.76 pooka 731: error = VOP_ACCESS(tvp, VWRITE, tcnp->cn_cred);
1.16 bouyer 732: if (error) {
733: VOP_UNLOCK(fvp, 0);
734: error = EACCES;
735: goto abortit;
736: }
1.1 bouyer 737: /*
738: * Avoid ".", "..", and aliases of "." for obvious reasons.
739: */
740: if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') ||
1.3 bouyer 741: dp == ip ||
1.70 chs 742: (fcnp->cn_flags & ISDOTDOT) ||
1.16 bouyer 743: (tcnp->cn_flags & ISDOTDOT) ||
1.1 bouyer 744: (ip->i_flag & IN_RENAME)) {
1.8 fvdl 745: VOP_UNLOCK(fvp, 0);
1.1 bouyer 746: error = EINVAL;
747: goto abortit;
748: }
749: ip->i_flag |= IN_RENAME;
750: oldparent = dp->i_number;
1.70 chs 751: doingdirectory = 1;
1.1 bouyer 752: }
1.42 jdolecek 753: VN_KNOTE(fdvp, NOTE_WRITE); /* XXXLUKEM/XXX: right place? */
1.1 bouyer 754:
755: /*
756: * When the target exists, both the directory
757: * and target vnodes are returned locked.
758: */
759: dp = VTOI(tdvp);
760: xp = NULL;
761: if (tvp)
762: xp = VTOI(tvp);
763:
764: /*
765: * 1) Bump link count while we're moving stuff
766: * around. If we crash somewhere before
767: * completing our work, the link count
768: * may be wrong, but correctable.
769: */
770: ip->i_e2fs_nlink++;
771: ip->i_flag |= IN_CHANGE;
1.63 yamt 772: if ((error = ext2fs_update(fvp, NULL, NULL, UPDATE_WAIT)) != 0) {
1.8 fvdl 773: VOP_UNLOCK(fvp, 0);
1.1 bouyer 774: goto bad;
775: }
776:
777: /*
778: * If ".." must be changed (ie the directory gets a new
779: * parent) then the source directory must not be in the
1.36 wiz 780: * directory hierarchy above the target, as this would
1.1 bouyer 781: * orphan everything below the source directory. Also
782: * the user must have write permission in the source so
1.59 perry 783: * as to be able to change "..". We must repeat the call
1.1 bouyer 784: * to namei, as the parent directory is unlocked by the
785: * call to checkpath().
786: */
1.76 pooka 787: error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred);
1.8 fvdl 788: VOP_UNLOCK(fvp, 0);
1.1 bouyer 789: if (oldparent != dp->i_number)
790: newparent = dp->i_number;
791: if (doingdirectory && newparent) {
792: if (error) /* write access check above */
793: goto bad;
794: if (xp != NULL)
795: vput(tvp);
1.70 chs 796: vref(tdvp); /* compensate for the ref checkpath loses */
1.47 thorpej 797: error = ext2fs_checkpath(ip, dp, tcnp->cn_cred);
1.70 chs 798: if (error != 0) {
799: vrele(tdvp);
1.1 bouyer 800: goto out;
1.70 chs 801: }
802: tcnp->cn_flags &= ~SAVESTART;
803: vn_lock(tdvp, LK_EXCLUSIVE | LK_RETRY);
804: if ((error = relookup(tdvp, &tvp, tcnp)) != 0) {
805: vput(tdvp);
1.1 bouyer 806: goto out;
1.70 chs 807: }
1.1 bouyer 808: dp = VTOI(tdvp);
809: xp = NULL;
810: if (tvp)
811: xp = VTOI(tvp);
812: }
813: /*
814: * 2) If target doesn't exist, link the target
1.59 perry 815: * to the source and unlink the source.
1.1 bouyer 816: * Otherwise, rewrite the target directory
817: * entry to reference the source inode and
818: * expunge the original entry's existence.
819: */
820: if (xp == NULL) {
821: if (dp->i_dev != ip->i_dev)
822: panic("rename: EXDEV");
823: /*
824: * Account for ".." in new directory.
825: * When source and destination have the same
826: * parent we don't fool with the link count.
827: */
828: if (doingdirectory && newparent) {
829: if ((nlink_t)dp->i_e2fs_nlink >= LINK_MAX) {
830: error = EMLINK;
831: goto bad;
832: }
833: dp->i_e2fs_nlink++;
834: dp->i_flag |= IN_CHANGE;
1.63 yamt 835: if ((error = ext2fs_update(tdvp, NULL, NULL,
836: UPDATE_WAIT)) != 0)
1.1 bouyer 837: goto bad;
838: }
839: error = ext2fs_direnter(ip, tdvp, tcnp);
840: if (error != 0) {
841: if (doingdirectory && newparent) {
842: dp->i_e2fs_nlink--;
843: dp->i_flag |= IN_CHANGE;
1.63 yamt 844: (void)ext2fs_update(tdvp, NULL, NULL,
845: UPDATE_WAIT);
1.1 bouyer 846: }
847: goto bad;
848: }
1.42 jdolecek 849: VN_KNOTE(tdvp, NOTE_WRITE);
1.1 bouyer 850: vput(tdvp);
851: } else {
852: if (xp->i_dev != dp->i_dev || xp->i_dev != ip->i_dev)
853: panic("rename: EXDEV");
854: /*
855: * Short circuit rename(foo, foo).
856: */
857: if (xp->i_number == ip->i_number)
858: panic("rename: same file");
859: /*
860: * If the parent directory is "sticky", then the user must
861: * own the parent directory, or the destination of the rename,
862: * otherwise the destination may not be changed (except by
863: * root). This implements append-only directories.
864: */
1.72 elad 865: if ((dp->i_e2fs_mode & S_ISTXT) &&
866: kauth_authorize_generic(tcnp->cn_cred,
867: KAUTH_GENERIC_ISSUSER, NULL) != 0 &&
1.65 elad 868: kauth_cred_geteuid(tcnp->cn_cred) != dp->i_e2fs_uid &&
869: xp->i_e2fs_uid != kauth_cred_geteuid(tcnp->cn_cred)) {
1.1 bouyer 870: error = EPERM;
871: goto bad;
872: }
873: /*
874: * Target must be empty if a directory and have no links
875: * to it. Also, ensure source and target are compatible
876: * (both directories, or both not directories).
877: */
878: if ((xp->i_e2fs_mode & IFMT) == IFDIR) {
879: if (!ext2fs_dirempty(xp, dp->i_number, tcnp->cn_cred) ||
880: xp->i_e2fs_nlink > 2) {
881: error = ENOTEMPTY;
882: goto bad;
883: }
884: if (!doingdirectory) {
885: error = ENOTDIR;
886: goto bad;
887: }
888: cache_purge(tdvp);
889: } else if (doingdirectory) {
890: error = EISDIR;
891: goto bad;
892: }
893: error = ext2fs_dirrewrite(dp, ip, tcnp);
894: if (error != 0)
895: goto bad;
896: /*
897: * If the target directory is in the same
898: * directory as the source directory,
899: * decrement the link count on the parent
900: * of the target directory.
901: */
902: if (doingdirectory && !newparent) {
903: dp->i_e2fs_nlink--;
904: dp->i_flag |= IN_CHANGE;
905: }
906: /*
907: * Adjust the link count of the target to
908: * reflect the dirrewrite above. If this is
909: * a directory it is empty and there are
910: * no links to it, so we can squash the inode and
911: * any space associated with it. We disallowed
912: * renaming over top of a directory with links to
913: * it above, as the remaining link would point to
914: * a directory without "." or ".." entries.
915: */
916: xp->i_e2fs_nlink--;
917: if (doingdirectory) {
918: if (--xp->i_e2fs_nlink != 0)
919: panic("rename: linked directory");
1.63 yamt 920: error = ext2fs_truncate(tvp, (off_t)0, IO_SYNC,
1.77 pooka 921: tcnp->cn_cred);
1.1 bouyer 922: }
923: xp->i_flag |= IN_CHANGE;
1.70 chs 924: VN_KNOTE(tdvp, NOTE_WRITE);
925: vput(tdvp);
1.42 jdolecek 926: VN_KNOTE(tvp, NOTE_DELETE);
1.1 bouyer 927: vput(tvp);
928: xp = NULL;
929: }
930:
931: /*
932: * 3) Unlink the source.
933: */
1.70 chs 934: fcnp->cn_flags &= ~(MODMASK | SAVESTART);
1.1 bouyer 935: fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
1.70 chs 936: vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
937: if ((error = relookup(fdvp, &fvp, fcnp))) {
938: vput(fdvp);
939: vrele(ap->a_fvp);
940: return (error);
941: }
1.1 bouyer 942: if (fvp != NULL) {
943: xp = VTOI(fvp);
944: dp = VTOI(fdvp);
945: } else {
946: /*
947: * From name has disappeared.
948: */
949: if (doingdirectory)
950: panic("ext2fs_rename: lost dir entry");
951: vrele(ap->a_fvp);
952: return (0);
953: }
954: /*
955: * Ensure that the directory entry still exists and has not
956: * changed while the new name has been entered. If the source is
957: * a file then the entry may have been unlinked or renamed. In
958: * either case there is no further work to be done. If the source
959: * is a directory then it cannot have been rmdir'ed; its link
960: * count of three would cause a rmdir to fail with ENOTEMPTY.
961: * The IRENAME flag ensures that it cannot be moved by another
962: * rename.
963: */
964: if (xp != ip) {
965: if (doingdirectory)
966: panic("ext2fs_rename: lost dir entry");
967: } else {
968: /*
969: * If the source is a directory with a
970: * new parent, the link count of the old
971: * parent directory must be decremented
972: * and ".." set to point to the new parent.
973: */
974: if (doingdirectory && newparent) {
1.69 christos 975: KASSERT(dp != NULL);
1.1 bouyer 976: dp->i_e2fs_nlink--;
977: dp->i_flag |= IN_CHANGE;
1.74 christos 978: error = vn_rdwr(UIO_READ, fvp, (void *)&dirbuf,
1.1 bouyer 979: sizeof (struct ext2fs_dirtemplate), (off_t)0,
1.59 perry 980: UIO_SYSSPACE, IO_NODELOCKED,
1.56 skrll 981: tcnp->cn_cred, (size_t *)0, NULL);
1.1 bouyer 982: if (error == 0) {
1.22 bouyer 983: namlen = dirbuf.dotdot_namlen;
1.1 bouyer 984: if (namlen != 2 ||
985: dirbuf.dotdot_name[0] != '.' ||
986: dirbuf.dotdot_name[1] != '.') {
987: ufs_dirbad(xp, (doff_t)12,
988: "ext2fs_rename: mangled dir");
989: } else {
1.4 bouyer 990: dirbuf.dotdot_ino = h2fs32(newparent);
1.1 bouyer 991: (void) vn_rdwr(UIO_WRITE, fvp,
1.74 christos 992: (void *)&dirbuf,
1.1 bouyer 993: sizeof (struct dirtemplate),
994: (off_t)0, UIO_SYSSPACE,
995: IO_NODELOCKED|IO_SYNC,
1.12 mjacob 996: tcnp->cn_cred, (size_t *)0,
1.56 skrll 997: NULL);
1.1 bouyer 998: cache_purge(fdvp);
999: }
1000: }
1001: }
1002: error = ext2fs_dirremove(fdvp, fcnp);
1003: if (!error) {
1004: xp->i_e2fs_nlink--;
1005: xp->i_flag |= IN_CHANGE;
1006: }
1007: xp->i_flag &= ~IN_RENAME;
1008: }
1.42 jdolecek 1009: VN_KNOTE(fvp, NOTE_RENAME);
1.70 chs 1010: if (dp)
1011: vput(fdvp);
1.1 bouyer 1012: if (xp)
1013: vput(fvp);
1.70 chs 1014: vrele(ap->a_fvp);
1.1 bouyer 1015: return (error);
1016:
1017: bad:
1018: if (xp)
1019: vput(ITOV(xp));
1020: vput(ITOV(dp));
1021: out:
1022: if (doingdirectory)
1023: ip->i_flag &= ~IN_RENAME;
1.8 fvdl 1024: if (vn_lock(fvp, LK_EXCLUSIVE) == 0) {
1.1 bouyer 1025: ip->i_e2fs_nlink--;
1026: ip->i_flag |= IN_CHANGE;
1027: vput(fvp);
1028: } else
1029: vrele(fvp);
1.70 chs 1030: vrele(fdvp);
1.1 bouyer 1031: return (error);
1032: }
1033:
1034: /*
1035: * Mkdir system call
1036: */
1037: int
1.61 xtraeme 1038: ext2fs_mkdir(void *v)
1.1 bouyer 1039: {
1040: struct vop_mkdir_args /* {
1041: struct vnode *a_dvp;
1042: struct vnode **a_vpp;
1043: struct componentname *a_cnp;
1044: struct vattr *a_vap;
1045: } */ *ap = v;
1.55 mycroft 1046: struct vnode *dvp = ap->a_dvp;
1047: struct vattr *vap = ap->a_vap;
1048: struct componentname *cnp = ap->a_cnp;
1049: struct inode *ip, *dp = VTOI(dvp);
1050: struct vnode *tvp;
1.4 bouyer 1051: struct ext2fs_dirtemplate dirtemplate;
1.55 mycroft 1052: int error, dmode;
1.1 bouyer 1053:
1054: #ifdef DIAGNOSTIC
1055: if ((cnp->cn_flags & HASBUF) == 0)
1056: panic("ext2fs_mkdir: no name");
1057: #endif
1058: if ((nlink_t)dp->i_e2fs_nlink >= LINK_MAX) {
1059: error = EMLINK;
1060: goto out;
1061: }
1062: dmode = vap->va_mode & ACCESSPERMS;
1063: dmode |= IFDIR;
1064: /*
1065: * Must simulate part of ext2fs_makeinode here to acquire the inode,
1066: * but not have it entered in the parent directory. The entry is
1067: * made later after writing "." and ".." entries.
1068: */
1.63 yamt 1069: if ((error = ext2fs_valloc(dvp, dmode, cnp->cn_cred, &tvp)) != 0)
1.1 bouyer 1070: goto out;
1071: ip = VTOI(tvp);
1.65 elad 1072: ip->i_e2fs_uid = kauth_cred_geteuid(cnp->cn_cred);
1.1 bouyer 1073: ip->i_e2fs_gid = dp->i_e2fs_gid;
1074: ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
1075: ip->i_e2fs_mode = dmode;
1076: tvp->v_type = VDIR; /* Rest init'd in getnewvnode(). */
1077: ip->i_e2fs_nlink = 2;
1078:
1079: /*
1080: * Bump link count in parent directory
1081: * to reflect work done below. Should
1082: * be done before reference is created
1083: * so reparation is possible if we crash.
1084: */
1085: dp->i_e2fs_nlink++;
1086: dp->i_flag |= IN_CHANGE;
1.63 yamt 1087: if ((error = ext2fs_update(dvp, NULL, NULL, UPDATE_DIROP)) != 0)
1.1 bouyer 1088: goto bad;
1089:
1090: /* Initialize directory with "." and ".." from static template. */
1.13 perry 1091: memset(&dirtemplate, 0, sizeof(dirtemplate));
1.4 bouyer 1092: dirtemplate.dot_ino = h2fs32(ip->i_number);
1093: dirtemplate.dot_reclen = h2fs16(12);
1.22 bouyer 1094: dirtemplate.dot_namlen = 1;
1095: if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 &&
1096: (ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) {
1.23 bouyer 1097: dirtemplate.dot_type = EXT2_FT_DIR;
1.22 bouyer 1098: }
1.4 bouyer 1099: dirtemplate.dot_name[0] = '.';
1100: dirtemplate.dotdot_ino = h2fs32(dp->i_number);
1101: dirtemplate.dotdot_reclen = h2fs16(VTOI(dvp)->i_e2fs->e2fs_bsize - 12);
1.22 bouyer 1102: dirtemplate.dotdot_namlen = 2;
1103: if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 &&
1104: (ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) {
1.23 bouyer 1105: dirtemplate.dotdot_type = EXT2_FT_DIR;
1.22 bouyer 1106: }
1.4 bouyer 1107: dirtemplate.dotdot_name[0] = dirtemplate.dotdot_name[1] = '.';
1.74 christos 1108: error = vn_rdwr(UIO_WRITE, tvp, (void *)&dirtemplate,
1.1 bouyer 1109: sizeof (dirtemplate), (off_t)0, UIO_SYSSPACE,
1.56 skrll 1110: IO_NODELOCKED|IO_SYNC, cnp->cn_cred, (size_t *)0, NULL);
1.1 bouyer 1111: if (error) {
1112: dp->i_e2fs_nlink--;
1113: dp->i_flag |= IN_CHANGE;
1114: goto bad;
1115: }
1.55 mycroft 1116: if (VTOI(dvp)->i_e2fs->e2fs_bsize > dvp->v_mount->mnt_stat.f_bsize)
1.1 bouyer 1117: panic("ext2fs_mkdir: blksize"); /* XXX should grow with balloc() */
1118: else {
1.58 ws 1119: error = ext2fs_setsize(ip, VTOI(dvp)->i_e2fs->e2fs_bsize);
1120: if (error) {
1121: dp->i_e2fs_nlink--;
1122: dp->i_flag |= IN_CHANGE;
1123: goto bad;
1124: }
1.1 bouyer 1125: ip->i_flag |= IN_CHANGE;
1.60 kml 1126: uvm_vnp_setsize(tvp, ext2fs_size(ip));
1.1 bouyer 1127: }
1128:
1129: /* Directory set up, now install it's entry in the parent directory. */
1130: error = ext2fs_direnter(ip, dvp, cnp);
1131: if (error != 0) {
1132: dp->i_e2fs_nlink--;
1133: dp->i_flag |= IN_CHANGE;
1134: }
1135: bad:
1136: /*
1.63 yamt 1137: * No need to do an explicit ext2fs_truncate here, vrele will do this
1.1 bouyer 1138: * for us because we set the link count to 0.
1139: */
1140: if (error) {
1141: ip->i_e2fs_nlink = 0;
1142: ip->i_flag |= IN_CHANGE;
1143: vput(tvp);
1.42 jdolecek 1144: } else {
1145: VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
1.1 bouyer 1146: *ap->a_vpp = tvp;
1.42 jdolecek 1147: }
1.1 bouyer 1148: out:
1.29 thorpej 1149: PNBUF_PUT(cnp->cn_pnbuf);
1.1 bouyer 1150: vput(dvp);
1151: return (error);
1152: }
1153:
1154: /*
1155: * Rmdir system call.
1156: */
1157: int
1.61 xtraeme 1158: ext2fs_rmdir(void *v)
1.1 bouyer 1159: {
1160: struct vop_rmdir_args /* {
1161: struct vnode *a_dvp;
1162: struct vnode *a_vp;
1163: struct componentname *a_cnp;
1164: } */ *ap = v;
1.25 augustss 1165: struct vnode *vp = ap->a_vp;
1166: struct vnode *dvp = ap->a_dvp;
1167: struct componentname *cnp = ap->a_cnp;
1168: struct inode *ip, *dp;
1.1 bouyer 1169: int error;
1170:
1171: ip = VTOI(vp);
1172: dp = VTOI(dvp);
1173: /*
1174: * No rmdir "." please.
1175: */
1176: if (dp == ip) {
1177: vrele(dvp);
1178: vput(vp);
1179: return (EINVAL);
1180: }
1181: /*
1182: * Verify the directory is empty (and valid).
1183: * (Rmdir ".." won't be valid since
1184: * ".." will contain a reference to
1185: * the current directory and thus be
1186: * non-empty.)
1187: */
1188: error = 0;
1189: if (ip->i_e2fs_nlink != 2 ||
1190: !ext2fs_dirempty(ip, dp->i_number, cnp->cn_cred)) {
1191: error = ENOTEMPTY;
1192: goto out;
1193: }
1194: if ((dp->i_e2fs_flags & EXT2_APPEND) ||
1195: (ip->i_e2fs_flags & (EXT2_IMMUTABLE | EXT2_APPEND))) {
1196: error = EPERM;
1197: goto out;
1198: }
1199: /*
1200: * Delete reference to directory before purging
1201: * inode. If we crash in between, the directory
1202: * will be reattached to lost+found,
1203: */
1204: error = ext2fs_dirremove(dvp, cnp);
1205: if (error != 0)
1206: goto out;
1207: dp->i_e2fs_nlink--;
1208: dp->i_flag |= IN_CHANGE;
1.42 jdolecek 1209: VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
1.1 bouyer 1210: cache_purge(dvp);
1211: vput(dvp);
1212: dvp = NULL;
1213: /*
1214: * Truncate inode. The only stuff left
1215: * in the directory is "." and "..". The
1216: * "." reference is inconsequential since
1217: * we're quashing it. The ".." reference
1218: * has already been adjusted above. We've
1219: * removed the "." reference and the reference
1220: * in the parent directory, but there may be
1221: * other hard links so decrement by 2 and
1222: * worry about them later.
1223: */
1224: ip->i_e2fs_nlink -= 2;
1.77 pooka 1225: error = ext2fs_truncate(vp, (off_t)0, IO_SYNC, cnp->cn_cred);
1.1 bouyer 1226: cache_purge(ITOV(ip));
1227: out:
1.42 jdolecek 1228: VN_KNOTE(vp, NOTE_DELETE);
1.1 bouyer 1229: if (dvp)
1230: vput(dvp);
1231: vput(vp);
1232: return (error);
1233: }
1234:
1235: /*
1236: * symlink -- make a symbolic link
1237: */
1238: int
1.61 xtraeme 1239: ext2fs_symlink(void *v)
1.1 bouyer 1240: {
1241: struct vop_symlink_args /* {
1242: struct vnode *a_dvp;
1243: struct vnode **a_vpp;
1244: struct componentname *a_cnp;
1245: struct vattr *a_vap;
1246: char *a_target;
1247: } */ *ap = v;
1.55 mycroft 1248: struct vnode *vp, **vpp;
1249: struct inode *ip;
1250: int len, error;
1.1 bouyer 1251:
1.55 mycroft 1252: vpp = ap->a_vpp;
1.1 bouyer 1253: error = ext2fs_makeinode(IFLNK | ap->a_vap->va_mode, ap->a_dvp,
1254: vpp, ap->a_cnp);
1255: if (error)
1256: return (error);
1.42 jdolecek 1257: VN_KNOTE(ap->a_dvp, NOTE_WRITE);
1.1 bouyer 1258: vp = *vpp;
1259: len = strlen(ap->a_target);
1.55 mycroft 1260: ip = VTOI(vp);
1261: if (len < ip->i_ump->um_maxsymlinklen) {
1.44 fvdl 1262: memcpy((char *)ip->i_din.e2fs_din->e2di_shortlink, ap->a_target, len);
1.58 ws 1263: error = ext2fs_setsize(ip, len);
1264: if (error)
1265: goto bad;
1.1 bouyer 1266: ip->i_flag |= IN_CHANGE | IN_UPDATE;
1.60 kml 1267: uvm_vnp_setsize(vp, len);
1.1 bouyer 1268: } else
1269: error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0,
1.12 mjacob 1270: UIO_SYSSPACE, IO_NODELOCKED, ap->a_cnp->cn_cred,
1.56 skrll 1271: (size_t *)0, NULL);
1.58 ws 1272: bad:
1.34 assar 1273: if (error)
1274: vput(vp);
1.1 bouyer 1275: return (error);
1276: }
1277:
1278: /*
1279: * Return target name of a symbolic link
1280: */
1281: int
1.61 xtraeme 1282: ext2fs_readlink(void *v)
1.1 bouyer 1283: {
1284: struct vop_readlink_args /* {
1285: struct vnode *a_vp;
1286: struct uio *a_uio;
1.65 elad 1287: kauth_cred_t a_cred;
1.1 bouyer 1288: } */ *ap = v;
1.55 mycroft 1289: struct vnode *vp = ap->a_vp;
1290: struct inode *ip = VTOI(vp);
1291: struct ufsmount *ump = ip->i_ump;
1292: int isize;
1.1 bouyer 1293:
1.58 ws 1294: isize = ext2fs_size(ip);
1.55 mycroft 1295: if (isize < ump->um_maxsymlinklen ||
1296: (ump->um_maxsymlinklen == 0 && ip->i_e2fs_nblock == 0)) {
1.44 fvdl 1297: uiomove((char *)ip->i_din.e2fs_din->e2di_shortlink, isize, ap->a_uio);
1.1 bouyer 1298: return (0);
1299: }
1300: return (VOP_READ(vp, ap->a_uio, 0, ap->a_cred));
1301: }
1302:
1303: /*
1304: * Advisory record locking support
1305: */
1306: int
1.61 xtraeme 1307: ext2fs_advlock(void *v)
1.1 bouyer 1308: {
1309: struct vop_advlock_args /* {
1310: struct vnode *a_vp;
1.74 christos 1311: void * a_id;
1.1 bouyer 1312: int a_op;
1313: struct flock *a_fl;
1314: int a_flags;
1315: } */ *ap = v;
1.25 augustss 1316: struct inode *ip = VTOI(ap->a_vp);
1.1 bouyer 1317:
1.58 ws 1318: return lf_advlock(ap, &ip->i_lockf, ext2fs_size(ip));
1.1 bouyer 1319: }
1320:
1.63 yamt 1321: int
1322: ext2fs_fsync(void *v)
1323: {
1324: struct vop_fsync_args /* {
1325: struct vnode *a_vp;
1.65 elad 1326: kauth_cred_t a_cred;
1.63 yamt 1327: int a_flags;
1328: off_t offlo;
1329: off_t offhi;
1330: struct proc *a_p;
1331: } */ *ap = v;
1332: struct vnode *vp = ap->a_vp;
1333: int wait;
1334: int error;
1335:
1336: wait = (ap->a_flags & FSYNC_WAIT) != 0;
1.82 ! ad 1337:
! 1338: if (vp->v_type == VBLK)
! 1339: spec_fsync(v);
! 1340: else
! 1341: vflushbuf(vp, wait);
1.63 yamt 1342: if ((ap->a_flags & FSYNC_DATAONLY) != 0)
1343: error = 0;
1344: else
1345: error = ext2fs_update(vp, NULL, NULL, wait ? UPDATE_WAIT : 0);
1346:
1347: if (error == 0 && ap->a_flags & FSYNC_CACHE) {
1348: int l = 0;
1349: error = VOP_IOCTL(VTOI(vp)->i_devvp, DIOCCACHESYNC, &l, FWRITE,
1.76 pooka 1350: curlwp->l_cred);
1.63 yamt 1351: }
1352:
1353: return error;
1354: }
1355:
1.1 bouyer 1356: /*
1357: * Initialize the vnode associated with a new inode, handle aliased
1358: * vnodes.
1359: */
1360: int
1.61 xtraeme 1361: ext2fs_vinit(struct mount *mntp, int (**specops)(void *),
1362: int (**fifoops)(void *), struct vnode **vpp)
1.1 bouyer 1363: {
1.66 kardel 1364: struct timeval tv;
1.1 bouyer 1365: struct inode *ip;
1.80 ad 1366: struct vnode *vp;
1.1 bouyer 1367:
1368: vp = *vpp;
1369: ip = VTOI(vp);
1370: switch(vp->v_type = IFTOVT(ip->i_e2fs_mode)) {
1371: case VCHR:
1372: case VBLK:
1373: vp->v_op = specops;
1.80 ad 1374: spec_node_init(vp, fs2h32(ip->i_din.e2fs_din->e2di_rdev));
1.1 bouyer 1375: break;
1376: case VFIFO:
1377: vp->v_op = fifoops;
1378: break;
1379: case VNON:
1380: case VBAD:
1381: case VSOCK:
1382: case VLNK:
1383: case VDIR:
1384: case VREG:
1385: break;
1386: }
1387: if (ip->i_number == ROOTINO)
1.75 ad 1388: vp->v_vflag |= VV_ROOT;
1.1 bouyer 1389: /*
1390: * Initialize modrev times
1391: */
1.66 kardel 1392: getmicrouptime(&tv);
1393: SETHIGH(ip->i_modrev, tv.tv_sec);
1394: SETLOW(ip->i_modrev, tv.tv_usec * 4294);
1.1 bouyer 1395: *vpp = vp;
1396: return (0);
1397: }
1398:
1399: /*
1400: * Allocate a new inode.
1401: */
1402: int
1.61 xtraeme 1403: ext2fs_makeinode(int mode, struct vnode *dvp, struct vnode **vpp,
1404: struct componentname *cnp)
1.1 bouyer 1405: {
1.25 augustss 1406: struct inode *ip, *pdir;
1.1 bouyer 1407: struct vnode *tvp;
1.65 elad 1408: int error, ismember = 0;
1.1 bouyer 1409:
1410: pdir = VTOI(dvp);
1411: #ifdef DIAGNOSTIC
1412: if ((cnp->cn_flags & HASBUF) == 0)
1413: panic("ext2fs_makeinode: no name");
1414: #endif
1415: *vpp = NULL;
1416: if ((mode & IFMT) == 0)
1417: mode |= IFREG;
1418:
1.63 yamt 1419: if ((error = ext2fs_valloc(dvp, mode, cnp->cn_cred, &tvp)) != 0) {
1.29 thorpej 1420: PNBUF_PUT(cnp->cn_pnbuf);
1.1 bouyer 1421: vput(dvp);
1422: return (error);
1423: }
1424: ip = VTOI(tvp);
1425: ip->i_e2fs_gid = pdir->i_e2fs_gid;
1.65 elad 1426: ip->i_e2fs_uid = kauth_cred_geteuid(cnp->cn_cred);
1.1 bouyer 1427: ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
1428: ip->i_e2fs_mode = mode;
1429: tvp->v_type = IFTOVT(mode); /* Rest init'd in getnewvnode(). */
1430: ip->i_e2fs_nlink = 1;
1.65 elad 1431: if ((ip->i_e2fs_mode & ISGID) && (kauth_cred_ismember_gid(cnp->cn_cred,
1432: ip->i_e2fs_gid, &ismember) != 0 || !ismember) &&
1433: kauth_authorize_generic(cnp->cn_cred, KAUTH_GENERIC_ISSUSER, NULL))
1.1 bouyer 1434: ip->i_e2fs_mode &= ~ISGID;
1435:
1436: /*
1437: * Make sure inode goes to disk before directory entry.
1438: */
1.63 yamt 1439: if ((error = ext2fs_update(tvp, NULL, NULL, UPDATE_WAIT)) != 0)
1.1 bouyer 1440: goto bad;
1441: error = ext2fs_direnter(ip, dvp, cnp);
1442: if (error != 0)
1443: goto bad;
1444: if ((cnp->cn_flags & SAVESTART) == 0)
1.29 thorpej 1445: PNBUF_PUT(cnp->cn_pnbuf);
1.1 bouyer 1446: vput(dvp);
1447: *vpp = tvp;
1448: return (0);
1449:
1450: bad:
1451: /*
1452: * Write error occurred trying to update the inode
1453: * or the directory so must deallocate the inode.
1454: */
1.50 dsl 1455: tvp->v_type = VNON; /* Stop explosion if VBLK */
1.1 bouyer 1456: ip->i_e2fs_nlink = 0;
1457: ip->i_flag |= IN_CHANGE;
1458: vput(tvp);
1.50 dsl 1459: PNBUF_PUT(cnp->cn_pnbuf);
1460: vput(dvp);
1.1 bouyer 1461: return (error);
1462: }
1463:
1464: /*
1465: * Reclaim an inode so that it can be used for other purposes.
1466: */
1467: int
1.61 xtraeme 1468: ext2fs_reclaim(void *v)
1.1 bouyer 1469: {
1470: struct vop_reclaim_args /* {
1471: struct vnode *a_vp;
1472: } */ *ap = v;
1.25 augustss 1473: struct vnode *vp = ap->a_vp;
1.54 mycroft 1474: struct inode *ip = VTOI(vp);
1475: int error;
1.45 fvdl 1476:
1.76 pooka 1477: if ((error = ufs_reclaim(vp)) != 0)
1.54 mycroft 1478: return (error);
1.45 fvdl 1479: if (ip->i_din.e2fs_din != NULL)
1480: pool_put(&ext2fs_dinode_pool, ip->i_din.e2fs_din);
1.73 ad 1481: genfs_node_destroy(vp);
1.14 thorpej 1482: pool_put(&ext2fs_inode_pool, vp->v_data);
1.1 bouyer 1483: vp->v_data = NULL;
1484: return (0);
1485: }
1486:
1487: /* Global vfs data structures for ext2fs. */
1.61 xtraeme 1488: int (**ext2fs_vnodeop_p)(void *);
1.31 jdolecek 1489: const struct vnodeopv_entry_desc ext2fs_vnodeop_entries[] = {
1.1 bouyer 1490: { &vop_default_desc, vn_default_error },
1.8 fvdl 1491: { &vop_lookup_desc, ext2fs_lookup }, /* lookup */
1492: { &vop_create_desc, ext2fs_create }, /* create */
1.1 bouyer 1493: { &vop_mknod_desc, ext2fs_mknod }, /* mknod */
1494: { &vop_open_desc, ext2fs_open }, /* open */
1495: { &vop_close_desc, ufs_close }, /* close */
1.8 fvdl 1496: { &vop_access_desc, ext2fs_access }, /* access */
1497: { &vop_getattr_desc, ext2fs_getattr }, /* getattr */
1498: { &vop_setattr_desc, ext2fs_setattr }, /* setattr */
1.1 bouyer 1499: { &vop_read_desc, ext2fs_read }, /* read */
1500: { &vop_write_desc, ext2fs_write }, /* write */
1501: { &vop_ioctl_desc, ufs_ioctl }, /* ioctl */
1.21 wrstuden 1502: { &vop_fcntl_desc, ufs_fcntl }, /* fcntl */
1.1 bouyer 1503: { &vop_poll_desc, ufs_poll }, /* poll */
1.42 jdolecek 1504: { &vop_kqfilter_desc, genfs_kqfilter }, /* kqfilter */
1.8 fvdl 1505: { &vop_revoke_desc, ufs_revoke }, /* revoke */
1.1 bouyer 1506: { &vop_mmap_desc, ufs_mmap }, /* mmap */
1507: { &vop_fsync_desc, ext2fs_fsync }, /* fsync */
1508: { &vop_seek_desc, ufs_seek }, /* seek */
1.8 fvdl 1509: { &vop_remove_desc, ext2fs_remove }, /* remove */
1.1 bouyer 1510: { &vop_link_desc, ext2fs_link }, /* link */
1.8 fvdl 1511: { &vop_rename_desc, ext2fs_rename }, /* rename */
1.1 bouyer 1512: { &vop_mkdir_desc, ext2fs_mkdir }, /* mkdir */
1513: { &vop_rmdir_desc, ext2fs_rmdir }, /* rmdir */
1.8 fvdl 1514: { &vop_symlink_desc, ext2fs_symlink }, /* symlink */
1515: { &vop_readdir_desc, ext2fs_readdir }, /* readdir */
1516: { &vop_readlink_desc, ext2fs_readlink }, /* readlink */
1.1 bouyer 1517: { &vop_abortop_desc, ufs_abortop }, /* abortop */
1.8 fvdl 1518: { &vop_inactive_desc, ext2fs_inactive }, /* inactive */
1519: { &vop_reclaim_desc, ext2fs_reclaim }, /* reclaim */
1.1 bouyer 1520: { &vop_lock_desc, ufs_lock }, /* lock */
1521: { &vop_unlock_desc, ufs_unlock }, /* unlock */
1522: { &vop_bmap_desc, ext2fs_bmap }, /* bmap */
1.8 fvdl 1523: { &vop_strategy_desc, ufs_strategy }, /* strategy */
1.1 bouyer 1524: { &vop_print_desc, ufs_print }, /* print */
1.8 fvdl 1525: { &vop_islocked_desc, ufs_islocked }, /* islocked */
1526: { &vop_pathconf_desc, ufs_pathconf }, /* pathconf */
1527: { &vop_advlock_desc, ext2fs_advlock }, /* advlock */
1.1 bouyer 1528: { &vop_bwrite_desc, vn_bwrite }, /* bwrite */
1.30 chs 1529: { &vop_getpages_desc, genfs_getpages }, /* getpages */
1530: { &vop_putpages_desc, genfs_putpages }, /* putpages */
1531: { NULL, NULL }
1.1 bouyer 1532: };
1.31 jdolecek 1533: const struct vnodeopv_desc ext2fs_vnodeop_opv_desc =
1.1 bouyer 1534: { &ext2fs_vnodeop_p, ext2fs_vnodeop_entries };
1535:
1.61 xtraeme 1536: int (**ext2fs_specop_p)(void *);
1.31 jdolecek 1537: const struct vnodeopv_entry_desc ext2fs_specop_entries[] = {
1.1 bouyer 1538: { &vop_default_desc, vn_default_error },
1539: { &vop_lookup_desc, spec_lookup }, /* lookup */
1540: { &vop_create_desc, spec_create }, /* create */
1541: { &vop_mknod_desc, spec_mknod }, /* mknod */
1542: { &vop_open_desc, spec_open }, /* open */
1543: { &vop_close_desc, ufsspec_close }, /* close */
1.8 fvdl 1544: { &vop_access_desc, ext2fs_access }, /* access */
1545: { &vop_getattr_desc, ext2fs_getattr }, /* getattr */
1546: { &vop_setattr_desc, ext2fs_setattr }, /* setattr */
1.1 bouyer 1547: { &vop_read_desc, ufsspec_read }, /* read */
1548: { &vop_write_desc, ufsspec_write }, /* write */
1549: { &vop_ioctl_desc, spec_ioctl }, /* ioctl */
1.21 wrstuden 1550: { &vop_fcntl_desc, ufs_fcntl }, /* fcntl */
1.1 bouyer 1551: { &vop_poll_desc, spec_poll }, /* poll */
1.42 jdolecek 1552: { &vop_kqfilter_desc, spec_kqfilter }, /* kqfilter */
1.8 fvdl 1553: { &vop_revoke_desc, spec_revoke }, /* revoke */
1.1 bouyer 1554: { &vop_mmap_desc, spec_mmap }, /* mmap */
1555: { &vop_fsync_desc, ext2fs_fsync }, /* fsync */
1556: { &vop_seek_desc, spec_seek }, /* seek */
1557: { &vop_remove_desc, spec_remove }, /* remove */
1558: { &vop_link_desc, spec_link }, /* link */
1559: { &vop_rename_desc, spec_rename }, /* rename */
1560: { &vop_mkdir_desc, spec_mkdir }, /* mkdir */
1561: { &vop_rmdir_desc, spec_rmdir }, /* rmdir */
1.8 fvdl 1562: { &vop_symlink_desc, spec_symlink }, /* symlink */
1563: { &vop_readdir_desc, spec_readdir }, /* readdir */
1564: { &vop_readlink_desc, spec_readlink }, /* readlink */
1565: { &vop_abortop_desc, spec_abortop }, /* abortop */
1566: { &vop_inactive_desc, ext2fs_inactive }, /* inactive */
1567: { &vop_reclaim_desc, ext2fs_reclaim }, /* reclaim */
1.1 bouyer 1568: { &vop_lock_desc, ufs_lock }, /* lock */
1569: { &vop_unlock_desc, ufs_unlock }, /* unlock */
1570: { &vop_bmap_desc, spec_bmap }, /* bmap */
1.8 fvdl 1571: { &vop_strategy_desc, spec_strategy }, /* strategy */
1.1 bouyer 1572: { &vop_print_desc, ufs_print }, /* print */
1.8 fvdl 1573: { &vop_islocked_desc, ufs_islocked }, /* islocked */
1574: { &vop_pathconf_desc, spec_pathconf }, /* pathconf */
1575: { &vop_advlock_desc, spec_advlock }, /* advlock */
1.1 bouyer 1576: { &vop_bwrite_desc, vn_bwrite }, /* bwrite */
1.35 chs 1577: { &vop_getpages_desc, spec_getpages }, /* getpages */
1578: { &vop_putpages_desc, spec_putpages }, /* putpages */
1.30 chs 1579: { NULL, NULL }
1.1 bouyer 1580: };
1.31 jdolecek 1581: const struct vnodeopv_desc ext2fs_specop_opv_desc =
1.1 bouyer 1582: { &ext2fs_specop_p, ext2fs_specop_entries };
1583:
1.61 xtraeme 1584: int (**ext2fs_fifoop_p)(void *);
1.31 jdolecek 1585: const struct vnodeopv_entry_desc ext2fs_fifoop_entries[] = {
1.1 bouyer 1586: { &vop_default_desc, vn_default_error },
1587: { &vop_lookup_desc, fifo_lookup }, /* lookup */
1588: { &vop_create_desc, fifo_create }, /* create */
1589: { &vop_mknod_desc, fifo_mknod }, /* mknod */
1590: { &vop_open_desc, fifo_open }, /* open */
1591: { &vop_close_desc, ufsfifo_close }, /* close */
1.8 fvdl 1592: { &vop_access_desc, ext2fs_access }, /* access */
1593: { &vop_getattr_desc, ext2fs_getattr }, /* getattr */
1594: { &vop_setattr_desc, ext2fs_setattr }, /* setattr */
1.1 bouyer 1595: { &vop_read_desc, ufsfifo_read }, /* read */
1596: { &vop_write_desc, ufsfifo_write }, /* write */
1597: { &vop_ioctl_desc, fifo_ioctl }, /* ioctl */
1.21 wrstuden 1598: { &vop_fcntl_desc, ufs_fcntl }, /* fcntl */
1.1 bouyer 1599: { &vop_poll_desc, fifo_poll }, /* poll */
1.42 jdolecek 1600: { &vop_kqfilter_desc, fifo_kqfilter }, /* kqfilter */
1.8 fvdl 1601: { &vop_revoke_desc, fifo_revoke }, /* revoke */
1.1 bouyer 1602: { &vop_mmap_desc, fifo_mmap }, /* mmap */
1603: { &vop_fsync_desc, ext2fs_fsync }, /* fsync */
1604: { &vop_seek_desc, fifo_seek }, /* seek */
1605: { &vop_remove_desc, fifo_remove }, /* remove */
1606: { &vop_link_desc, fifo_link }, /* link */
1607: { &vop_rename_desc, fifo_rename }, /* rename */
1608: { &vop_mkdir_desc, fifo_mkdir }, /* mkdir */
1609: { &vop_rmdir_desc, fifo_rmdir }, /* rmdir */
1.8 fvdl 1610: { &vop_symlink_desc, fifo_symlink }, /* symlink */
1611: { &vop_readdir_desc, fifo_readdir }, /* readdir */
1612: { &vop_readlink_desc, fifo_readlink }, /* readlink */
1613: { &vop_abortop_desc, fifo_abortop }, /* abortop */
1614: { &vop_inactive_desc, ext2fs_inactive }, /* inactive */
1615: { &vop_reclaim_desc, ext2fs_reclaim }, /* reclaim */
1.1 bouyer 1616: { &vop_lock_desc, ufs_lock }, /* lock */
1617: { &vop_unlock_desc, ufs_unlock }, /* unlock */
1618: { &vop_bmap_desc, fifo_bmap }, /* bmap */
1.8 fvdl 1619: { &vop_strategy_desc, fifo_strategy }, /* strategy */
1.1 bouyer 1620: { &vop_print_desc, ufs_print }, /* print */
1.8 fvdl 1621: { &vop_islocked_desc, ufs_islocked }, /* islocked */
1622: { &vop_pathconf_desc, fifo_pathconf }, /* pathconf */
1623: { &vop_advlock_desc, fifo_advlock }, /* advlock */
1.1 bouyer 1624: { &vop_bwrite_desc, vn_bwrite }, /* bwrite */
1.38 sommerfe 1625: { &vop_putpages_desc, fifo_putpages }, /* putpages */
1.30 chs 1626: { NULL, NULL }
1.1 bouyer 1627: };
1.31 jdolecek 1628: const struct vnodeopv_desc ext2fs_fifoop_opv_desc =
1.1 bouyer 1629: { &ext2fs_fifoop_p, ext2fs_fifoop_entries };
CVSweb <webmaster@jp.NetBSD.org>