Project

General

Profile

Actions

Bug #1979

closed

mount devfs on ${init_chroot}/dev

Added by y0n3t4n1 about 13 years ago. Updated about 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Hello.

Apparently, booting the system with init_chroot (boot loader variable) set
won't work correctly. The problem is devfs is mounted as /dev, not inside
the chroot()'ed directory, so the processes forked from chroot()'ed init
program can't see the device nodes and gets stuck. The following patch
makes vfs_mountroot_devfs() honor $init_chroot and mounts the devfs under
it instead of hard-coded /dev.

I'd like to push this to crater in a few days if no objection is raised.

Best Regards,
YONETANI Tomokazu.

diff --git a/sys/kern/vfs_conf.c b/sys/kern/vfs_conf.c
index 0730ccc..8d7d40d 100644
--- a/sys/kern/vfs_conf.c
++ b/sys/kern/vfs_conf.c
@ -216,12 +216,24 @ vfs_mountroot_devfs(void)
struct vfsconf *vfsp;
int error;
struct ucred *cred = proc0.p_ucred;
const char *devfs_path, *init_chroot;
+ char *dev_malloced = NULL;

+ if ((init_chroot = kgetenv("init_chroot")) != NULL) {
+ size_t l;

l = strlen(init_chroot) + sizeof("/dev");
+ dev_malloced = kmalloc(l, M_MOUNT, M_WAITOK);
+ ksnprintf(dev_malloced, l, "%s/dev", init_chroot);
+ devfs_path = dev_malloced;
+ } else {
+ devfs_path = "/dev";
+ }
/* * Lookup the requested path and extract the nch and vnode.
*/
error = nlookup_init_raw(&nd,
- "/dev", UIO_SYSSPACE, NLC_FOLLOW,
+ devfs_path, UIO_SYSSPACE, NLC_FOLLOW,
cred, &rootnch);

if (error == 0) {
@ -234,6 +246,9 @ vfs_mountroot_devfs(void)
}
}
}
+ if (dev_malloced != NULL)
+ kfree(dev_malloced, M_MOUNT), dev_malloced = NULL;
+ devfs_path = NULL;
if (error) {
nlookup_done(&nd);
devfs_debug(DEVFS_DEBUG_SHOW, "vfs_mountroot_devfs: nlookup failed, error: %d\n", error);
--
1.7.3.5
Actions #1

Updated by dillon about 13 years ago

:I'd like to push this to crater in a few days if no objection is raised.
:
:Best Regards,
:YONETANI Tomokazu.

I like it!
-Matt
Actions #2

Updated by y0n3t4n1 about 13 years ago

Committed as 358c69e996e6dd4278ea6a92d322b973548c4ce8

Actions

Also available in: Atom PDF