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