649 struct namenode *nodep;
650
651 if (vfsp == NULL)
652 return (0);
653
654 nodep = (struct namenode *)vfsp->vfs_data;
655 if (flag & SYNC_CLOSE)
656 return (nm_umountall(nodep->nm_filevp, crp));
657
658 return (VOP_FSYNC(nodep->nm_filevp, FSYNC, crp, NULL));
659 }
660
661 /*
662 * File system initialization routine. Save the file system type,
663 * establish a file system device number and initialize nm_filevp_hash[].
664 */
665 int
666 nameinit(int fstype, char *name)
667 {
668 static const fs_operation_def_t nm_vfsops_template[] = {
669 VFSNAME_MOUNT, { .vfs_mount = nm_mount },
670 VFSNAME_UNMOUNT, { .vfs_unmount = nm_unmount },
671 VFSNAME_ROOT, { .vfs_root = nm_root },
672 VFSNAME_STATVFS, { .vfs_statvfs = nm_statvfs },
673 VFSNAME_SYNC, { .vfs_sync = nm_sync },
674 NULL, NULL
675 };
676 static const fs_operation_def_t nm_dummy_vfsops_template[] = {
677 VFSNAME_STATVFS, { .vfs_statvfs = nm_statvfs },
678 VFSNAME_SYNC, { .vfs_sync = nm_sync },
679 NULL, NULL
680 };
681 int error;
682 int dev;
683 vfsops_t *dummy_vfsops;
684
685 error = vfs_setfsops(fstype, nm_vfsops_template, &namefs_vfsops);
686 if (error != 0) {
687 cmn_err(CE_WARN, "nameinit: bad vfs ops template");
688 return (error);
689 }
690
691 error = vfs_makefsops(nm_dummy_vfsops_template, &dummy_vfsops);
692 if (error != 0) {
693 (void) vfs_freevfsops_by_type(fstype);
694 cmn_err(CE_WARN, "nameinit: bad dummy vfs ops template");
695 return (error);
696 }
697
698 error = vn_make_ops(name, nm_vnodeops_template, &nm_vnodeops);
699 if (error != 0) {
725 NULL,
726 0
727 };
728
729 static vfsdef_t vfw = {
730 VFSDEF_VERSION,
731 "namefs",
732 nameinit,
733 VSW_HASPROTO | VSW_ZMOUNT,
734 &nm_mntopts
735 };
736
737 /*
738 * Module linkage information for the kernel.
739 */
740 static struct modlfs modlfs = {
741 &mod_fsops, "filesystem for namefs", &vfw
742 };
743
744 static struct modlinkage modlinkage = {
745 MODREV_1, (void *)&modlfs, NULL
746 };
747
748 int
749 _init(void)
750 {
751 namenodeno_init();
752 return (mod_install(&modlinkage));
753 }
754
755 int
756 _fini(void)
757 {
758 return (EBUSY);
759 }
760
761 int
762 _info(struct modinfo *modinfop)
763 {
764 return (mod_info(&modlinkage, modinfop));
765 }
|
649 struct namenode *nodep;
650
651 if (vfsp == NULL)
652 return (0);
653
654 nodep = (struct namenode *)vfsp->vfs_data;
655 if (flag & SYNC_CLOSE)
656 return (nm_umountall(nodep->nm_filevp, crp));
657
658 return (VOP_FSYNC(nodep->nm_filevp, FSYNC, crp, NULL));
659 }
660
661 /*
662 * File system initialization routine. Save the file system type,
663 * establish a file system device number and initialize nm_filevp_hash[].
664 */
665 int
666 nameinit(int fstype, char *name)
667 {
668 static const fs_operation_def_t nm_vfsops_template[] = {
669 { VFSNAME_MOUNT, { .vfs_mount = nm_mount } },
670 { VFSNAME_UNMOUNT, { .vfs_unmount = nm_unmount } },
671 { VFSNAME_ROOT, { .vfs_root = nm_root } },
672 { VFSNAME_STATVFS, { .vfs_statvfs = nm_statvfs } },
673 { VFSNAME_SYNC, { .vfs_sync = nm_sync } },
674 { NULL, { NULL } }
675 };
676 static const fs_operation_def_t nm_dummy_vfsops_template[] = {
677 { VFSNAME_STATVFS, { .vfs_statvfs = nm_statvfs } },
678 { VFSNAME_SYNC, { .vfs_sync = nm_sync } },
679 { NULL, { NULL } }
680 };
681 int error;
682 int dev;
683 vfsops_t *dummy_vfsops;
684
685 error = vfs_setfsops(fstype, nm_vfsops_template, &namefs_vfsops);
686 if (error != 0) {
687 cmn_err(CE_WARN, "nameinit: bad vfs ops template");
688 return (error);
689 }
690
691 error = vfs_makefsops(nm_dummy_vfsops_template, &dummy_vfsops);
692 if (error != 0) {
693 (void) vfs_freevfsops_by_type(fstype);
694 cmn_err(CE_WARN, "nameinit: bad dummy vfs ops template");
695 return (error);
696 }
697
698 error = vn_make_ops(name, nm_vnodeops_template, &nm_vnodeops);
699 if (error != 0) {
725 NULL,
726 0
727 };
728
729 static vfsdef_t vfw = {
730 VFSDEF_VERSION,
731 "namefs",
732 nameinit,
733 VSW_HASPROTO | VSW_ZMOUNT,
734 &nm_mntopts
735 };
736
737 /*
738 * Module linkage information for the kernel.
739 */
740 static struct modlfs modlfs = {
741 &mod_fsops, "filesystem for namefs", &vfw
742 };
743
744 static struct modlinkage modlinkage = {
745 MODREV_1, { (void *)&modlfs, NULL }
746 };
747
748 int
749 _init(void)
750 {
751 namenodeno_init();
752 return (mod_install(&modlinkage));
753 }
754
755 int
756 _fini(void)
757 {
758 return (EBUSY);
759 }
760
761 int
762 _info(struct modinfo *modinfop)
763 {
764 return (mod_info(&modlinkage, modinfop));
765 }
|