aboutsummaryrefslogtreecommitdiffstats
path: root/init/do_mounts.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 11:34:42 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 11:35:13 -0500
commitdf8dc74e8a383eaf2d9b44b80a71ec6f0e52b42e (patch)
treebc3799a43e8b94fa84b32e37b1c124d5e4868f50 /init/do_mounts.c
parent556a169dab38b5100df6f4a45b655dddd3db94c1 (diff)
parent4a3ad20ccd8f4d2a0535cf98fa83f7b561ba59a9 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6
This can be broken down into these major areas: - Documentation updates (language translations and fixes, as well as kobject and kset documenatation updates.) - major kset/kobject/ktype rework and fixes. This cleans up the kset and kobject and ktype relationship and architecture, making sense of things now, and good documenation and samples are provided for others to use. Also the attributes for kobjects are much easier to handle now. This cleaned up a LOT of code all through the kernel, making kobjects easier to use if you want to. - struct bus_type has been reworked to now handle the lifetime rules properly, as the kobject is properly dynamic. - struct driver has also been reworked, and now the lifetime issues are resolved. - the block subsystem has been converted to use struct device now, and not "raw" kobjects. This patch has been in the -mm tree for over a year now, and finally all the issues are worked out with it. Older distros now properly work with new kernels, and no userspace updates are needed at all. - nozomi driver is added. This has also been in -mm for a long time, and many people have asked for it to go in. It is now in good enough shape to do so. - lots of class_device conversions to use struct device instead. The tree is almost all cleaned up now, only SCSI and IB is the remaining code to fix up... * git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6: (196 commits) Driver core: coding style fixes Kobject: fix coding style issues in kobject c files Kobject: fix coding style issues in kobject.h Driver core: fix coding style issues in device.h spi: use class iteration api scsi: use class iteration api rtc: use class iteration api power supply : use class iteration api ieee1394: use class iteration api Driver Core: add class iteration api Driver core: Cleanup get_device_parent() in device_add() and device_move() UIO: constify function pointer tables Driver Core: constify the name passed to platform_device_register_simple driver core: fix build with SYSFS=n sysfs: make SYSFS_DEPRECATED depend on SYSFS Driver core: use LIST_HEAD instead of call to INIT_LIST_HEAD in __init kobject: add sample code for how to use ksets/ktypes/kobjects kobject: add sample code for how to use kobjects in a simple manner. kobject: update the kobject/kset documentation kobject: remove old, outdated documentation. ...
Diffstat (limited to 'init/do_mounts.c')
-rw-r--r--init/do_mounts.c108
1 files changed, 8 insertions, 100 deletions
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 4efa1e5385e3..2ae5b8462399 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -55,69 +55,6 @@ static int __init readwrite(char *str)
55__setup("ro", readonly); 55__setup("ro", readonly);
56__setup("rw", readwrite); 56__setup("rw", readwrite);
57 57
58static dev_t try_name(char *name, int part)
59{
60 char path[64];
61 char buf[32];
62 int range;
63 dev_t res;
64 char *s;
65 int len;
66 int fd;
67 unsigned int maj, min;
68
69 /* read device number from .../dev */
70
71 sprintf(path, "/sys/block/%s/dev", name);
72 fd = sys_open(path, 0, 0);
73 if (fd < 0)
74 goto fail;
75 len = sys_read(fd, buf, 32);
76 sys_close(fd);
77 if (len <= 0 || len == 32 || buf[len - 1] != '\n')
78 goto fail;
79 buf[len - 1] = '\0';
80 if (sscanf(buf, "%u:%u", &maj, &min) == 2) {
81 /*
82 * Try the %u:%u format -- see print_dev_t()
83 */
84 res = MKDEV(maj, min);
85 if (maj != MAJOR(res) || min != MINOR(res))
86 goto fail;
87 } else {
88 /*
89 * Nope. Try old-style "0321"
90 */
91 res = new_decode_dev(simple_strtoul(buf, &s, 16));
92 if (*s)
93 goto fail;
94 }
95
96 /* if it's there and we are not looking for a partition - that's it */
97 if (!part)
98 return res;
99
100 /* otherwise read range from .../range */
101 sprintf(path, "/sys/block/%s/range", name);
102 fd = sys_open(path, 0, 0);
103 if (fd < 0)
104 goto fail;
105 len = sys_read(fd, buf, 32);
106 sys_close(fd);
107 if (len <= 0 || len == 32 || buf[len - 1] != '\n')
108 goto fail;
109 buf[len - 1] = '\0';
110 range = simple_strtoul(buf, &s, 10);
111 if (*s)
112 goto fail;
113
114 /* if partition is within range - we got it */
115 if (part < range)
116 return res + part;
117fail:
118 return 0;
119}
120
121/* 58/*
122 * Convert a name into device number. We accept the following variants: 59 * Convert a name into device number. We accept the following variants:
123 * 60 *
@@ -129,12 +66,10 @@ fail:
129 * 5) /dev/<disk_name>p<decimal> - same as the above, that form is 66 * 5) /dev/<disk_name>p<decimal> - same as the above, that form is
130 * used when disk name of partitioned disk ends on a digit. 67 * used when disk name of partitioned disk ends on a digit.
131 * 68 *
132 * If name doesn't have fall into the categories above, we return 0. 69 * If name doesn't have fall into the categories above, we return (0,0).
133 * Sysfs is used to check if something is a disk name - it has 70 * block_class is used to check if something is a disk name. If the disk
134 * all known disks under bus/block/devices. If the disk name 71 * name contains slashes, the device name has them replaced with
135 * contains slashes, name of sysfs node has them replaced with 72 * bangs.
136 * bangs. try_name() does the actual checks, assuming that sysfs
137 * is mounted on rootfs /sys.
138 */ 73 */
139 74
140dev_t name_to_dev_t(char *name) 75dev_t name_to_dev_t(char *name)
@@ -142,13 +77,6 @@ dev_t name_to_dev_t(char *name)
142 char s[32]; 77 char s[32];
143 char *p; 78 char *p;
144 dev_t res = 0; 79 dev_t res = 0;
145 int part;
146
147#ifdef CONFIG_SYSFS
148 int mkdir_err = sys_mkdir("/sys", 0700);
149 if (sys_mount("sysfs", "/sys", "sysfs", 0, NULL) < 0)
150 goto out;
151#endif
152 80
153 if (strncmp(name, "/dev/", 5) != 0) { 81 if (strncmp(name, "/dev/", 5) != 0) {
154 unsigned maj, min; 82 unsigned maj, min;
@@ -164,6 +92,7 @@ dev_t name_to_dev_t(char *name)
164 } 92 }
165 goto done; 93 goto done;
166 } 94 }
95
167 name += 5; 96 name += 5;
168 res = Root_NFS; 97 res = Root_NFS;
169 if (strcmp(name, "nfs") == 0) 98 if (strcmp(name, "nfs") == 0)
@@ -178,35 +107,14 @@ dev_t name_to_dev_t(char *name)
178 for (p = s; *p; p++) 107 for (p = s; *p; p++)
179 if (*p == '/') 108 if (*p == '/')
180 *p = '!'; 109 *p = '!';
181 res = try_name(s, 0); 110 res = blk_lookup_devt(s);
182 if (res) 111 if (res)
183 goto done; 112 goto done;
184 113
185 while (p > s && isdigit(p[-1])) 114fail:
186 p--; 115 return 0;
187 if (p == s || !*p || *p == '0')
188 goto fail;
189 part = simple_strtoul(p, NULL, 10);
190 *p = '\0';
191 res = try_name(s, part);
192 if (res)
193 goto done;
194
195 if (p < s + 2 || !isdigit(p[-2]) || p[-1] != 'p')
196 goto fail;
197 p[-1] = '\0';
198 res = try_name(s, part);
199done: 116done:
200#ifdef CONFIG_SYSFS
201 sys_umount("/sys", 0);
202out:
203 if (!mkdir_err)
204 sys_rmdir("/sys");
205#endif
206 return res; 117 return res;
207fail:
208 res = 0;
209 goto done;
210} 118}
211 119
212static int __init root_dev_setup(char *line) 120static int __init root_dev_setup(char *line)