[PATCH] devfs: Remove devfs from the init code
This patch removes the devfs code from the init/ directory. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
a29641883f
commit
bdaf852938
|
@ -32,8 +32,4 @@ static inline int devfs_register_tape(const char *name)
|
||||||
static inline void devfs_unregister_tape(int num)
|
static inline void devfs_unregister_tape(int num)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
static inline void mount_devfs_fs(void)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif /* _LINUX_DEVFS_FS_KERNEL_H */
|
#endif /* _LINUX_DEVFS_FS_KERNEL_H */
|
||||||
|
|
|
@ -6,7 +6,6 @@ obj-y := main.o version.o mounts.o initramfs.o
|
||||||
obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o
|
obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o
|
||||||
|
|
||||||
mounts-y := do_mounts.o
|
mounts-y := do_mounts.o
|
||||||
mounts-$(CONFIG_DEVFS_FS) += do_mounts_devfs.o
|
|
||||||
mounts-$(CONFIG_BLK_DEV_RAM) += do_mounts_rd.o
|
mounts-$(CONFIG_BLK_DEV_RAM) += do_mounts_rd.o
|
||||||
mounts-$(CONFIG_BLK_DEV_INITRD) += do_mounts_initrd.o
|
mounts-$(CONFIG_BLK_DEV_INITRD) += do_mounts_initrd.o
|
||||||
mounts-$(CONFIG_BLK_DEV_MD) += do_mounts_md.o
|
mounts-$(CONFIG_BLK_DEV_MD) += do_mounts_md.o
|
||||||
|
|
|
@ -325,7 +325,7 @@ static int __init mount_nfs_root(void)
|
||||||
{
|
{
|
||||||
void *data = nfs_root_data();
|
void *data = nfs_root_data();
|
||||||
|
|
||||||
create_dev("/dev/root", ROOT_DEV, NULL);
|
create_dev("/dev/root", ROOT_DEV);
|
||||||
if (data &&
|
if (data &&
|
||||||
do_mount_root("/dev/root", "nfs", root_mountflags, data) == 0)
|
do_mount_root("/dev/root", "nfs", root_mountflags, data) == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -386,7 +386,7 @@ void __init mount_root(void)
|
||||||
change_floppy("root floppy");
|
change_floppy("root floppy");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
create_dev("/dev/root", ROOT_DEV, root_device_name);
|
create_dev("/dev/root", ROOT_DEV);
|
||||||
mount_block_root("/dev/root", root_mountflags);
|
mount_block_root("/dev/root", root_mountflags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,8 +397,6 @@ void __init prepare_namespace(void)
|
||||||
{
|
{
|
||||||
int is_floppy;
|
int is_floppy;
|
||||||
|
|
||||||
mount_devfs();
|
|
||||||
|
|
||||||
if (root_delay) {
|
if (root_delay) {
|
||||||
printk(KERN_INFO "Waiting %dsec before mounting root device...\n",
|
printk(KERN_INFO "Waiting %dsec before mounting root device...\n",
|
||||||
root_delay);
|
root_delay);
|
||||||
|
@ -428,10 +426,8 @@ void __init prepare_namespace(void)
|
||||||
|
|
||||||
mount_root();
|
mount_root();
|
||||||
out:
|
out:
|
||||||
umount_devfs("/dev");
|
|
||||||
sys_mount(".", "/", NULL, MS_MOVE, NULL);
|
sys_mount(".", "/", NULL, MS_MOVE, NULL);
|
||||||
sys_chroot(".");
|
sys_chroot(".");
|
||||||
security_sb_post_mountroot();
|
security_sb_post_mountroot();
|
||||||
mount_devfs_fs ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,25 +15,12 @@ void mount_root(void);
|
||||||
extern int root_mountflags;
|
extern int root_mountflags;
|
||||||
extern char *root_device_name;
|
extern char *root_device_name;
|
||||||
|
|
||||||
#ifdef CONFIG_DEVFS_FS
|
static inline int create_dev(char *name, dev_t dev)
|
||||||
|
|
||||||
void mount_devfs(void);
|
|
||||||
void umount_devfs(char *path);
|
|
||||||
int create_dev(char *name, dev_t dev, char *devfs_name);
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
static inline void mount_devfs(void) {}
|
|
||||||
static inline void umount_devfs(const char *path) {}
|
|
||||||
|
|
||||||
static inline int create_dev(char *name, dev_t dev, char *devfs_name)
|
|
||||||
{
|
{
|
||||||
sys_unlink(name);
|
sys_unlink(name);
|
||||||
return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
|
return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BITS_PER_LONG == 32
|
#if BITS_PER_LONG == 32
|
||||||
static inline u32 bstat(char *name)
|
static inline u32 bstat(char *name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,137 +0,0 @@
|
||||||
|
|
||||||
#include <linux/kernel.h>
|
|
||||||
#include <linux/dirent.h>
|
|
||||||
#include <linux/string.h>
|
|
||||||
|
|
||||||
#include "do_mounts.h"
|
|
||||||
|
|
||||||
void __init mount_devfs(void)
|
|
||||||
{
|
|
||||||
sys_mount("devfs", "/dev", "devfs", 0, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void __init umount_devfs(char *path)
|
|
||||||
{
|
|
||||||
sys_umount(path, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the dir will fit in *buf, return its length. If it won't fit, return
|
|
||||||
* zero. Return -ve on error.
|
|
||||||
*/
|
|
||||||
static int __init do_read_dir(int fd, void *buf, int len)
|
|
||||||
{
|
|
||||||
long bytes, n;
|
|
||||||
char *p = buf;
|
|
||||||
sys_lseek(fd, 0, 0);
|
|
||||||
|
|
||||||
for (bytes = 0; bytes < len; bytes += n) {
|
|
||||||
n = sys_getdents64(fd, (struct linux_dirent64 *)(p + bytes),
|
|
||||||
len - bytes);
|
|
||||||
if (n < 0)
|
|
||||||
return n;
|
|
||||||
if (n == 0)
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Try to read all of a directory. Returns the contents at *p, which
|
|
||||||
* is kmalloced memory. Returns the number of bytes read at *len. Returns
|
|
||||||
* NULL on error.
|
|
||||||
*/
|
|
||||||
static void * __init read_dir(char *path, int *len)
|
|
||||||
{
|
|
||||||
int size;
|
|
||||||
int fd = sys_open(path, 0, 0);
|
|
||||||
|
|
||||||
*len = 0;
|
|
||||||
if (fd < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
for (size = 1 << 9; size <= (PAGE_SIZE << MAX_ORDER); size <<= 1) {
|
|
||||||
void *p = kmalloc(size, GFP_KERNEL);
|
|
||||||
int n;
|
|
||||||
if (!p)
|
|
||||||
break;
|
|
||||||
n = do_read_dir(fd, p, size);
|
|
||||||
if (n > 0) {
|
|
||||||
sys_close(fd);
|
|
||||||
*len = n;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
kfree(p);
|
|
||||||
if (n == -EINVAL)
|
|
||||||
continue; /* Try a larger buffer */
|
|
||||||
if (n < 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
sys_close(fd);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* recursively scan <path>, looking for a device node of type <dev>
|
|
||||||
*/
|
|
||||||
static int __init find_in_devfs(char *path, unsigned dev)
|
|
||||||
{
|
|
||||||
char *end = path + strlen(path);
|
|
||||||
int rest = path + 64 - end;
|
|
||||||
int size;
|
|
||||||
char *p = read_dir(path, &size);
|
|
||||||
char *s;
|
|
||||||
|
|
||||||
if (!p)
|
|
||||||
return -1;
|
|
||||||
for (s = p; s < p + size; s += ((struct linux_dirent64 *)s)->d_reclen) {
|
|
||||||
struct linux_dirent64 *d = (struct linux_dirent64 *)s;
|
|
||||||
if (strlen(d->d_name) + 2 > rest)
|
|
||||||
continue;
|
|
||||||
switch (d->d_type) {
|
|
||||||
case DT_BLK:
|
|
||||||
sprintf(end, "/%s", d->d_name);
|
|
||||||
if (bstat(path) != dev)
|
|
||||||
break;
|
|
||||||
kfree(p);
|
|
||||||
return 0;
|
|
||||||
case DT_DIR:
|
|
||||||
if (strcmp(d->d_name, ".") == 0)
|
|
||||||
break;
|
|
||||||
if (strcmp(d->d_name, "..") == 0)
|
|
||||||
break;
|
|
||||||
sprintf(end, "/%s", d->d_name);
|
|
||||||
if (find_in_devfs(path, dev) < 0)
|
|
||||||
break;
|
|
||||||
kfree(p);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
kfree(p);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* create a device node called <name> which points to
|
|
||||||
* <devfs_name> if possible, otherwise find a device node
|
|
||||||
* which matches <dev> and make <name> a symlink pointing to it.
|
|
||||||
*/
|
|
||||||
int __init create_dev(char *name, dev_t dev, char *devfs_name)
|
|
||||||
{
|
|
||||||
char path[64];
|
|
||||||
|
|
||||||
sys_unlink(name);
|
|
||||||
if (devfs_name && devfs_name[0]) {
|
|
||||||
if (strncmp(devfs_name, "/dev/", 5) == 0)
|
|
||||||
devfs_name += 5;
|
|
||||||
sprintf(path, "/dev/%s", devfs_name);
|
|
||||||
if (sys_access(path, 0) == 0)
|
|
||||||
return sys_symlink(devfs_name, name);
|
|
||||||
}
|
|
||||||
if (!dev)
|
|
||||||
return -1;
|
|
||||||
strcpy(path, "/dev");
|
|
||||||
if (find_in_devfs(path, new_encode_dev(dev)) < 0)
|
|
||||||
return -1;
|
|
||||||
return sys_symlink(path + 5, name);
|
|
||||||
}
|
|
|
@ -44,7 +44,7 @@ static void __init handle_initrd(void)
|
||||||
int pid;
|
int pid;
|
||||||
|
|
||||||
real_root_dev = new_encode_dev(ROOT_DEV);
|
real_root_dev = new_encode_dev(ROOT_DEV);
|
||||||
create_dev("/dev/root.old", Root_RAM0, NULL);
|
create_dev("/dev/root.old", Root_RAM0);
|
||||||
/* mount initrd on rootfs' /root */
|
/* mount initrd on rootfs' /root */
|
||||||
mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
|
mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
|
||||||
sys_mkdir("/old", 0700);
|
sys_mkdir("/old", 0700);
|
||||||
|
@ -54,7 +54,6 @@ static void __init handle_initrd(void)
|
||||||
sys_chdir("/root");
|
sys_chdir("/root");
|
||||||
sys_mount(".", "/", NULL, MS_MOVE, NULL);
|
sys_mount(".", "/", NULL, MS_MOVE, NULL);
|
||||||
sys_chroot(".");
|
sys_chroot(".");
|
||||||
mount_devfs_fs ();
|
|
||||||
|
|
||||||
current->flags |= PF_NOFREEZE;
|
current->flags |= PF_NOFREEZE;
|
||||||
pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
|
pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
|
||||||
|
@ -71,7 +70,6 @@ static void __init handle_initrd(void)
|
||||||
sys_chroot(".");
|
sys_chroot(".");
|
||||||
sys_close(old_fd);
|
sys_close(old_fd);
|
||||||
sys_close(root_fd);
|
sys_close(root_fd);
|
||||||
umount_devfs("/old/dev");
|
|
||||||
|
|
||||||
if (new_decode_dev(real_root_dev) == Root_RAM0) {
|
if (new_decode_dev(real_root_dev) == Root_RAM0) {
|
||||||
sys_chdir("/old");
|
sys_chdir("/old");
|
||||||
|
@ -107,7 +105,7 @@ static void __init handle_initrd(void)
|
||||||
int __init initrd_load(void)
|
int __init initrd_load(void)
|
||||||
{
|
{
|
||||||
if (mount_initrd) {
|
if (mount_initrd) {
|
||||||
create_dev("/dev/ram", Root_RAM0, NULL);
|
create_dev("/dev/ram", Root_RAM0);
|
||||||
/*
|
/*
|
||||||
* Load the initrd data into /dev/ram0. Execute it as initrd
|
* Load the initrd data into /dev/ram0. Execute it as initrd
|
||||||
* unless /dev/ram0 is supposed to be our actual root device,
|
* unless /dev/ram0 is supposed to be our actual root device,
|
||||||
|
|
|
@ -125,19 +125,18 @@ static void __init md_setup_drive(void)
|
||||||
int err = 0;
|
int err = 0;
|
||||||
char *devname;
|
char *devname;
|
||||||
mdu_disk_info_t dinfo;
|
mdu_disk_info_t dinfo;
|
||||||
char name[16], devfs_name[16];
|
char name[16];
|
||||||
|
|
||||||
minor = md_setup_args[ent].minor;
|
minor = md_setup_args[ent].minor;
|
||||||
partitioned = md_setup_args[ent].partitioned;
|
partitioned = md_setup_args[ent].partitioned;
|
||||||
devname = md_setup_args[ent].device_names;
|
devname = md_setup_args[ent].device_names;
|
||||||
|
|
||||||
sprintf(name, "/dev/md%s%d", partitioned?"_d":"", minor);
|
sprintf(name, "/dev/md%s%d", partitioned?"_d":"", minor);
|
||||||
sprintf(devfs_name, "/dev/md/%s%d", partitioned?"d":"", minor);
|
|
||||||
if (partitioned)
|
if (partitioned)
|
||||||
dev = MKDEV(mdp_major, minor << MdpMinorShift);
|
dev = MKDEV(mdp_major, minor << MdpMinorShift);
|
||||||
else
|
else
|
||||||
dev = MKDEV(MD_MAJOR, minor);
|
dev = MKDEV(MD_MAJOR, minor);
|
||||||
create_dev(name, dev, devfs_name);
|
create_dev(name, dev);
|
||||||
for (i = 0; i < MD_SB_DISKS && devname != 0; i++) {
|
for (i = 0; i < MD_SB_DISKS && devname != 0; i++) {
|
||||||
char *p;
|
char *p;
|
||||||
char comp_name[64];
|
char comp_name[64];
|
||||||
|
@ -272,7 +271,7 @@ __setup("md=", md_setup);
|
||||||
|
|
||||||
void __init md_run_setup(void)
|
void __init md_run_setup(void)
|
||||||
{
|
{
|
||||||
create_dev("/dev/md0", MKDEV(MD_MAJOR, 0), "md/0");
|
create_dev("/dev/md0", MKDEV(MD_MAJOR, 0));
|
||||||
if (raid_noautodetect)
|
if (raid_noautodetect)
|
||||||
printk(KERN_INFO "md: Skipping autodetection of RAID arrays. (raid=noautodetect)\n");
|
printk(KERN_INFO "md: Skipping autodetection of RAID arrays. (raid=noautodetect)\n");
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -262,8 +262,8 @@ int __init rd_load_disk(int n)
|
||||||
{
|
{
|
||||||
if (rd_prompt)
|
if (rd_prompt)
|
||||||
change_floppy("root floppy disk to be loaded into RAM disk");
|
change_floppy("root floppy disk to be loaded into RAM disk");
|
||||||
create_dev("/dev/root", ROOT_DEV, root_device_name);
|
create_dev("/dev/root", ROOT_DEV);
|
||||||
create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, n), NULL);
|
create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, n));
|
||||||
return rd_load_image("/dev/root");
|
return rd_load_image("/dev/root");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue