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