aboutsummaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-06-29 17:19:21 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-29 17:19:21 -0400
commit602cada851b28c5792339786efe872fbdc1f5d41 (patch)
tree233d474b74d6038b5bb54a07ad91dd1bb10b0218 /init
parent82991c6f2c361acc17279b8124d9bf1878973435 (diff)
parentfee68d1cc0d9bd863e51c16cdcd707737b16bb38 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/devfs-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/devfs-2.6: (22 commits) [PATCH] devfs: Remove it from the feature_removal.txt file [PATCH] devfs: Last little devfs cleanups throughout the kernel tree. [PATCH] devfs: Rename TTY_DRIVER_NO_DEVFS to TTY_DRIVER_DYNAMIC_DEV [PATCH] devfs: Remove the tty_driver devfs_name field as it's no longer needed [PATCH] devfs: Remove the line_driver devfs_name field as it's no longer needed [PATCH] devfs: Remove the videodevice devfs_name field as it's no longer needed [PATCH] devfs: Remove the gendisk devfs_name field as it's no longer needed [PATCH] devfs: Remove the miscdevice devfs_name field as it's no longer needed [PATCH] devfs: Remove the devfs_fs_kernel.h file from the tree [PATCH] devfs: Remove devfs_remove() function from the kernel tree [PATCH] devfs: Remove devfs_mk_cdev() function from the kernel tree [PATCH] devfs: Remove devfs_mk_bdev() function from the kernel tree [PATCH] devfs: Remove devfs_mk_symlink() function from the kernel tree [PATCH] devfs: Remove devfs_mk_dir() function from the kernel tree [PATCH] devfs: Remove devfs_*_tape() functions from the kernel tree [PATCH] devfs: Remove devfs support from the sound subsystem [PATCH] devfs: Remove devfs support from the ide subsystem. [PATCH] devfs: Remove devfs support from the serial subsystem [PATCH] devfs: Remove devfs from the init code [PATCH] devfs: Remove devfs from the partition code ...
Diffstat (limited to 'init')
-rw-r--r--init/Makefile1
-rw-r--r--init/do_mounts.c8
-rw-r--r--init/do_mounts.h16
-rw-r--r--init/do_mounts_devfs.c137
-rw-r--r--init/do_mounts_initrd.c6
-rw-r--r--init/do_mounts_md.c7
-rw-r--r--init/do_mounts_rd.c4
-rw-r--r--init/main.c1
8 files changed, 10 insertions, 170 deletions
diff --git a/init/Makefile b/init/Makefile
index a2300078f2b7..633a268d270d 100644
--- a/init/Makefile
+++ b/init/Makefile
@@ -6,7 +6,6 @@ obj-y := main.o version.o mounts.o initramfs.o
6obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o 6obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o
7 7
8mounts-y := do_mounts.o 8mounts-y := do_mounts.o
9mounts-$(CONFIG_DEVFS_FS) += do_mounts_devfs.o
10mounts-$(CONFIG_BLK_DEV_RAM) += do_mounts_rd.o 9mounts-$(CONFIG_BLK_DEV_RAM) += do_mounts_rd.o
11mounts-$(CONFIG_BLK_DEV_INITRD) += do_mounts_initrd.o 10mounts-$(CONFIG_BLK_DEV_INITRD) += do_mounts_initrd.o
12mounts-$(CONFIG_BLK_DEV_MD) += do_mounts_md.o 11mounts-$(CONFIG_BLK_DEV_MD) += do_mounts_md.o
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 21b3b8f33a72..94aeec7aa917 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -325,7 +325,7 @@ static int __init mount_nfs_root(void)
325{ 325{
326 void *data = nfs_root_data(); 326 void *data = nfs_root_data();
327 327
328 create_dev("/dev/root", ROOT_DEV, NULL); 328 create_dev("/dev/root", ROOT_DEV);
329 if (data && 329 if (data &&
330 do_mount_root("/dev/root", "nfs", root_mountflags, data) == 0) 330 do_mount_root("/dev/root", "nfs", root_mountflags, data) == 0)
331 return 1; 331 return 1;
@@ -386,7 +386,7 @@ void __init mount_root(void)
386 change_floppy("root floppy"); 386 change_floppy("root floppy");
387 } 387 }
388#endif 388#endif
389 create_dev("/dev/root", ROOT_DEV, root_device_name); 389 create_dev("/dev/root", ROOT_DEV);
390 mount_block_root("/dev/root", root_mountflags); 390 mount_block_root("/dev/root", root_mountflags);
391} 391}
392 392
@@ -397,8 +397,6 @@ void __init prepare_namespace(void)
397{ 397{
398 int is_floppy; 398 int is_floppy;
399 399
400 mount_devfs();
401
402 if (root_delay) { 400 if (root_delay) {
403 printk(KERN_INFO "Waiting %dsec before mounting root device...\n", 401 printk(KERN_INFO "Waiting %dsec before mounting root device...\n",
404 root_delay); 402 root_delay);
@@ -428,10 +426,8 @@ void __init prepare_namespace(void)
428 426
429 mount_root(); 427 mount_root();
430out: 428out:
431 umount_devfs("/dev");
432 sys_mount(".", "/", NULL, MS_MOVE, NULL); 429 sys_mount(".", "/", NULL, MS_MOVE, NULL);
433 sys_chroot("."); 430 sys_chroot(".");
434 security_sb_post_mountroot(); 431 security_sb_post_mountroot();
435 mount_devfs_fs ();
436} 432}
437 433
diff --git a/init/do_mounts.h b/init/do_mounts.h
index e0a7ac9649e1..e7f2e7fa066e 100644
--- a/init/do_mounts.h
+++ b/init/do_mounts.h
@@ -1,6 +1,5 @@
1#include <linux/config.h> 1#include <linux/config.h>
2#include <linux/kernel.h> 2#include <linux/kernel.h>
3#include <linux/devfs_fs_kernel.h>
4#include <linux/init.h> 3#include <linux/init.h>
5#include <linux/syscalls.h> 4#include <linux/syscalls.h>
6#include <linux/unistd.h> 5#include <linux/unistd.h>
@@ -15,25 +14,12 @@ void mount_root(void);
15extern int root_mountflags; 14extern int root_mountflags;
16extern char *root_device_name; 15extern char *root_device_name;
17 16
18#ifdef CONFIG_DEVFS_FS 17static inline int create_dev(char *name, dev_t dev)
19
20void mount_devfs(void);
21void umount_devfs(char *path);
22int create_dev(char *name, dev_t dev, char *devfs_name);
23
24#else
25
26static inline void mount_devfs(void) {}
27static inline void umount_devfs(const char *path) {}
28
29static inline int create_dev(char *name, dev_t dev, char *devfs_name)
30{ 18{
31 sys_unlink(name); 19 sys_unlink(name);
32 return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev)); 20 return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
33} 21}
34 22
35#endif
36
37#if BITS_PER_LONG == 32 23#if BITS_PER_LONG == 32
38static inline u32 bstat(char *name) 24static inline u32 bstat(char *name)
39{ 25{
diff --git a/init/do_mounts_devfs.c b/init/do_mounts_devfs.c
deleted file mode 100644
index cc526474690a..000000000000
--- a/init/do_mounts_devfs.c
+++ /dev/null
@@ -1,137 +0,0 @@
1
2#include <linux/kernel.h>
3#include <linux/dirent.h>
4#include <linux/string.h>
5
6#include "do_mounts.h"
7
8void __init mount_devfs(void)
9{
10 sys_mount("devfs", "/dev", "devfs", 0, NULL);
11}
12
13void __init umount_devfs(char *path)
14{
15 sys_umount(path, 0);
16}
17
18/*
19 * If the dir will fit in *buf, return its length. If it won't fit, return
20 * zero. Return -ve on error.
21 */
22static int __init do_read_dir(int fd, void *buf, int len)
23{
24 long bytes, n;
25 char *p = buf;
26 sys_lseek(fd, 0, 0);
27
28 for (bytes = 0; bytes < len; bytes += n) {
29 n = sys_getdents64(fd, (struct linux_dirent64 *)(p + bytes),
30 len - bytes);
31 if (n < 0)
32 return n;
33 if (n == 0)
34 return bytes;
35 }
36 return 0;
37}
38
39/*
40 * Try to read all of a directory. Returns the contents at *p, which
41 * is kmalloced memory. Returns the number of bytes read at *len. Returns
42 * NULL on error.
43 */
44static void * __init read_dir(char *path, int *len)
45{
46 int size;
47 int fd = sys_open(path, 0, 0);
48
49 *len = 0;
50 if (fd < 0)
51 return NULL;
52
53 for (size = 1 << 9; size <= (PAGE_SIZE << MAX_ORDER); size <<= 1) {
54 void *p = kmalloc(size, GFP_KERNEL);
55 int n;
56 if (!p)
57 break;
58 n = do_read_dir(fd, p, size);
59 if (n > 0) {
60 sys_close(fd);
61 *len = n;
62 return p;
63 }
64 kfree(p);
65 if (n == -EINVAL)
66 continue; /* Try a larger buffer */
67 if (n < 0)
68 break;
69 }
70 sys_close(fd);
71 return NULL;
72}
73
74/*
75 * recursively scan <path>, looking for a device node of type <dev>
76 */
77static int __init find_in_devfs(char *path, unsigned dev)
78{
79 char *end = path + strlen(path);
80 int rest = path + 64 - end;
81 int size;
82 char *p = read_dir(path, &size);
83 char *s;
84
85 if (!p)
86 return -1;
87 for (s = p; s < p + size; s += ((struct linux_dirent64 *)s)->d_reclen) {
88 struct linux_dirent64 *d = (struct linux_dirent64 *)s;
89 if (strlen(d->d_name) + 2 > rest)
90 continue;
91 switch (d->d_type) {
92 case DT_BLK:
93 sprintf(end, "/%s", d->d_name);
94 if (bstat(path) != dev)
95 break;
96 kfree(p);
97 return 0;
98 case DT_DIR:
99 if (strcmp(d->d_name, ".") == 0)
100 break;
101 if (strcmp(d->d_name, "..") == 0)
102 break;
103 sprintf(end, "/%s", d->d_name);
104 if (find_in_devfs(path, dev) < 0)
105 break;
106 kfree(p);
107 return 0;
108 }
109 }
110 kfree(p);
111 return -1;
112}
113
114/*
115 * create a device node called <name> which points to
116 * <devfs_name> if possible, otherwise find a device node
117 * which matches <dev> and make <name> a symlink pointing to it.
118 */
119int __init create_dev(char *name, dev_t dev, char *devfs_name)
120{
121 char path[64];
122
123 sys_unlink(name);
124 if (devfs_name && devfs_name[0]) {
125 if (strncmp(devfs_name, "/dev/", 5) == 0)
126 devfs_name += 5;
127 sprintf(path, "/dev/%s", devfs_name);
128 if (sys_access(path, 0) == 0)
129 return sys_symlink(devfs_name, name);
130 }
131 if (!dev)
132 return -1;
133 strcpy(path, "/dev");
134 if (find_in_devfs(path, new_encode_dev(dev)) < 0)
135 return -1;
136 return sys_symlink(path + 5, name);
137}
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index 405f9031af87..a06f037fa000 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -44,7 +44,7 @@ static void __init handle_initrd(void)
44 int pid; 44 int pid;
45 45
46 real_root_dev = new_encode_dev(ROOT_DEV); 46 real_root_dev = new_encode_dev(ROOT_DEV);
47 create_dev("/dev/root.old", Root_RAM0, NULL); 47 create_dev("/dev/root.old", Root_RAM0);
48 /* mount initrd on rootfs' /root */ 48 /* mount initrd on rootfs' /root */
49 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY); 49 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
50 sys_mkdir("/old", 0700); 50 sys_mkdir("/old", 0700);
@@ -54,7 +54,6 @@ static void __init handle_initrd(void)
54 sys_chdir("/root"); 54 sys_chdir("/root");
55 sys_mount(".", "/", NULL, MS_MOVE, NULL); 55 sys_mount(".", "/", NULL, MS_MOVE, NULL);
56 sys_chroot("."); 56 sys_chroot(".");
57 mount_devfs_fs ();
58 57
59 current->flags |= PF_NOFREEZE; 58 current->flags |= PF_NOFREEZE;
60 pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD); 59 pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
@@ -71,7 +70,6 @@ static void __init handle_initrd(void)
71 sys_chroot("."); 70 sys_chroot(".");
72 sys_close(old_fd); 71 sys_close(old_fd);
73 sys_close(root_fd); 72 sys_close(root_fd);
74 umount_devfs("/old/dev");
75 73
76 if (new_decode_dev(real_root_dev) == Root_RAM0) { 74 if (new_decode_dev(real_root_dev) == Root_RAM0) {
77 sys_chdir("/old"); 75 sys_chdir("/old");
@@ -107,7 +105,7 @@ static void __init handle_initrd(void)
107int __init initrd_load(void) 105int __init initrd_load(void)
108{ 106{
109 if (mount_initrd) { 107 if (mount_initrd) {
110 create_dev("/dev/ram", Root_RAM0, NULL); 108 create_dev("/dev/ram", Root_RAM0);
111 /* 109 /*
112 * Load the initrd data into /dev/ram0. Execute it as initrd 110 * Load the initrd data into /dev/ram0. Execute it as initrd
113 * unless /dev/ram0 is supposed to be our actual root device, 111 * unless /dev/ram0 is supposed to be our actual root device,
diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
index f6f36806f84a..2429e1bf8c60 100644
--- a/init/do_mounts_md.c
+++ b/init/do_mounts_md.c
@@ -125,19 +125,18 @@ static void __init md_setup_drive(void)
125 int err = 0; 125 int err = 0;
126 char *devname; 126 char *devname;
127 mdu_disk_info_t dinfo; 127 mdu_disk_info_t dinfo;
128 char name[16], devfs_name[16]; 128 char name[16];
129 129
130 minor = md_setup_args[ent].minor; 130 minor = md_setup_args[ent].minor;
131 partitioned = md_setup_args[ent].partitioned; 131 partitioned = md_setup_args[ent].partitioned;
132 devname = md_setup_args[ent].device_names; 132 devname = md_setup_args[ent].device_names;
133 133
134 sprintf(name, "/dev/md%s%d", partitioned?"_d":"", minor); 134 sprintf(name, "/dev/md%s%d", partitioned?"_d":"", minor);
135 sprintf(devfs_name, "/dev/md/%s%d", partitioned?"d":"", minor);
136 if (partitioned) 135 if (partitioned)
137 dev = MKDEV(mdp_major, minor << MdpMinorShift); 136 dev = MKDEV(mdp_major, minor << MdpMinorShift);
138 else 137 else
139 dev = MKDEV(MD_MAJOR, minor); 138 dev = MKDEV(MD_MAJOR, minor);
140 create_dev(name, dev, devfs_name); 139 create_dev(name, dev);
141 for (i = 0; i < MD_SB_DISKS && devname != 0; i++) { 140 for (i = 0; i < MD_SB_DISKS && devname != 0; i++) {
142 char *p; 141 char *p;
143 char comp_name[64]; 142 char comp_name[64];
@@ -272,7 +271,7 @@ __setup("md=", md_setup);
272 271
273void __init md_run_setup(void) 272void __init md_run_setup(void)
274{ 273{
275 create_dev("/dev/md0", MKDEV(MD_MAJOR, 0), "md/0"); 274 create_dev("/dev/md0", MKDEV(MD_MAJOR, 0));
276 if (raid_noautodetect) 275 if (raid_noautodetect)
277 printk(KERN_INFO "md: Skipping autodetection of RAID arrays. (raid=noautodetect)\n"); 276 printk(KERN_INFO "md: Skipping autodetection of RAID arrays. (raid=noautodetect)\n");
278 else { 277 else {
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index c2683fcd792d..ed652f40f075 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -262,8 +262,8 @@ int __init rd_load_disk(int n)
262{ 262{
263 if (rd_prompt) 263 if (rd_prompt)
264 change_floppy("root floppy disk to be loaded into RAM disk"); 264 change_floppy("root floppy disk to be loaded into RAM disk");
265 create_dev("/dev/root", ROOT_DEV, root_device_name); 265 create_dev("/dev/root", ROOT_DEV);
266 create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, n), NULL); 266 create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, n));
267 return rd_load_image("/dev/root"); 267 return rd_load_image("/dev/root");
268} 268}
269 269
diff --git a/init/main.c b/init/main.c
index 0d57f6ccb63a..bce0eb7f4f8f 100644
--- a/init/main.c
+++ b/init/main.c
@@ -15,7 +15,6 @@
15#include <linux/types.h> 15#include <linux/types.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
18#include <linux/devfs_fs_kernel.h>
19#include <linux/kernel.h> 18#include <linux/kernel.h>
20#include <linux/syscalls.h> 19#include <linux/syscalls.h>
21#include <linux/string.h> 20#include <linux/string.h>