75 VFSDEF_VERSION,
76 "devfs", /* type name string */
77 devfsinit, /* init routine */
78 0, /* flags */
79 NULL /* mount options table prototype */
80 };
81
82 static kmutex_t devfs_lock; /* protects global data */
83 static int devfstype; /* fstype */
84 static dev_t devfsdev; /* the fictious 'device' we live on */
85 static struct devfs_data *devfs_mntinfo; /* linked list of instances */
86
87 /*
88 * Module linkage information
89 */
90 static struct modlfs modlfs = {
91 &mod_fsops, "devices filesystem", &devfs_vfssw
92 };
93
94 static struct modlinkage modlinkage = {
95 MODREV_1, (void *)&modlfs, NULL
96 };
97
98 int
99 _init(void)
100 {
101 int e;
102
103 mutex_init(&devfs_lock, "devfs lock", MUTEX_DEFAULT, NULL);
104 dv_node_cache_init();
105 if ((e = mod_install(&modlinkage)) != 0) {
106 dv_node_cache_fini();
107 mutex_destroy(&devfs_lock);
108 return (e);
109 }
110 dcmn_err(("devfs loaded\n"));
111 return (0);
112 }
113
114 int
115 _fini(void)
116 {
117 return (EBUSY);
118 }
119
120 int
121 _info(struct modinfo *modinfop)
122 {
123 return (mod_info(&modlinkage, modinfop));
124 }
125
126 /*ARGSUSED1*/
127 static int
128 devfsinit(int fstype, char *name)
129 {
130 static const fs_operation_def_t devfs_vfsops_template[] = {
131 VFSNAME_MOUNT, { .vfs_mount = devfs_mount },
132 VFSNAME_UNMOUNT, { .vfs_unmount = devfs_unmount },
133 VFSNAME_ROOT, { .vfs_root = devfs_root },
134 VFSNAME_STATVFS, { .vfs_statvfs = devfs_statvfs },
135 VFSNAME_SYNC, { .vfs_sync = fs_sync },
136 VFSNAME_MOUNTROOT, { .vfs_mountroot = devfs_mountroot },
137 NULL, NULL
138 };
139 int error;
140 int dev;
141 extern major_t getudev(void); /* gack - what a function */
142
143 devfstype = fstype;
144 /*
145 * Associate VFS ops vector with this fstype
146 */
147 error = vfs_setfsops(fstype, devfs_vfsops_template, NULL);
148 if (error != 0) {
149 cmn_err(CE_WARN, "devfsinit: bad vfs ops template");
150 return (error);
151 }
152
153 error = vn_make_ops("dev fs", dv_vnodeops_template, &dv_vnodeops);
154 if (error != 0) {
155 (void) vfs_freevfsops_by_type(fstype);
156 cmn_err(CE_WARN, "devfsinit: bad vnode ops template");
157 return (error);
|
75 VFSDEF_VERSION,
76 "devfs", /* type name string */
77 devfsinit, /* init routine */
78 0, /* flags */
79 NULL /* mount options table prototype */
80 };
81
82 static kmutex_t devfs_lock; /* protects global data */
83 static int devfstype; /* fstype */
84 static dev_t devfsdev; /* the fictious 'device' we live on */
85 static struct devfs_data *devfs_mntinfo; /* linked list of instances */
86
87 /*
88 * Module linkage information
89 */
90 static struct modlfs modlfs = {
91 &mod_fsops, "devices filesystem", &devfs_vfssw
92 };
93
94 static struct modlinkage modlinkage = {
95 MODREV_1, { (void *)&modlfs, NULL }
96 };
97
98 int
99 _init(void)
100 {
101 int e;
102
103 mutex_init(&devfs_lock, "devfs lock", MUTEX_DEFAULT, NULL);
104 dv_node_cache_init();
105 if ((e = mod_install(&modlinkage)) != 0) {
106 dv_node_cache_fini();
107 mutex_destroy(&devfs_lock);
108 return (e);
109 }
110 dcmn_err(("devfs loaded\n"));
111 return (0);
112 }
113
114 int
115 _fini(void)
116 {
117 return (EBUSY);
118 }
119
120 int
121 _info(struct modinfo *modinfop)
122 {
123 return (mod_info(&modlinkage, modinfop));
124 }
125
126 /*ARGSUSED1*/
127 static int
128 devfsinit(int fstype, char *name)
129 {
130 static const fs_operation_def_t devfs_vfsops_template[] = {
131 { VFSNAME_MOUNT, { .vfs_mount = devfs_mount } },
132 { VFSNAME_UNMOUNT, { .vfs_unmount = devfs_unmount } },
133 { VFSNAME_ROOT, { .vfs_root = devfs_root } },
134 { VFSNAME_STATVFS, { .vfs_statvfs = devfs_statvfs } },
135 { VFSNAME_SYNC, { .vfs_sync = fs_sync } },
136 { VFSNAME_MOUNTROOT, { .vfs_mountroot = devfs_mountroot } },
137 { NULL, { NULL } }
138 };
139 int error;
140 int dev;
141 extern major_t getudev(void); /* gack - what a function */
142
143 devfstype = fstype;
144 /*
145 * Associate VFS ops vector with this fstype
146 */
147 error = vfs_setfsops(fstype, devfs_vfsops_template, NULL);
148 if (error != 0) {
149 cmn_err(CE_WARN, "devfsinit: bad vfs ops template");
150 return (error);
151 }
152
153 error = vn_make_ops("dev fs", dv_vnodeops_template, &dv_vnodeops);
154 if (error != 0) {
155 (void) vfs_freevfsops_by_type(fstype);
156 cmn_err(CE_WARN, "devfsinit: bad vnode ops template");
157 return (error);
|