efs_vnops.c revision 1.12 1 /* $NetBSD: efs_vnops.c,v 1.12 2007/11/26 19:01:43 pooka 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.12 2007/11/26 19:01:43 pooka 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);
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);
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 } */ *ap = v;
143 struct vnode *vp = ap->a_vp;
144 struct efs_inode *eip = EFS_VTOI(vp);
145
146 if ((ap->a_mode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY))
147 return (EROFS);
148
149 return (vaccess(vp->v_type, eip->ei_mode, eip->ei_uid, eip->ei_gid,
150 ap->a_mode, ap->a_cred));
151 }
152
153 /*
154 * Get specific vnode attributes on a file. See vattr(9).
155 *
156 * Returns 0 on success.
157 */
158 static int
159 efs_getattr(void *v)
160 {
161 struct vop_getattr_args /* {
162 const struct vnodeop_desc *a_desc;
163 struct vnode *a_vp;
164 struct vattr *a_vap;
165 struct ucred *a_cred;
166 } */ *ap = v;
167
168 struct vattr *vap = ap->a_vap;
169 struct efs_inode *eip = EFS_VTOI(ap->a_vp);
170
171 vattr_null(ap->a_vap);
172 vap->va_type = ap->a_vp->v_type;
173 vap->va_mode = eip->ei_mode;
174 vap->va_nlink = eip->ei_nlink;
175 vap->va_uid = eip->ei_uid;
176 vap->va_gid = eip->ei_gid;
177 vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid;
178 vap->va_fileid = eip->ei_number;
179 vap->va_size = eip->ei_size;
180
181 if (ap->a_vp->v_type == VBLK)
182 vap->va_blocksize = BLKDEV_IOSIZE;
183 else if (ap->a_vp->v_type == VCHR)
184 vap->va_blocksize = MAXBSIZE;
185 else
186 vap->va_blocksize = EFS_BB_SIZE;
187
188 vap->va_atime.tv_sec = eip->ei_atime;
189 vap->va_mtime.tv_sec = eip->ei_mtime;
190 vap->va_ctime.tv_sec = eip->ei_ctime;
191 /* vap->va_birthtime = */
192 vap->va_gen = eip->ei_gen;
193 vap->va_flags = ap->a_vp->v_vflag |
194 ap->a_vp->v_iflag | ap->a_vp->v_uflag;
195
196 if (ap->a_vp->v_type == VBLK || ap->a_vp->v_type == VCHR) {
197 uint32_t dmaj, dmin;
198
199 if (be16toh(eip->ei_di.di_odev) != EFS_DINODE_ODEV_INVALID) {
200 dmaj = EFS_DINODE_ODEV_MAJ(be16toh(eip->ei_di.di_odev));
201 dmin = EFS_DINODE_ODEV_MIN(be16toh(eip->ei_di.di_odev));
202 } else {
203 dmaj = EFS_DINODE_NDEV_MAJ(be32toh(eip->ei_di.di_ndev));
204 dmin = EFS_DINODE_NDEV_MIN(be32toh(eip->ei_di.di_ndev));
205 }
206
207 vap->va_rdev = makedev(dmaj, dmin);
208 }
209
210 vap->va_bytes = eip->ei_size;
211 /* vap->va_filerev = */
212 /* vap->va_vaflags = */
213
214 return (0);
215 }
216
217 /*
218 * Read a file.
219 *
220 * Returns 0 on success.
221 */
222 static int
223 efs_read(void *v)
224 {
225 struct vop_read_args /* {
226 const struct vnodeop_desc *a_desc;
227 struct vnode *a_vp;
228 struct uio *a_uio;
229 int a_ioflag;
230 struct ucred *a_cred;
231 } */ *ap = v;
232 struct efs_extent ex;
233 struct efs_extent_iterator exi;
234 void *win;
235 struct uio *uio = ap->a_uio;
236 struct efs_inode *eip = EFS_VTOI(ap->a_vp);
237 off_t start;
238 vsize_t len;
239 int err, ret, flags;
240 const int advice = IO_ADV_DECODE(ap->a_ioflag);
241
242 if (ap->a_vp->v_type == VDIR)
243 return (EISDIR);
244
245 if (ap->a_vp->v_type != VREG)
246 return (EINVAL);
247
248 efs_extent_iterator_init(&exi, eip, uio->uio_offset);
249 ret = efs_extent_iterator_next(&exi, &ex);
250 while (ret == 0) {
251 if (uio->uio_offset < 0 || uio->uio_offset >= eip->ei_size ||
252 uio->uio_resid == 0)
253 break;
254
255 start = ex.ex_offset * EFS_BB_SIZE;
256 len = ex.ex_length * EFS_BB_SIZE;
257
258 if (!(uio->uio_offset >= start &&
259 uio->uio_offset < (start + len))) {
260 ret = efs_extent_iterator_next(&exi, &ex);
261 continue;
262 }
263
264 start = uio->uio_offset - start;
265
266 len = MIN(len - start, uio->uio_resid);
267 len = MIN(len, eip->ei_size - uio->uio_offset);
268
269 win = ubc_alloc(&ap->a_vp->v_uobj, uio->uio_offset,
270 &len, advice, UBC_READ);
271
272 flags = UBC_WANT_UNMAP(ap->a_vp) ? UBC_UNMAP : 0;
273
274 err = uiomove(win, len, uio);
275 ubc_release(win, flags);
276 if (err) {
277 EFS_DPRINTF(("efs_read: uiomove error %d\n",
278 err));
279 return (err);
280 }
281 }
282
283 return ((ret == -1) ? 0 : ret);
284 }
285
286 static int
287 efs_readdir(void *v)
288 {
289 struct vop_readdir_args /* {
290 const struct vnodeop_desc *a_desc;
291 struct vnode *a_vp;
292 struct uio *a_uio;
293 struct ucred *a_cred;
294 int *a_eofflag;
295 off_t **a_cookies;
296 int *a_ncookies;
297 } */ *ap = v;
298 struct dirent *dp;
299 struct efs_dinode edi;
300 struct efs_extent ex;
301 struct efs_extent_iterator exi;
302 struct buf *bp;
303 struct efs_dirent *de;
304 struct efs_dirblk *db;
305 struct uio *uio = ap->a_uio;
306 struct efs_inode *ei = EFS_VTOI(ap->a_vp);
307 off_t *cookies = NULL;
308 off_t offset;
309 int i, j, err, ret, s, slot, ncookies, maxcookies = 0;
310
311 if (ap->a_vp->v_type != VDIR)
312 return (ENOTDIR);
313
314 if (ap->a_eofflag != NULL)
315 *ap->a_eofflag = false;
316
317 if (ap->a_ncookies != NULL) {
318 ncookies = 0;
319 maxcookies =
320 uio->uio_resid / _DIRENT_MINSIZE((struct dirent *)0);
321 cookies = malloc(maxcookies * sizeof(off_t), M_TEMP, M_WAITOK);
322 }
323
324 dp = malloc(sizeof(struct dirent), M_EFSTMP, M_WAITOK | M_ZERO);
325
326 offset = 0;
327 efs_extent_iterator_init(&exi, ei, 0);
328 while ((ret = efs_extent_iterator_next(&exi, &ex)) == 0) {
329 for (i = 0; i < ex.ex_length; i++) {
330 err = efs_bread(VFSTOEFS(ap->a_vp->v_mount),
331 ex.ex_bn + i, NULL, &bp);
332 if (err) {
333 brelse(bp, 0);
334 goto exit_err;
335 }
336
337 db = (struct efs_dirblk *)bp->b_data;
338
339 if (be16toh(db->db_magic) != EFS_DIRBLK_MAGIC) {
340 printf("efs_readdir: bad dirblk\n");
341 brelse(bp, 0);
342 continue;
343 }
344
345 for (j = 0; j < db->db_slots; j++) {
346 slot = EFS_DIRENT_OFF_EXPND(db->db_space[j]);
347 if (slot == EFS_DIRBLK_SLOT_FREE)
348 continue;
349
350 if (!EFS_DIRENT_OFF_VALID(slot)) {
351 printf("efs_readdir: bad dirent\n");
352 continue;
353 }
354
355 de = EFS_DIRBLK_TO_DIRENT(db, slot);
356 s = _DIRENT_RECLEN(dp, de->de_namelen);
357
358 if (offset < uio->uio_offset) {
359 offset += s;
360 continue;
361 }
362
363 /* XXX - shouldn't happen, right? */
364 if (offset > uio->uio_offset ||
365 s > uio->uio_resid) {
366 brelse(bp, 0);
367 goto exit_ok;
368 }
369
370 /* de_namelen is uint8_t, d.d_name is 512b */
371 KASSERT(sizeof(dp->d_name)-de->de_namelen > 0);
372 dp->d_fileno = be32toh(de->de_inumber);
373 dp->d_reclen = s;
374 dp->d_namlen = de->de_namelen;
375 memcpy(dp->d_name, de->de_name,
376 de->de_namelen);
377 dp->d_name[de->de_namelen] = '\0';
378
379 /* look up inode to get type */
380 err = efs_read_inode(
381 VFSTOEFS(ap->a_vp->v_mount),
382 dp->d_fileno, NULL, &edi);
383 if (err) {
384 brelse(bp, 0);
385 goto exit_err;
386 }
387
388 switch (be16toh(edi.di_mode) & EFS_IFMT) {
389 case EFS_IFIFO:
390 dp->d_type = DT_FIFO;
391 break;
392 case EFS_IFCHR:
393 dp->d_type = DT_CHR;
394 break;
395 case EFS_IFDIR:
396 dp->d_type = DT_DIR;
397 break;
398 case EFS_IFBLK:
399 dp->d_type = DT_BLK;
400 break;
401 case EFS_IFREG:
402 dp->d_type = DT_REG;
403 break;
404 case EFS_IFLNK:
405 dp->d_type = DT_LNK;
406 break;
407 case EFS_IFSOCK:
408 dp->d_type = DT_SOCK;
409 break;
410 default:
411 dp->d_type = DT_UNKNOWN;
412 break;
413 }
414
415 err = uiomove(dp, s, uio);
416 if (err) {
417 brelse(bp, 0);
418 goto exit_err;
419 }
420
421 offset += s;
422
423 if (cookies != NULL && maxcookies != 0) {
424 cookies[ncookies++] = offset;
425 if (ncookies == maxcookies) {
426 brelse(bp, 0);
427 goto exit_ok;
428 }
429 }
430 }
431
432 brelse(bp, 0);
433 }
434 }
435
436 if (ret != -1) {
437 err = ret;
438 goto exit_err;
439 }
440
441 if (ap->a_eofflag != NULL)
442 *ap->a_eofflag = true;
443
444 exit_ok:
445 if (cookies != NULL) {
446 *ap->a_cookies = cookies;
447 *ap->a_ncookies = ncookies;
448 }
449
450 uio->uio_offset = offset;
451
452 free(dp, M_EFSTMP);
453
454 return (0);
455
456 exit_err:
457 if (cookies != NULL)
458 free(cookies, M_TEMP);
459
460 free(dp, M_EFSTMP);
461
462 return (err);
463 }
464
465 static int
466 efs_readlink(void *v)
467 {
468 struct vop_readlink_args /* {
469 const struct vnodeop_desc *a_desc;
470 struct vnode *a_vp;
471 struct uio *a_uio;
472 struct ucred *a_cred;
473 } */ *ap = v;
474 struct uio *uio = ap->a_uio;
475 struct efs_inode *eip = EFS_VTOI(ap->a_vp);
476 char *buf;
477 size_t len;
478 int err, i;
479
480 if ((eip->ei_mode & EFS_IFMT) != EFS_IFLNK)
481 return (EINVAL);
482
483 if (uio->uio_resid < 1)
484 return (EINVAL);
485
486 buf = malloc(eip->ei_size + 1, M_EFSTMP, M_ZERO | M_WAITOK);
487
488 /* symlinks are either inlined in the inode, or in extents */
489 if (eip->ei_numextents == 0) {
490 if (eip->ei_size > sizeof(eip->ei_di.di_symlink)) {
491 EFS_DPRINTF(("efs_readlink: too big for inline\n"));
492 free(buf, M_EFSTMP);
493 return (EBADF);
494 }
495
496 memcpy(buf, eip->ei_di.di_symlink, eip->ei_size);
497 len = MIN(uio->uio_resid, eip->ei_size + 1);
498 } else {
499 struct efs_extent_iterator exi;
500 struct efs_extent ex;
501 struct buf *bp;
502 int resid, off, ret;
503
504 off = 0;
505 resid = eip->ei_size;
506
507 efs_extent_iterator_init(&exi, eip, 0);
508 while ((ret = efs_extent_iterator_next(&exi, &ex)) == 0) {
509 for (i = 0; i < ex.ex_length; i++) {
510 err = efs_bread(VFSTOEFS(ap->a_vp->v_mount),
511 ex.ex_bn + i, NULL, &bp);
512 if (err) {
513 brelse(bp, 0);
514 free(buf, M_EFSTMP);
515 return (err);
516 }
517
518 len = MIN(resid, bp->b_bcount);
519 memcpy(buf + off, bp->b_data, len);
520 brelse(bp, 0);
521
522 off += len;
523 resid -= len;
524
525 if (resid == 0)
526 break;
527 }
528
529 if (resid == 0)
530 break;
531 }
532
533 if (ret != 0 && ret != -1) {
534 free(buf, M_EFSTMP);
535 return (ret);
536 }
537
538 len = off + 1;
539 }
540
541 KASSERT(len >= 1 && len <= (eip->ei_size + 1));
542 buf[len - 1] = '\0';
543 err = uiomove(buf, len, uio);
544 free(buf, M_EFSTMP);
545
546 return (err);
547 }
548
549 /*
550 * Release an inactive vnode. The vnode _must_ be unlocked on return.
551 * It is either nolonger being used by the kernel, or an unmount is being
552 * forced.
553 *
554 * Returns 0 on success.
555 */
556 static int
557 efs_inactive(void *v)
558 {
559 struct vop_inactive_args /* {
560 const struct vnodeop_desc *a_desc;
561 struct vnode *a_vp;
562 } */ *ap = v;
563 struct efs_inode *eip = EFS_VTOI(ap->a_vp);
564
565 VOP_UNLOCK(ap->a_vp, 0);
566
567 if (eip->ei_mode == 0)
568 vrecycle(ap->a_vp, NULL, curlwp);
569
570 return (0);
571 }
572
573 static int
574 efs_reclaim(void *v)
575 {
576 struct vop_reclaim_args /* {
577 const struct vnodeop_desc *a_desc;
578 struct vnode *a_vp;
579 } */ *ap = v;
580 struct vnode *vp = ap->a_vp;
581
582 efs_ihashrem(EFS_VTOI(vp));
583 cache_purge(vp);
584 genfs_node_destroy(vp);
585 pool_put(&efs_inode_pool, vp->v_data);
586 vp->v_data = NULL;
587
588 return (0);
589 }
590
591 static int
592 efs_bmap(void *v)
593 {
594 struct vop_bmap_args /* {
595 const struct vnodeop_desc *a_desc;
596 struct vnode *a_vp;
597 daddr_t a_bn;
598 struct vnode **a_vpp;
599 daddr_t *a_bnp;
600 int *a_runp;
601 } */ *ap = v;
602 struct efs_extent ex;
603 struct efs_extent_iterator exi;
604 struct vnode *vp = ap->a_vp;
605 struct efs_inode *eip = EFS_VTOI(vp);
606 bool found;
607 int ret;
608
609 if (ap->a_vpp != NULL)
610 *ap->a_vpp = VFSTOEFS(vp->v_mount)->em_devvp;
611
612 found = false;
613 efs_extent_iterator_init(&exi, eip, ap->a_bn * EFS_BB_SIZE);
614 while ((ret = efs_extent_iterator_next(&exi, &ex)) == 0) {
615 if (ap->a_bn >= ex.ex_offset &&
616 ap->a_bn < (ex.ex_offset + ex.ex_length)) {
617 found = true;
618 break;
619 }
620 }
621
622 KASSERT(!found || (found && ret == 0));
623
624 if (!found) {
625 EFS_DPRINTF(("efs_bmap: ap->a_bn not in extents\n"));
626 return ((ret == -1) ? EIO : ret);
627 }
628
629 if (ex.ex_magic != EFS_EXTENT_MAGIC) {
630 EFS_DPRINTF(("efs_bmap: exn.ex_magic != EFS_EXTENT_MAGIC\n"));
631 return (EIO);
632 }
633
634 if (ap->a_bn < ex.ex_offset) {
635 EFS_DPRINTF(("efs_bmap: ap->a_bn < exn.ex_offset\n"));
636 return (EIO);
637 }
638
639 KASSERT(ap->a_bn >= ex.ex_offset);
640 KASSERT(ex.ex_length > ap->a_bn - ex.ex_offset);
641
642 *ap->a_bnp = ex.ex_bn + (ap->a_bn - ex.ex_offset);
643 if (ap->a_runp != NULL)
644 *ap->a_runp = ex.ex_length - (ap->a_bn - ex.ex_offset) - 1;
645
646 return (0);
647 }
648
649 static int
650 efs_strategy(void *v)
651 {
652 struct vop_strategy_args /* {
653 const struct vnodeop_desc *a_desc;
654 struct vnode *a_vp;
655 struct buf *a_bp;
656 } */ *ap = v;
657 struct vnode *vp = ap->a_vp;
658 struct buf *bp = ap->a_bp;
659 int error;
660
661 if (vp == NULL) {
662 bp->b_error = EIO;
663 biodone(bp);
664 return (EIO);
665 }
666
667 if (bp->b_blkno == bp->b_lblkno) {
668 error = VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL);
669 if (error) {
670 bp->b_error = error;
671 biodone(bp);
672 return (error);
673 }
674 if ((long)bp->b_blkno == -1)
675 clrbuf(bp);
676 }
677
678 if ((long)bp->b_blkno == -1) {
679 biodone(bp);
680 return (0);
681 }
682
683 return (VOP_STRATEGY(VFSTOEFS(vp->v_mount)->em_devvp, bp));
684 }
685
686 static int
687 efs_print(void *v)
688 {
689 struct vop_print_args /* {
690 const struct vnodeop_desc *a_desc;
691 struct vnode *a_vp;
692 } */ *ap = v;
693 struct efs_inode *eip = EFS_VTOI(ap->a_vp);
694
695 printf( "efs_inode (ino %lu):\n"
696 " ei_mode: %07o\n"
697 " ei_nlink: %d\n"
698 " ei_uid: %d\n"
699 " ei_gid: %d\n"
700 " ei_size: %d\n"
701 " ei_atime: %d\n"
702 " ei_mtime: %d\n"
703 " ei_ctime: %d\n"
704 " ei_gen: %d\n"
705 " ei_numextents: %d\n"
706 " ei_version: %d\n",
707 (unsigned long)eip->ei_number,
708 (unsigned int)eip->ei_mode,
709 eip->ei_nlink,
710 eip->ei_uid,
711 eip->ei_gid,
712 eip->ei_size,
713 (int32_t)eip->ei_atime,
714 (int32_t)eip->ei_mtime,
715 (int32_t)eip->ei_ctime,
716 eip->ei_gen,
717 eip->ei_numextents,
718 eip->ei_version);
719
720 return (0);
721 }
722
723 static int
724 efs_pathconf(void *v)
725 {
726 struct vop_pathconf_args /* {
727 const struct vnodeop_desc *a_desc;
728 struct vnode *a_vp;
729 int a_name;
730 register_t *a_retval;
731 } */ *ap = v;
732
733 /* IRIX 4 values */
734 switch (ap->a_name) {
735 case _PC_LINK_MAX:
736 *ap->a_retval = 30000;
737 break;
738 case _PC_NAME_MAX:
739 *ap->a_retval = 255;
740 break;
741 case _PC_PATH_MAX:
742 *ap->a_retval = 1024;
743 break;
744 case _PC_NO_TRUNC:
745 *ap->a_retval = 1;
746 break;
747 case _PC_CHOWN_RESTRICTED:
748 *ap->a_retval = 1;
749 break;
750 case _PC_SYNC_IO:
751 *ap->a_retval = 1;
752 break;
753 case _PC_FILESIZEBITS:
754 *ap->a_retval = 32;
755 break;
756 default:
757 return (EINVAL);
758 }
759
760 return (0);
761 }
762
763 static int
764 efs_advlock(void *v)
765 {
766 struct vop_advlock_args /* {
767 const struct vnodeop_desc *a_desc;
768 struct vnode *a_vp;
769 void *a_id;
770 int a_op;
771 struct flock *a_fl;
772 int a_flags;
773 } */ *ap = v;
774 struct efs_inode *eip = EFS_VTOI(ap->a_vp);
775
776 return (lf_advlock(ap, &eip->ei_lockf, eip->ei_size));
777 }
778
779 /* Global vfs data structures for efs */
780 int (**efs_vnodeop_p)(void *);
781 const struct vnodeopv_entry_desc efs_vnodeop_entries[] = {
782 { &vop_default_desc, vn_default_error}, /* error handler */
783 { &vop_lookup_desc, efs_lookup }, /* lookup */
784 { &vop_create_desc, genfs_eopnotsupp}, /* create */
785 { &vop_mknod_desc, genfs_eopnotsupp}, /* mknod */
786 { &vop_open_desc, genfs_nullop }, /* open */
787 { &vop_close_desc, genfs_nullop }, /* close */
788 { &vop_access_desc, efs_access }, /* access */
789 { &vop_getattr_desc, efs_getattr }, /* getattr */
790 { &vop_setattr_desc, genfs_eopnotsupp}, /* setattr */
791 { &vop_read_desc, efs_read }, /* read */
792 { &vop_write_desc, genfs_eopnotsupp}, /* write */
793 { &vop_ioctl_desc, genfs_enoioctl }, /* ioctl */
794 { &vop_fcntl_desc, genfs_fcntl }, /* fcntl */
795 { &vop_poll_desc, genfs_poll }, /* poll */
796 { &vop_kqfilter_desc, genfs_kqfilter }, /* kqfilter */
797 { &vop_revoke_desc, genfs_revoke }, /* revoke */
798 { &vop_mmap_desc, genfs_mmap }, /* mmap */
799 { &vop_fsync_desc, genfs_eopnotsupp}, /* fsync */
800 { &vop_seek_desc, genfs_seek }, /* seek */
801 { &vop_remove_desc, genfs_eopnotsupp}, /* remove */
802 { &vop_link_desc, genfs_eopnotsupp}, /* link */
803 { &vop_rename_desc, genfs_eopnotsupp}, /* rename */
804 { &vop_mkdir_desc, genfs_eopnotsupp}, /* mkdir */
805 { &vop_rmdir_desc, genfs_eopnotsupp}, /* rmdir */
806 { &vop_symlink_desc, genfs_eopnotsupp}, /* symlink */
807 { &vop_readdir_desc, efs_readdir }, /* readdir */
808 { &vop_readlink_desc, efs_readlink }, /* readlink */
809 { &vop_abortop_desc, genfs_abortop }, /* abortop */
810 { &vop_inactive_desc, efs_inactive }, /* inactive */
811 { &vop_reclaim_desc, efs_reclaim }, /* reclaim */
812 { &vop_lock_desc, genfs_lock, }, /* lock */
813 { &vop_unlock_desc, genfs_unlock, }, /* unlock */
814 { &vop_islocked_desc, genfs_islocked, }, /* islocked */
815 { &vop_bmap_desc, efs_bmap }, /* bmap */
816 { &vop_print_desc, efs_print }, /* print */
817 { &vop_pathconf_desc, efs_pathconf }, /* pathconf */
818 { &vop_advlock_desc, efs_advlock }, /* advlock */
819 /* blkatoff */
820 /* valloc */
821 /* balloc */
822 /* vfree */
823 /* truncate */
824 { &vop_lease_desc, genfs_lease_check }, /* lease */
825 /* whiteout */
826 { &vop_getpages_desc, genfs_getpages }, /* getpages */
827 { &vop_putpages_desc, genfs_putpages }, /* putpages */
828 { &vop_bwrite_desc, vn_bwrite }, /* bwrite */
829 { &vop_strategy_desc, efs_strategy }, /* strategy */
830 { NULL, NULL }
831 };
832 const struct vnodeopv_desc efs_vnodeop_opv_desc = {
833 &efs_vnodeop_p,
834 efs_vnodeop_entries
835 };
836