Commit 0036dac9 authored by Kai Germaschewski's avatar Kai Germaschewski

do_mounts: Separate out common root mounting code into do_mount_root()

Small savings, but somewhat nicer anyway.
parent 9b561322
...@@ -225,6 +225,22 @@ static void __init get_fs_names(char *page) ...@@ -225,6 +225,22 @@ static void __init get_fs_names(char *page)
} }
*s = '\0'; *s = '\0';
} }
static int __init do_mount_root(char *name, char *fs, int flags, void *data)
{
int err = sys_mount(name, "/root", fs, flags, data);
if (err)
return err;
sys_chdir("/root");
ROOT_DEV = current->fs->pwdmnt->mnt_sb->s_dev;
printk("VFS: Mounted root (%s filesystem)%s.\n",
current->fs->pwdmnt->mnt_sb->s_type->name,
current->fs->pwdmnt->mnt_sb->s_flags & MS_RDONLY ?
" readonly" : "");
return 0;
}
void __init mount_block_root(char *name, int flags) void __init mount_block_root(char *name, int flags)
{ {
char *fs_names = __getname(); char *fs_names = __getname();
...@@ -233,7 +249,7 @@ void __init mount_block_root(char *name, int flags) ...@@ -233,7 +249,7 @@ void __init mount_block_root(char *name, int flags)
get_fs_names(fs_names); get_fs_names(fs_names);
retry: retry:
for (p = fs_names; *p; p += strlen(p)+1) { for (p = fs_names; *p; p += strlen(p)+1) {
int err = sys_mount(name, "/root", p, flags, root_mount_data); int err = do_mount_root(name, p, flags, root_mount_data);
switch (err) { switch (err) {
case 0: case 0:
goto out; goto out;
...@@ -256,11 +272,6 @@ void __init mount_block_root(char *name, int flags) ...@@ -256,11 +272,6 @@ void __init mount_block_root(char *name, int flags)
panic("VFS: Unable to mount root fs on %s", kdevname(to_kdev_t(ROOT_DEV))); panic("VFS: Unable to mount root fs on %s", kdevname(to_kdev_t(ROOT_DEV)));
out: out:
putname(fs_names); putname(fs_names);
sys_chdir("/root");
ROOT_DEV = current->fs->pwdmnt->mnt_sb->s_dev;
printk("VFS: Mounted root (%s filesystem)%s.\n",
current->fs->pwdmnt->mnt_sb->s_type->name,
(current->fs->pwdmnt->mnt_sb->s_flags & MS_RDONLY) ? " readonly" : "");
} }
#ifdef CONFIG_ROOT_NFS #ifdef CONFIG_ROOT_NFS
...@@ -268,7 +279,8 @@ static int __init mount_nfs_root(void) ...@@ -268,7 +279,8 @@ static int __init mount_nfs_root(void)
{ {
void *data = nfs_root_data(); void *data = nfs_root_data();
if (data && sys_mount("/dev/root","/root","nfs",root_mountflags,data) == 0) if (data &&
do_mount_root("/dev/root", "nfs", root_mountflags, data) == 0)
return 1; return 1;
return 0; return 0;
} }
...@@ -308,12 +320,9 @@ void __init mount_root(void) ...@@ -308,12 +320,9 @@ void __init mount_root(void)
{ {
#ifdef CONFIG_ROOT_NFS #ifdef CONFIG_ROOT_NFS
if (MAJOR(ROOT_DEV) == UNNAMED_MAJOR) { if (MAJOR(ROOT_DEV) == UNNAMED_MAJOR) {
if (mount_nfs_root()) { if (mount_nfs_root())
sys_chdir("/root");
ROOT_DEV = current->fs->pwdmnt->mnt_sb->s_dev;
printk("VFS: Mounted root (nfs filesystem).\n");
return; return;
}
printk(KERN_ERR "VFS: Unable to mount root fs via NFS, trying floppy.\n"); printk(KERN_ERR "VFS: Unable to mount root fs via NFS, trying floppy.\n");
ROOT_DEV = Root_FD0; ROOT_DEV = Root_FD0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment