Commit bdaf8529385d5126ef791e8f1914afff8cd59bcf

Authored by Greg Kroah-Hartman
1 parent a29641883f

[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>

Showing 8 changed files with 10 additions and 172 deletions Side-by-side Diff

include/linux/devfs_fs_kernel.h
... ... @@ -32,9 +32,5 @@
32 32 static inline void devfs_unregister_tape(int num)
33 33 {
34 34 }
35   -static inline void mount_devfs_fs(void)
36   -{
37   - return;
38   -}
39 35 #endif /* _LINUX_DEVFS_FS_KERNEL_H */
... ... @@ -6,7 +6,6 @@
6 6 obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o
7 7  
8 8 mounts-y := do_mounts.o
9   -mounts-$(CONFIG_DEVFS_FS) += do_mounts_devfs.o
10 9 mounts-$(CONFIG_BLK_DEV_RAM) += do_mounts_rd.o
11 10 mounts-$(CONFIG_BLK_DEV_INITRD) += do_mounts_initrd.o
12 11 mounts-$(CONFIG_BLK_DEV_MD) += do_mounts_md.o
... ... @@ -325,7 +325,7 @@
325 325 {
326 326 void *data = nfs_root_data();
327 327  
328   - create_dev("/dev/root", ROOT_DEV, NULL);
  328 + create_dev("/dev/root", ROOT_DEV);
329 329 if (data &&
330 330 do_mount_root("/dev/root", "nfs", root_mountflags, data) == 0)
331 331 return 1;
... ... @@ -386,7 +386,7 @@
386 386 change_floppy("root floppy");
387 387 }
388 388 #endif
389   - create_dev("/dev/root", ROOT_DEV, root_device_name);
  389 + create_dev("/dev/root", ROOT_DEV);
390 390 mount_block_root("/dev/root", root_mountflags);
391 391 }
392 392  
... ... @@ -397,8 +397,6 @@
397 397 {
398 398 int is_floppy;
399 399  
400   - mount_devfs();
401   -
402 400 if (root_delay) {
403 401 printk(KERN_INFO "Waiting %dsec before mounting root device...\n",
404 402 root_delay);
405 403  
... ... @@ -428,10 +426,8 @@
428 426  
429 427 mount_root();
430 428 out:
431   - umount_devfs("/dev");
432 429 sys_mount(".", "/", NULL, MS_MOVE, NULL);
433 430 sys_chroot(".");
434 431 security_sb_post_mountroot();
435   - mount_devfs_fs ();
436 432 }
... ... @@ -15,24 +15,11 @@
15 15 extern int root_mountflags;
16 16 extern char *root_device_name;
17 17  
18   -#ifdef CONFIG_DEVFS_FS
19   -
20   -void mount_devfs(void);
21   -void umount_devfs(char *path);
22   -int create_dev(char *name, dev_t dev, char *devfs_name);
23   -
24   -#else
25   -
26   -static inline void mount_devfs(void) {}
27   -static inline void umount_devfs(const char *path) {}
28   -
29   -static inline int create_dev(char *name, dev_t dev, char *devfs_name)
  18 +static inline int create_dev(char *name, dev_t dev)
30 19 {
31 20 sys_unlink(name);
32 21 return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
33 22 }
34   -
35   -#endif
36 23  
37 24 #if BITS_PER_LONG == 32
38 25 static inline u32 bstat(char *name)
init/do_mounts_devfs.c
1   -
2   -#include <linux/kernel.h>
3   -#include <linux/dirent.h>
4   -#include <linux/string.h>
5   -
6   -#include "do_mounts.h"
7   -
8   -void __init mount_devfs(void)
9   -{
10   - sys_mount("devfs", "/dev", "devfs", 0, NULL);
11   -}
12   -
13   -void __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   - */
22   -static 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   - */
44   -static 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   - */
77   -static 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   - */
119   -int __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   -}
init/do_mounts_initrd.c
... ... @@ -44,7 +44,7 @@
44 44 int pid;
45 45  
46 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 48 /* mount initrd on rootfs' /root */
49 49 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
50 50 sys_mkdir("/old", 0700);
... ... @@ -54,7 +54,6 @@
54 54 sys_chdir("/root");
55 55 sys_mount(".", "/", NULL, MS_MOVE, NULL);
56 56 sys_chroot(".");
57   - mount_devfs_fs ();
58 57  
59 58 current->flags |= PF_NOFREEZE;
60 59 pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
... ... @@ -71,7 +70,6 @@
71 70 sys_chroot(".");
72 71 sys_close(old_fd);
73 72 sys_close(root_fd);
74   - umount_devfs("/old/dev");
75 73  
76 74 if (new_decode_dev(real_root_dev) == Root_RAM0) {
77 75 sys_chdir("/old");
... ... @@ -107,7 +105,7 @@
107 105 int __init initrd_load(void)
108 106 {
109 107 if (mount_initrd) {
110   - create_dev("/dev/ram", Root_RAM0, NULL);
  108 + create_dev("/dev/ram", Root_RAM0);
111 109 /*
112 110 * Load the initrd data into /dev/ram0. Execute it as initrd
113 111 * unless /dev/ram0 is supposed to be our actual root device,
... ... @@ -125,19 +125,18 @@
125 125 int err = 0;
126 126 char *devname;
127 127 mdu_disk_info_t dinfo;
128   - char name[16], devfs_name[16];
  128 + char name[16];
129 129  
130 130 minor = md_setup_args[ent].minor;
131 131 partitioned = md_setup_args[ent].partitioned;
132 132 devname = md_setup_args[ent].device_names;
133 133  
134 134 sprintf(name, "/dev/md%s%d", partitioned?"_d":"", minor);
135   - sprintf(devfs_name, "/dev/md/%s%d", partitioned?"d":"", minor);
136 135 if (partitioned)
137 136 dev = MKDEV(mdp_major, minor << MdpMinorShift);
138 137 else
139 138 dev = MKDEV(MD_MAJOR, minor);
140   - create_dev(name, dev, devfs_name);
  139 + create_dev(name, dev);
141 140 for (i = 0; i < MD_SB_DISKS && devname != 0; i++) {
142 141 char *p;
143 142 char comp_name[64];
... ... @@ -272,7 +271,7 @@
272 271  
273 272 void __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 275 if (raid_noautodetect)
277 276 printk(KERN_INFO "md: Skipping autodetection of RAID arrays. (raid=noautodetect)\n");
278 277 else {
... ... @@ -262,8 +262,8 @@
262 262 {
263 263 if (rd_prompt)
264 264 change_floppy("root floppy disk to be loaded into RAM disk");
265   - create_dev("/dev/root", ROOT_DEV, root_device_name);
266   - create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, n), NULL);
  265 + create_dev("/dev/root", ROOT_DEV);
  266 + create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, n));
267 267 return rd_load_image("/dev/root");
268 268 }
269 269