MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vfs_mountroot_devfs

Function vfs_mountroot_devfs

freebsd/kern/vfs_mountroot.c:249–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249static int
250vfs_mountroot_devfs(struct thread *td, struct mount **mpp)
251{
252 struct vfsoptlist *opts;
253 struct vfsconf *vfsp;
254 struct mount *mp;
255 int error;
256
257 *mpp = NULL;
258
259 if (rootdevmp != NULL) {
260 /*
261 * Already have /dev; this happens during rerooting.
262 */
263 error = vfs_busy(rootdevmp, 0);
264 if (error != 0)
265 return (error);
266 *mpp = rootdevmp;
267 } else {
268 vfsp = vfs_byname("devfs");
269 KASSERT(vfsp != NULL, ("Could not find devfs by name"));
270 if (vfsp == NULL)
271 return (ENOENT);
272
273 mp = vfs_mount_alloc(NULLVP, vfsp, "/dev", td->td_ucred);
274
275 error = VFS_MOUNT(mp);
276 KASSERT(error == 0, ("VFS_MOUNT(devfs) failed %d", error));
277 if (error)
278 return (error);
279
280 error = VFS_STATFS(mp, &mp->mnt_stat);
281 KASSERT(error == 0, ("VFS_STATFS(devfs) failed %d", error));
282 if (error)
283 return (error);
284
285 opts = malloc(sizeof(struct vfsoptlist), M_MOUNT, M_WAITOK);
286 TAILQ_INIT(opts);
287 mp->mnt_opt = opts;
288
289 mtx_lock(&mountlist_mtx);
290 TAILQ_INSERT_HEAD(&mountlist, mp, mnt_list);
291 mtx_unlock(&mountlist_mtx);
292
293 *mpp = mp;
294 rootdevmp = mp;
295 vfs_op_exit(mp);
296 }
297
298 set_rootvnode();
299
300 error = kern_symlinkat(td, "/", AT_FDCWD, "dev", UIO_SYSSPACE);
301 if (error)
302 printf("kern_symlink /dev -> / returns %d\n", error);
303
304 return (error);
305}
306

Callers 1

vfs_mountrootFunction · 0.85

Calls 10

vfs_busyFunction · 0.85
vfs_bynameFunction · 0.85
vfs_mount_allocFunction · 0.85
mallocFunction · 0.85
vfs_op_exitFunction · 0.85
kern_symlinkatFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70
set_rootvnodeFunction · 0.70
printfFunction · 0.70

Tested by

no test coverage detected