efs_vnops.c revision 1.8 1 /* $NetBSD: efs_vnops.c,v 1.8 2007/09/08 18:17:59 rumble Exp $ */
2
3 /*
4 * Copyright (c) 2006 Stephen M. Rumble <rumble (at) ephemeral.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #include <sys/cdefs.h>
20 __KERNEL_RCSID(0, "$NetBSD: efs_vnops.c,v 1.8 2007/09/08 18:17:59 rumble Exp $");
21
22 #include <sys/param.h>
23 #include <sys/systm.h>
24 #include <sys/proc.h>
25 #include <sys/kernel.h>
26 #include <sys/vnode.h>
27 #include <sys/mount.h>
28 #include <sys/malloc.h>
29 #include <sys/namei.h>
30 #include <sys/dirent.h>
31 #include <sys/lockf.h>
32 #include <sys/unistd.h>
33
34 #include <miscfs/genfs/genfs.h>
35 #include <miscfs/genfs/genfs_node.h>
36
37 #include <fs/efs/efs.h>
38 #include <fs/efs/efs_sb.h>
39 #include <fs/efs/efs_dir.h>
40 #include <fs/efs/efs_genfs.h>
41 #include <fs/efs/efs_mount.h>
42 #include <fs/efs/efs_extent.h>
43 #include <fs/efs/efs_dinode.h>
44 #include <fs/efs/efs_inode.h>
45 #include <fs/efs/efs_subr.h>
46 #include <fs/efs/efs_ihash.h>
47
48 MALLOC_DECLARE(M_EFSTMP);
49
50 /*
51 * Lookup a pathname component in the given directory.
52 *
53 * Returns 0 on success.
54 */
55 static int
56 efs_lookup(void *v)
57 {
58 struct vop_lookup_args /* {
59 struct vnode *a_dvp;
60 struct vnode **a_vpp;
61 struct componentname *a_cnp;
62 } */ *ap = v;
63 struct componentname *cnp = ap->a_cnp;
64 struct vnode *vp;
65 ino_t ino;
66 int err, nameiop = cnp->cn_nameiop;
67
68 /* ensure that the directory can be accessed first */
69 err = VOP_ACCESS(ap->a_dvp, VEXEC, cnp->cn_cred, cnp->cn_lwp);
70 if (err)
71 return (err);
72
73 err = cache_lookup(ap->a_dvp, ap->a_vpp, cnp);
74 if (err != -1)
75 return (err);
76
77 /*
78 * Handle the three lookup types: '.', '..', and everything else.
79 */
80 if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {
81 vref(ap->a_dvp);
82 *ap->a_vpp = ap->a_dvp;
83 } else if (cnp->cn_flags & ISDOTDOT) {
84 err = efs_inode_lookup(VFSTOEFS(ap->a_dvp->v_mount),
85 EFS_VTOI(ap->a_dvp), ap->a_cnp, &ino);
86 if (err)
87 return (err);
88
89 VOP_UNLOCK(ap->a_dvp, 0); /* preserve lock order */
90
91 err = VFS_VGET(ap->a_dvp->v_mount, ino, &vp);
92 if (err) {
93 vn_lock(ap->a_dvp, LK_EXCLUSIVE | LK_RETRY);
94 return (err);
95 }
96 vn_lock(ap->a_dvp, LK_EXCLUSIVE | LK_RETRY);
97 *ap->a_vpp = vp;
98 } else {
99 err = efs_inode_lookup(VFSTOEFS(ap->a_dvp->v_mount),
100 EFS_VTOI(ap->a_dvp), ap->a_cnp, &ino);
101 if (err) {
102 if (err == ENOENT && (cnp->cn_flags & MAKEENTRY) &&
103 nameiop != CREATE)
104 cache_enter(ap->a_dvp, NULL, cnp);
105 if (err == ENOENT && (nameiop == CREATE ||
106 nameiop == RENAME)) {
107 err = VOP_ACCESS(ap->a_dvp, VWRITE,
108 cnp->cn_cred, cnp->cn_lwp);
109 if (err)
110 return (err);
111 cnp->cn_flags |= SAVENAME;
112 return (EJUSTRETURN);
113 }
114 return (err);
115 }
116 err = VFS_VGET(ap->a_dvp->v_mount, ino, &vp);
117 if (err)
118 return (err);
119 *ap->a_vpp = vp;
120 }
121
122 if (cnp->cn_flags & MAKEENTRY)
123 cache_enter(ap->a_dvp, *ap->a_vpp, cnp);
124
125 return (0);
126 }
127
128 /*
129 * Determine the accessiblity of a file based on the permissions allowed by the
130 * specified credentials.
131 *
132 * Returns 0 on success.
133 */
134 static int
135 efs_access(void *v)
136 {
137 struct vop_access_args /* {
138 const struct vnodeop_desc *a_desc;
139 struct vnode *a_vp;
140 int a_mode;
141 struct ucred *a_cred;
142 struct lwp *a_l;
143 } */ *ap = v;
144 struct vnode *vp = ap->a_vp;
145 struct efs_inode *eip = EFS_VTOI(vp);
146
147 if ((ap->a_mode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY))
148 return (EROFS);
149
150 return (vaccess(vp->v_type, eip->ei_mode, eip->ei_uid, eip->ei_gid,
151 ap->a_mode, ap->a_cred));
152 }
153
154 /*
155 * Get specific vnode attributes on a file. See vattr(9).
156 *
157 * Returns 0 on success.
158 */
159 static int
160 efs_getattr(void *v)
161 {
162 struct vop_getattr_args /* {
163 const struct vnodeop_desc *a_desc;
164 struct vnode *a_vp;
165 struct vattr *a_vap;
166 struct ucred *a_cred;
167 struct lwp *a_l;
168 } */ *ap = v;
169
170 struct vattr *vap = ap->a_vap;
171 struct efs_inode *eip = EFS_VTOI(ap->a_vp);
172
173 vattr_null(ap->a_vap);
174 vap->va_type = ap->a_vp->v_type;
175 vap->va_mode = eip->ei_mode;
176 vap->va_nlink = eip->ei_nlink;
177 vap->va_uid = eip->ei_uid;
178 vap->va_gid = eip->ei_gid;
179 vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid;
180 vap->va_fileid = eip->ei_number;
181 vap->va_size = eip->ei_size;
182
183 if (ap->a_vp->v_type == VBLK)
184 vap->va_blocksize = BLKDEV_IOSIZE;
185 else if (ap->a_vp->v_type == VCHR)
186 vap->va_blocksize = MAXBSIZE;
187 else
188 vap->va_blocksize = EFS_BB_SIZE;
189
190 vap->va_atime.tv_sec = eip->ei_atime;
191 vap->va_mtime.tv_sec = eip->ei_mtime;
192 vap->va_ctime.tv_sec = eip->ei_ctime;
193 /* vap->va_birthtime = */
194 vap->va_gen = eip->ei_gen;
195 vap->va_flags = ap->a_vp->v_flag;
196
197 if (ap->a_vp->v_type == VBLK || ap->a_vp->v_type == VCHR) {
198 uint32_t dmaj, dmin;
199
200 if (be16toh(eip->ei_di.di_odev) != EFS_DINODE_ODEV_INVALID) {
201 dmaj = EFS_DINODE_ODEV_MAJ(be16toh(eip->ei_di.di_odev));
202 dmin = EFS_DINODE_ODEV_MIN(be16toh(eip->ei_di.di_odev));
203 } else {
204 dmaj = EFS_DINODE_NDEV_MAJ(be32toh(eip->ei_di.di_ndev));
205 dmin = EFS_DINODE_NDEV_MIN(be32toh(eip->ei_di.di_ndev));
206 }
207
208 vap->va_rdev = makedev(dmaj, dmin);
209 }
210
211 vap->va_bytes = eip->ei_size;
212 /* vap->va_filerev = */
213 /* vap->va_vaflags = */
214
215 return (0);
216 }
217
218 /*
219 * Read a file.
220 *
221 * Returns 0 on success.
222 */
223 static int
224 efs_read(void *v)
225 {
226 struct vop_read_args /* {
227 const struct vnodeop_desc *a_desc;
228 struct vnode *a_vp;
229 struct uio *a_uio;
230 int a_ioflag;
231 struct ucred *a_cred;
232 } */ *ap = v;
233 struct efs_extent ex;
234 struct efs_extent_iterator exi;
235 void *win;
236 struct uio *uio = ap->a_uio;
237 struct efs_inode *eip = EFS_VTOI(ap->a_vp);
238 off_t start;
239 vsize_t len;
240 int err, ret, flags;
241 const int advice = IO_ADV_DECODE(ap->a_ioflag);
242
243 if (ap->a_vp->v_type == VDIR)
244 return (EISDIR);
245
246 if (ap->a_vp->v_type != VREG)
247 return (EINVAL);
248
249 efs_extent_iterator_init(&exi, eip, uio->uio_offset);
250 ret = efs_extent_iterator_next(&exi, &ex);
251 while (ret == 0) {
252 if (uio->uio_offset < 0 || uio->uio_offset >= eip->ei_size ||
253 uio->uio_resid == 0)
254 break;
255
256 start = ex.ex_offset * EFS_BB_SIZE;
257 len = ex.ex_length * EFS_BB_SIZE;
258
259 if (!(uio->uio_offset >= start &&
260 uio->uio_offset < (start + len))) {
261 ret = efs_extent_iterator_next(&exi, &ex);
262 continue;
263 }
264
265 start = uio->uio_offset - start;
266
267 len = MIN(len - start, uio->uio_resid);
268 len = MIN(len, eip->ei_size - uio->uio_offset);
269
270 win = ubc_alloc(&ap->a_vp->v_uobj, uio->uio_offset,
271 &len, advice, UBC_READ);
272
273 flags = UBC_WANT_UNMAP(ap->a_vp) ? UBC_UNMAP : 0;
274
275 err = uiomove(win, len, uio);
276 ubc_release(win, flags);
277 if (err) {
278 EFS_DPRINTF(("efs_read: uiomove error %d\n",
279 err));
280 return (err);
281 }
282 }
283
284 return ((ret == -1) ? 0 : ret);
285 }
286
287 static int
288 efs_readdir(void *v)
289 {
290 struct vop_readdir_args /* {
291 const struct vnodeop_desc *a_desc;
292 struct vnode *a_vp;
293 struct uio *a_uio;
294 struct ucred *a_cred;
295 int *a_eofflag;
296 off_t **a_cookies;
297 int *a_ncookies;
298 } */ *ap = v;
299 struct dirent d;
300 struct efs_dinode edi;
301 struct efs_extent ex;
302 struct efs_extent_iterator exi;
303 struct buf *bp;
304 struct efs_dirent *de;
305 struct efs_dirblk *db;
306 struct uio *uio = ap->a_uio;
307 struct efs_inode *ei = EFS_VTOI(ap->a_vp);
308 off_t *cookies = NULL;
309 off_t offset;
310 int i, j, err, ret, s, slot, ncookies, maxcookies = 0;
311
312 if (ap->a_vp->v_type != VDIR)
313 return (ENOTDIR);
314
315 if (ap->a_eofflag != NULL)
316 *ap->a_eofflag = false;
317
318 if (ap->a_ncookies != NULL) {
319 ncookies = 0;
320 maxcookies =
321 uio->uio_resid / _DIRENT_MINSIZE((struct dirent *)0);
322 cookies = malloc(maxcookies * sizeof(off_t), M_TEMP, M_WAITOK);
323 }
324
325 offset = 0;
326 efs_extent_iterator_init(&exi, ei, 0);
327 while ((ret = efs_extent_iterator_next(&exi, &ex)) == 0) {
328 for (i = 0; i < ex.ex_length; i++) {
329 err = efs_bread(VFSTOEFS(ap->a_vp->v_mount),
330 ex.ex_bn + i, NULL, &bp);
331 if (err) {
332 brelse(bp);
333 goto exit_err;
334 }
335
336 db = (struct efs_dirblk *)bp->b_data;
337
338 if (be16toh(db->db_magic) != EFS_DIRBLK_MAGIC) {
339 printf("efs_readdir: bad dirblk\n");
340 brelse(bp);
341 continue;
342 }
343
344 for (j = 0; j < db->db_slots; j++) {
345 slot = EFS_DIRENT_OFF_EXPND(db->db_space[j]);
346 if (slot == EFS_DIRBLK_SLOT_FREE)
347 continue;
348
349 if (!EFS_DIRENT_OFF_VALID(slot)) {
350 printf("efs_readdir: bad dirent\n");
351 continue;
352 }
353
354 de = EFS_DIRBLK_TO_DIRENT(db, slot);
355 s = _DIRENT_RECLEN(&d, de->de_namelen);
356
357 if (offset < uio->uio_offset) {
358 offset += s;
359 continue;
360 }
361
362 /* XXX - latter shouldn't happen, right? */
363 if (s > uio->uio_resid ||
364 offset > uio->uio_offset) {
365 brelse(bp);
366 goto exit_ok;
367 }
368
369 /* de_namelen is uint8_t, d.d_name is 512b */
370 KASSERT(sizeof(d.d_name) - de->de_namelen > 0);
371 d.d_fileno = be32toh(de->de_inumber);
372 d.d_reclen = s;
373 d.d_namlen = de->de_namelen;
374 memcpy(d.d_name, de->de_name,
375 de->de_namelen);
376 d.d_name[de->de_namelen] = '\0';
377
378 /* look up inode to get type */
379 err = efs_read_inode(
380 VFSTOEFS(ap->a_vp->v_mount),
381 d.d_fileno, NULL, &edi);
382 if (err) {
383 brelse(bp);
384 goto exit_err;
385 }
386
387 switch (be16toh(edi.di_mode) & EFS_IFMT) {
388 case EFS_IFIFO:
389 d.d_type = DT_FIFO;
390 break;
391 case EFS_IFCHR:
392 d.d_type = DT_CHR;
393 break;
394 case EFS_IFDIR:
395 d.d_type = DT_DIR;
396 break;
397 case EFS_IFBLK:
398 d.d_type = DT_BLK;
399 break;
400 case EFS_IFREG:
401 d.d_type = DT_REG;
402 break;
403 case EFS_IFLNK:
404 d.d_type = DT_LNK;
405 break;
406 case EFS_IFSOCK:
407 d.d_type = DT_SOCK;
408 break;
409 default:
410 d.d_type = DT_UNKNOWN;
411 break;
412 }
413
414 err = uiomove(&d, s, uio);
415 if (err) {
416 brelse(bp);
417 goto exit_err;
418 }
419
420 offset += s;
421
422 if (cookies != NULL && maxcookies != 0) {
423 cookies[ncookies++] = offset;
424 if (ncookies == maxcookies) {
425 brelse(bp);
426 goto exit_ok;
427 }
428 }
429 }
430
431 brelse(bp);
432 }
433 }
434
435 if (ret != -1) {
436 err = ret;
437 goto exit_err;
438 }
439
440 if (ap->a_eofflag != NULL)
441 *ap->a_eofflag = true;
442
443 exit_ok:
444 if (cookies != NULL) {
445 *ap->a_cookies = cookies;
446 *ap->a_ncookies = ncookies;
447 }
448
449 uio->uio_offset = offset;
450
451 return (0);
452
453 exit_err:
454 if (cookies != NULL)
455 free(cookies, M_TEMP);
456
457 return (err);
458 }
459
460 static int
461 efs_readlink(void *v)
462 {
463 struct vop_readlink_args /* {
464 const struct vnodeop_desc *a_desc;
465 struct vnode *a_vp;
466 struct uio *a_uio;
467 struct ucred *a_cred;
468 } */ *ap = v;
469 struct uio *uio = ap->a_uio;
470 struct efs_inode *eip = EFS_VTOI(ap->a_vp);
471 char *buf;
472 size_t len;
473 int err, i;
474
475 if ((eip->ei_mode & EFS_IFMT) != EFS_IFLNK)
476 return (EINVAL);
477
478 if (uio->uio_resid < 1)
479 return (EINVAL);
480
481 buf = malloc(eip->ei_size + 1, M_EFSTMP, M_ZERO | M_WAITOK);
482
483 /* symlinks are either inlined in the inode, or in extents */
484 if (eip->ei_numextents == 0) {
485 if (eip->ei_size > sizeof(eip->ei_di.di_symlink)) {
486 EFS_DPRINTF(("efs_readlink: too big for inline\n"));
487 free(buf, M_EFSTMP);
488 return (EBADF);
489 }
490
491 memcpy(buf, eip->ei_di.di_symlink, eip->ei_size);
492 len = MIN(uio->uio_resid, eip->ei_size + 1);
493 } else {
494 struct efs_extent_iterator exi;
495 struct efs_extent ex;
496 struct buf *bp;
497 int resid, off, ret;
498
499 off = 0;
500 resid = eip->ei_size;
501
502 efs_extent_iterator_init(&exi, eip, 0);
503 while ((ret = efs_extent_iterator_next(&exi, &ex)) == 0) {
504 for (i = 0; i < ex.ex_length; i++) {
505 err = efs_bread(VFSTOEFS(ap->a_vp->v_mount),
506 ex.ex_bn + i, NULL, &bp);
507 if (err) {
508 brelse(bp);
509 free(buf, M_EFSTMP);
510 return (err);
511 }
512
513 len = MIN(resid, bp->b_bcount);
514 memcpy(buf + off, bp->b_data, len);
515 brelse(bp);
516
517 off += len;
518 resid -= len;
519
520 if (resid == 0)
521 break;
522 }
523
524 if (resid == 0)
525 break;
526 }
527
528 if (ret != 0 && ret != -1) {
529 free(buf, M_EFSTMP);
530 return (ret);
531 }
532
533 len = off + 1;
534 }
535
536 KASSERT(len >= 1 && len <= (eip->ei_size + 1));
537 buf[len - 1] = '\0';
538 err = uiomove(buf, len, uio);
539 free(buf, M_EFSTMP);
540
541 return (err);
542 }
543
544 /*
545 * Release an inactive vnode. The vnode _must_ be unlocked on return.
546 * It is either nolonger being used by the kernel, or an unmount is being
547 * forced.
548 *
549 * Returns 0 on success.
550 */
551 static int
552 efs_inactive(void *v)
553 {
554 struct vop_inactive_args /* {
555 const struct vnodeop_desc *a_desc;
556 struct vnode *a_vp;
557 struct lwp *a_l;
558 } */ *ap = v;
559 struct efs_inode *eip = EFS_VTOI(ap->a_vp);
560
561 VOP_UNLOCK(ap->a_vp, 0);
562
563 if (eip->ei_mode == 0)
564 vrecycle(ap->a_vp, NULL, ap->a_l);
565
566 return (0);
567 }
568
569 static int
570 efs_reclaim(void *v)
571 {
572 struct vop_reclaim_args /* {
573 const struct vnodeop_desc *a_desc;
574 struct vnode *a_vp;
575 struct lwp *a_l;
576 } */ *ap = v;
577 struct vnode *vp = ap->a_vp;
578
579 efs_ihashrem(EFS_VTOI(vp));
580 cache_purge(vp);
581 genfs_node_destroy(vp);
582 pool_put(&efs_inode_pool, vp->v_data);
583 vp->v_data = NULL;
584
585 return (0);
586 }
587
588 static int
589 efs_bmap(void *v)
590 {
591 struct vop_bmap_args /* {
592 const struct vnodeop_desc *a_desc;
593 struct vnode *a_vp;
594 daddr_t a_bn;
595 struct vnode **a_vpp;
596 daddr_t *a_bnp;
597 int *a_runp;
598 } */ *ap = v;
599 struct efs_extent ex;
600 struct efs_extent_iterator exi;
601 struct vnode *vp = ap->a_vp;
602 struct efs_inode *eip = EFS_VTOI(vp);
603 bool found;
604 int ret;
605
606 if (ap->a_vpp != NULL)
607 *ap->a_vpp = VFSTOEFS(vp->v_mount)->em_devvp;
608
609 found = false;
610 efs_extent_iterator_init(&exi, eip, ap->a_bn * EFS_BB_SIZE);
611 while ((ret = efs_extent_iterator_next(&exi, &ex)) == 0) {
612 if (ap->a_bn >= ex.ex_offset &&
613 ap->a_bn < (ex.ex_offset + ex.ex_length)) {
614 found = true;
615 break;
616 }
617 }
618
619 KASSERT(!found || (found && ret == 0));
620
621 if (!found) {
622 EFS_DPRINTF(("efs_bmap: ap->a_bn not in extents\n"));
623 return ((ret == -1) ? EIO : ret);
624 }
625
626 if (ex.ex_magic != EFS_EXTENT_MAGIC) {
627 EFS_DPRINTF(("efs_bmap: exn.ex_magic != EFS_EXTENT_MAGIC\n"));
628 return (EIO);
629 }
630
631 if (ap->a_bn < ex.ex_offset) {
632 EFS_DPRINTF(("efs_bmap: ap->a_bn < exn.ex_offset\n"));
633 return (EIO);
634 }
635
636 KASSERT(ap->a_bn >= ex.ex_offset);
637 KASSERT(ex.ex_length > ap->a_bn - ex.ex_offset);
638
639 *ap->a_bnp = ex.ex_bn + (ap->a_bn - ex.ex_offset);
640 if (ap->a_runp != NULL)
641 *ap->a_runp = ex.ex_length - (ap->a_bn - ex.ex_offset) - 1;
642
643 return (0);
644 }
645
646 static int
647 efs_strategy(void *v)
648 {
649 struct vop_strategy_args /* {
650 const struct vnodeop_desc *a_desc;
651 struct vnode *a_vp;
652 struct buf *a_bp;
653 } */ *ap = v;
654 struct vnode *vp = ap->a_vp;
655 struct buf *bp = ap->a_bp;
656 int error;
657
658 if (vp == NULL) {
659 bp->b_error = EIO;
660 biodone(bp);
661 return (EIO);
662 }
663
664 if (bp->b_blkno == bp->b_lblkno) {
665 error = VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL);
666 if (error) {
667 bp->b_error = error;
668 biodone(bp);
669 return (error);
670 }
671 if ((long)bp->b_blkno == -1)
672 clrbuf(bp);
673 }
674
675 if ((long)bp->b_blkno == -1) {
676 biodone(bp);
677 return (0);
678 }
679
680 return (VOP_STRATEGY(VFSTOEFS(vp->v_mount)->em_devvp, bp));
681 }
682
683 static int
684 efs_print(void *v)
685 {
686 struct vop_print_args /* {
687 const struct vnodeop_desc *a_desc;
688 struct vnode *a_vp;
689 } */ *ap = v;
690 struct efs_inode *eip = EFS_VTOI(ap->a_vp);
691
692 printf( "efs_inode (ino %lu):\n"
693 " ei_mode: %07o\n"
694 " ei_nlink: %d\n"
695 " ei_uid: %d\n"
696 " ei_gid: %d\n"
697 " ei_size: %d\n"
698 " ei_atime: %d\n"
699 " ei_mtime: %d\n"
700 " ei_ctime: %d\n"
701 " ei_gen: %d\n"
702 " ei_numextents: %d\n"
703 " ei_version: %d\n",
704 (unsigned long)eip->ei_number,
705 (unsigned int)eip->ei_mode,
706 eip->ei_nlink,
707 eip->ei_uid,
708 eip->ei_gid,
709 eip->ei_size,
710 (int32_t)eip->ei_atime,
711 (int32_t)eip->ei_mtime,
712 (int32_t)eip->ei_ctime,
713 eip->ei_gen,
714 eip->ei_numextents,
715 eip->ei_version);
716
717 return (0);
718 }
719
720 static int
721 efs_pathconf(void *v)
722 {
723 struct vop_pathconf_args /* {
724 const struct vnodeop_desc *a_desc;
725 struct vnode *a_vp;
726 int a_name;
727 register_t *a_retval;
728 } */ *ap = v;
729
730 /* IRIX 4 values */
731 switch (ap->a_name) {
732 case _PC_LINK_MAX:
733 *ap->a_retval = 30000;
734 break;
735 case _PC_NAME_MAX:
736 *ap->a_retval = 255;
737 break;
738 case _PC_PATH_MAX:
739 *ap->a_retval = 1024;
740 break;
741 case _PC_NO_TRUNC:
742 *ap->a_retval = 1;
743 break;
744 case _PC_CHOWN_RESTRICTED:
745 *ap->a_retval = 1;
746 break;
747 case _PC_SYNC_IO:
748 *ap->a_retval = 1;
749 break;
750 case _PC_FILESIZEBITS:
751 *ap->a_retval = 32;
752 break;
753 default:
754 return (EINVAL);
755 }
756
757 return (0);
758 }
759
760 static int
761 efs_advlock(void *v)
762 {
763 struct vop_advlock_args /* {
764 const struct vnodeop_desc *a_desc;
765 struct vnode *a_vp;
766 void *a_id;
767 int a_op;
768 struct flock *a_fl;
769 int a_flags;
770 } */ *ap = v;
771 struct efs_inode *eip = EFS_VTOI(ap->a_vp);
772
773 return (lf_advlock(ap, &eip->ei_lockf, eip->ei_size));
774 }
775
776 /* Global vfs data structures for efs */
777 int (**efs_vnodeop_p)(void *);
778 const struct vnodeopv_entry_desc efs_vnodeop_entries[] = {
779 { &vop_default_desc, vn_default_error}, /* error handler */
780 { &vop_lookup_desc, efs_lookup }, /* lookup */
781 { &vop_create_desc, genfs_eopnotsupp}, /* create */
782 { &vop_mknod_desc, genfs_eopnotsupp}, /* mknod */
783 { &vop_open_desc, genfs_nullop }, /* open */
784 { &vop_close_desc, genfs_nullop }, /* close */
785 { &vop_access_desc, efs_access }, /* access */
786 { &vop_getattr_desc, efs_getattr }, /* getattr */
787 { &vop_setattr_desc, genfs_eopnotsupp}, /* setattr */
788 { &vop_read_desc, efs_read }, /* read */
789 { &vop_write_desc, genfs_eopnotsupp}, /* write */
790 { &vop_ioctl_desc, genfs_enoioctl }, /* ioctl */
791 { &vop_fcntl_desc, genfs_fcntl }, /* fcntl */
792 { &vop_poll_desc, genfs_poll }, /* poll */
793 { &vop_kqfilter_desc, genfs_kqfilter }, /* kqfilter */
794 { &vop_revoke_desc, genfs_revoke }, /* revoke */
795 { &vop_mmap_desc, genfs_mmap }, /* mmap */
796 { &vop_fsync_desc, genfs_eopnotsupp}, /* fsync */
797 { &vop_seek_desc, genfs_seek }, /* seek */
798 { &vop_remove_desc, genfs_eopnotsupp}, /* remove */
799 { &vop_link_desc, genfs_eopnotsupp}, /* link */
800 { &vop_rename_desc, genfs_eopnotsupp}, /* rename */
801 { &vop_mkdir_desc, genfs_eopnotsupp}, /* mkdir */
802 { &vop_rmdir_desc, genfs_eopnotsupp}, /* rmdir */
803 { &vop_symlink_desc, genfs_eopnotsupp}, /* symlink */
804 { &vop_readdir_desc, efs_readdir }, /* readdir */
805 { &vop_readlink_desc, efs_readlink }, /* readlink */
806 { &vop_abortop_desc, genfs_abortop }, /* abortop */
807 { &vop_inactive_desc, efs_inactive }, /* inactive */
808 { &vop_reclaim_desc, efs_reclaim }, /* reclaim */
809 { &vop_lock_desc, genfs_lock, }, /* lock */
810 { &vop_unlock_desc, genfs_unlock, }, /* unlock */
811 { &vop_islocked_desc, genfs_islocked, }, /* islocked */
812 { &vop_bmap_desc, efs_bmap }, /* bmap */
813 { &vop_print_desc, efs_print }, /* print */
814 { &vop_pathconf_desc, efs_pathconf }, /* pathconf */
815 { &vop_advlock_desc, efs_advlock }, /* advlock */
816 /* blkatoff */
817 /* valloc */
818 /* balloc */
819 /* vfree */
820 /* truncate */
821 { &vop_lease_desc, genfs_lease_check }, /* lease */
822 /* whiteout */
823 { &vop_getpages_desc, genfs_getpages }, /* getpages */
824 { &vop_putpages_desc, genfs_putpages }, /* putpages */
825 { &vop_bwrite_desc, vn_bwrite }, /* bwrite */
826 { &vop_strategy_desc, efs_strategy }, /* strategy */
827 { NULL, NULL }
828 };
829 const struct vnodeopv_desc efs_vnodeop_opv_desc = {
830 &efs_vnodeop_p,
831 efs_vnodeop_entries
832 };
833