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