301 }
302
303 /* ARGSUSED */
304 static void
305 fdinactive(vnode_t *vp, cred_t *cr, caller_context_t *ct)
306 {
307 mutex_enter(&vp->v_lock);
308 ASSERT(vp->v_count >= 1);
309 if (--vp->v_count != 0) {
310 mutex_exit(&vp->v_lock);
311 return;
312 }
313 mutex_exit(&vp->v_lock);
314 vn_invalid(vp);
315 vn_free(vp);
316 }
317
318 static struct vnodeops *fd_vnodeops;
319
320 static const fs_operation_def_t fd_vnodeops_template[] = {
321 VOPNAME_OPEN, { .vop_open = fdopen },
322 VOPNAME_CLOSE, { .vop_close = fdclose },
323 VOPNAME_READ, { .vop_read = fdread },
324 VOPNAME_GETATTR, { .vop_getattr = fdgetattr },
325 VOPNAME_ACCESS, { .vop_access = fdaccess },
326 VOPNAME_LOOKUP, { .vop_lookup = fdlookup },
327 VOPNAME_CREATE, { .vop_create = fdcreate },
328 VOPNAME_READDIR, { .vop_readdir = fdreaddir },
329 VOPNAME_INACTIVE, { .vop_inactive = fdinactive },
330 VOPNAME_FRLOCK, { .error = fs_error },
331 VOPNAME_POLL, { .error = fs_error },
332 VOPNAME_DISPOSE, { .error = fs_error },
333 NULL, NULL
334 };
335
336 static int
337 fdget(struct vnode *dvp, char *comp, struct vnode **vpp)
338 {
339 int n = 0;
340 struct vnode *vp;
341
342 while (*comp) {
343 if (*comp < '0' || *comp > '9')
344 return (ENOENT);
345 n = 10 * n + *comp++ - '0';
346 }
347 vp = vn_alloc(KM_SLEEP);
348 vp->v_type = VCHR;
349 vp->v_vfsp = dvp->v_vfsp;
350 vn_setops(vp, fd_vnodeops);
351 vp->v_data = NULL;
352 vp->v_flag = VNOMAP;
353 vp->v_rdev = makedevice(fdrmaj, n);
462 sp->f_bfree = (fsblkcnt64_t)0;
463 sp->f_bavail = (fsblkcnt64_t)0;
464 sp->f_files = (fsfilcnt64_t)
465 (MIN(P_FINFO(curproc)->fi_nfiles, fdno_ctl + 2));
466 sp->f_ffree = (fsfilcnt64_t)0;
467 sp->f_favail = (fsfilcnt64_t)0;
468 (void) cmpldev(&d32, vfsp->vfs_dev);
469 sp->f_fsid = d32;
470 (void) strcpy(sp->f_basetype, vfssw[fdfstype].vsw_name);
471 sp->f_flag = vf_to_stf(vfsp->vfs_flag);
472 sp->f_namemax = FDNSIZE;
473 (void) strcpy(sp->f_fstr, "/dev/fd");
474 (void) strcpy(&sp->f_fstr[8], "/dev/fd");
475 return (0);
476 }
477
478 int
479 fdinit(int fstype, char *name)
480 {
481 static const fs_operation_def_t fd_vfsops_template[] = {
482 VFSNAME_MOUNT, { .vfs_mount = fdmount },
483 VFSNAME_UNMOUNT, { .vfs_unmount = fdunmount },
484 VFSNAME_ROOT, { .vfs_root = fdroot },
485 VFSNAME_STATVFS, { .vfs_statvfs = fdstatvfs },
486 NULL, NULL
487 };
488 int error;
489
490 fdfstype = fstype;
491 ASSERT(fdfstype != 0);
492
493 /*
494 * Associate VFS ops vector with this fstype.
495 */
496 error = vfs_setfsops(fstype, fd_vfsops_template, NULL);
497 if (error != 0) {
498 cmn_err(CE_WARN, "fdinit: bad vnode ops template");
499 return (error);
500 }
501
502 error = vn_make_ops(name, fd_vnodeops_template, &fd_vnodeops);
503 if (error != 0) {
504 (void) vfs_freevfsops_by_type(fstype);
505 cmn_err(CE_WARN, "fdinit: bad vnode ops template");
506 return (error);
541 sizeof (mntopts) / sizeof (mntopt_t),
542 mntopts
543 };
544
545 static vfsdef_t vfw = {
546 VFSDEF_VERSION,
547 "fd",
548 fdinit,
549 VSW_HASPROTO | VSW_ZMOUNT,
550 &fdfs_mntopts
551 };
552
553 static struct modlfs modlfs = {
554 &mod_fsops,
555 "filesystem for fd",
556 &vfw
557 };
558
559 static struct modlinkage modlinkage = {
560 MODREV_1,
561 &modlfs,
562 NULL
563 };
564
565 int
566 _init(void)
567 {
568 return (mod_install(&modlinkage));
569 }
570
571 int
572 _info(struct modinfo *modinfop)
573 {
574 return (mod_info(&modlinkage, modinfop));
575 }
|
301 }
302
303 /* ARGSUSED */
304 static void
305 fdinactive(vnode_t *vp, cred_t *cr, caller_context_t *ct)
306 {
307 mutex_enter(&vp->v_lock);
308 ASSERT(vp->v_count >= 1);
309 if (--vp->v_count != 0) {
310 mutex_exit(&vp->v_lock);
311 return;
312 }
313 mutex_exit(&vp->v_lock);
314 vn_invalid(vp);
315 vn_free(vp);
316 }
317
318 static struct vnodeops *fd_vnodeops;
319
320 static const fs_operation_def_t fd_vnodeops_template[] = {
321 { VOPNAME_OPEN, { .vop_open = fdopen } },
322 { VOPNAME_CLOSE, { .vop_close = fdclose } },
323 { VOPNAME_READ, { .vop_read = fdread } },
324 { VOPNAME_GETATTR, { .vop_getattr = fdgetattr } },
325 { VOPNAME_ACCESS, { .vop_access = fdaccess } },
326 { VOPNAME_LOOKUP, { .vop_lookup = fdlookup } },
327 { VOPNAME_CREATE, { .vop_create = fdcreate } },
328 { VOPNAME_READDIR, { .vop_readdir = fdreaddir } },
329 { VOPNAME_INACTIVE, { .vop_inactive = fdinactive } },
330 { VOPNAME_FRLOCK, { .error = fs_error } },
331 { VOPNAME_POLL, { .error = fs_error } },
332 { VOPNAME_DISPOSE, { .error = fs_error } },
333 { NULL, { NULL } }
334 };
335
336 static int
337 fdget(struct vnode *dvp, char *comp, struct vnode **vpp)
338 {
339 int n = 0;
340 struct vnode *vp;
341
342 while (*comp) {
343 if (*comp < '0' || *comp > '9')
344 return (ENOENT);
345 n = 10 * n + *comp++ - '0';
346 }
347 vp = vn_alloc(KM_SLEEP);
348 vp->v_type = VCHR;
349 vp->v_vfsp = dvp->v_vfsp;
350 vn_setops(vp, fd_vnodeops);
351 vp->v_data = NULL;
352 vp->v_flag = VNOMAP;
353 vp->v_rdev = makedevice(fdrmaj, n);
462 sp->f_bfree = (fsblkcnt64_t)0;
463 sp->f_bavail = (fsblkcnt64_t)0;
464 sp->f_files = (fsfilcnt64_t)
465 (MIN(P_FINFO(curproc)->fi_nfiles, fdno_ctl + 2));
466 sp->f_ffree = (fsfilcnt64_t)0;
467 sp->f_favail = (fsfilcnt64_t)0;
468 (void) cmpldev(&d32, vfsp->vfs_dev);
469 sp->f_fsid = d32;
470 (void) strcpy(sp->f_basetype, vfssw[fdfstype].vsw_name);
471 sp->f_flag = vf_to_stf(vfsp->vfs_flag);
472 sp->f_namemax = FDNSIZE;
473 (void) strcpy(sp->f_fstr, "/dev/fd");
474 (void) strcpy(&sp->f_fstr[8], "/dev/fd");
475 return (0);
476 }
477
478 int
479 fdinit(int fstype, char *name)
480 {
481 static const fs_operation_def_t fd_vfsops_template[] = {
482 { VFSNAME_MOUNT, { .vfs_mount = fdmount } },
483 { VFSNAME_UNMOUNT, { .vfs_unmount = fdunmount } },
484 { VFSNAME_ROOT, { .vfs_root = fdroot } },
485 { VFSNAME_STATVFS, { .vfs_statvfs = fdstatvfs } },
486 { NULL, { NULL } }
487 };
488 int error;
489
490 fdfstype = fstype;
491 ASSERT(fdfstype != 0);
492
493 /*
494 * Associate VFS ops vector with this fstype.
495 */
496 error = vfs_setfsops(fstype, fd_vfsops_template, NULL);
497 if (error != 0) {
498 cmn_err(CE_WARN, "fdinit: bad vnode ops template");
499 return (error);
500 }
501
502 error = vn_make_ops(name, fd_vnodeops_template, &fd_vnodeops);
503 if (error != 0) {
504 (void) vfs_freevfsops_by_type(fstype);
505 cmn_err(CE_WARN, "fdinit: bad vnode ops template");
506 return (error);
541 sizeof (mntopts) / sizeof (mntopt_t),
542 mntopts
543 };
544
545 static vfsdef_t vfw = {
546 VFSDEF_VERSION,
547 "fd",
548 fdinit,
549 VSW_HASPROTO | VSW_ZMOUNT,
550 &fdfs_mntopts
551 };
552
553 static struct modlfs modlfs = {
554 &mod_fsops,
555 "filesystem for fd",
556 &vfw
557 };
558
559 static struct modlinkage modlinkage = {
560 MODREV_1,
561 { &modlfs, NULL }
562 };
563
564 int
565 _init(void)
566 {
567 return (mod_install(&modlinkage));
568 }
569
570 int
571 _info(struct modinfo *modinfop)
572 {
573 return (mod_info(&modlinkage, modinfop));
574 }
|