62 };
63
64 static vfsdef_t vfw = {
65 VFSDEF_VERSION,
66 "mntfs",
67 mntinit,
68 VSW_HASPROTO|VSW_STATS|VSW_ZMOUNT,
69 &mnt_mntopts
70 };
71
72 /*
73 * Module linkage information for the kernel.
74 */
75 extern struct mod_ops mod_fsops;
76
77 static struct modlfs modlfs = {
78 &mod_fsops, "mount information file system", &vfw
79 };
80
81 static struct modlinkage modlinkage = {
82 MODREV_1, (void *)&modlfs, NULL
83 };
84
85 int
86 _init(void)
87 {
88 return (mod_install(&modlinkage));
89 }
90
91 int
92 _info(struct modinfo *modinfop)
93 {
94 return (mod_info(&modlinkage, modinfop));
95 }
96
97 /*
98 * N.B.
99 * No _fini routine. The module cannot be unloaded once loaded.
100 * The NO_UNLOAD_STUB in modstubs.s must change if this module
101 * is ever modified to become unloadable.
102 */
115 mntinitrootnode(mntnode_t *mnp)
116 {
117 struct vnode *vp;
118
119 bzero((caddr_t)mnp, sizeof (*mnp));
120
121 mnp->mnt_vnode = vn_alloc(KM_SLEEP);
122
123 vp = MTOV(mnp);
124
125 vp->v_flag = VROOT|VNOCACHE|VNOMAP|VNOSWAP|VNOMOUNT;
126 vn_setops(vp, mntvnodeops);
127 vp->v_type = VREG;
128 vp->v_data = (caddr_t)mnp;
129 }
130
131 static int
132 mntinit(int fstype, char *name)
133 {
134 static const fs_operation_def_t mnt_vfsops_template[] = {
135 VFSNAME_MOUNT, { .vfs_mount = mntmount },
136 VFSNAME_UNMOUNT, { .vfs_unmount = mntunmount },
137 VFSNAME_ROOT, { .vfs_root = mntroot },
138 VFSNAME_STATVFS, { .vfs_statvfs = mntstatvfs },
139 NULL, NULL
140 };
141 extern const fs_operation_def_t mnt_vnodeops_template[];
142 int error;
143
144 mntfstype = fstype;
145 ASSERT(mntfstype != 0);
146 /*
147 * Associate VFS ops vector with this fstype.
148 */
149 error = vfs_setfsops(fstype, mnt_vfsops_template, NULL);
150 if (error != 0) {
151 cmn_err(CE_WARN, "mntinit: bad vfs ops template");
152 return (error);
153 }
154
155 /* Vnode ops too. */
156
157 error = vn_make_ops(name, mnt_vnodeops_template, &mntvnodeops);
158 if (error != 0) {
159 (void) vfs_freevfsops_by_type(fstype);
|
62 };
63
64 static vfsdef_t vfw = {
65 VFSDEF_VERSION,
66 "mntfs",
67 mntinit,
68 VSW_HASPROTO|VSW_STATS|VSW_ZMOUNT,
69 &mnt_mntopts
70 };
71
72 /*
73 * Module linkage information for the kernel.
74 */
75 extern struct mod_ops mod_fsops;
76
77 static struct modlfs modlfs = {
78 &mod_fsops, "mount information file system", &vfw
79 };
80
81 static struct modlinkage modlinkage = {
82 MODREV_1, { (void *)&modlfs, NULL }
83 };
84
85 int
86 _init(void)
87 {
88 return (mod_install(&modlinkage));
89 }
90
91 int
92 _info(struct modinfo *modinfop)
93 {
94 return (mod_info(&modlinkage, modinfop));
95 }
96
97 /*
98 * N.B.
99 * No _fini routine. The module cannot be unloaded once loaded.
100 * The NO_UNLOAD_STUB in modstubs.s must change if this module
101 * is ever modified to become unloadable.
102 */
115 mntinitrootnode(mntnode_t *mnp)
116 {
117 struct vnode *vp;
118
119 bzero((caddr_t)mnp, sizeof (*mnp));
120
121 mnp->mnt_vnode = vn_alloc(KM_SLEEP);
122
123 vp = MTOV(mnp);
124
125 vp->v_flag = VROOT|VNOCACHE|VNOMAP|VNOSWAP|VNOMOUNT;
126 vn_setops(vp, mntvnodeops);
127 vp->v_type = VREG;
128 vp->v_data = (caddr_t)mnp;
129 }
130
131 static int
132 mntinit(int fstype, char *name)
133 {
134 static const fs_operation_def_t mnt_vfsops_template[] = {
135 { VFSNAME_MOUNT, { .vfs_mount = mntmount } },
136 { VFSNAME_UNMOUNT, { .vfs_unmount = mntunmount } },
137 { VFSNAME_ROOT, { .vfs_root = mntroot } },
138 { VFSNAME_STATVFS, { .vfs_statvfs = mntstatvfs } },
139 { NULL, { NULL } }
140 };
141 extern const fs_operation_def_t mnt_vnodeops_template[];
142 int error;
143
144 mntfstype = fstype;
145 ASSERT(mntfstype != 0);
146 /*
147 * Associate VFS ops vector with this fstype.
148 */
149 error = vfs_setfsops(fstype, mnt_vfsops_template, NULL);
150 if (error != 0) {
151 cmn_err(CE_WARN, "mntinit: bad vfs ops template");
152 return (error);
153 }
154
155 /* Vnode ops too. */
156
157 error = vn_make_ops(name, mnt_vnodeops_template, &mntvnodeops);
158 if (error != 0) {
159 (void) vfs_freevfsops_by_type(fstype);
|