diff options
-rw-r--r-- | util-linux/mdev.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c index 135843581..a18e44835 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c | |||
@@ -43,23 +43,13 @@ static void make_device(char *path) | |||
43 | fd = open(temp, O_RDONLY); | 43 | fd = open(temp, O_RDONLY); |
44 | len = read(fd, temp, PATH_MAX-1); | 44 | len = read(fd, temp, PATH_MAX-1); |
45 | if (len<1) goto end; | 45 | if (len<1) goto end; |
46 | temp[--len] = 0; // remove trailing \n | ||
47 | close(fd); | 46 | close(fd); |
48 | 47 | ||
49 | /* Determine device name, type, major and minor */ | 48 | /* Determine device name, type, major and minor */ |
50 | 49 | ||
51 | device_name = strrchr(path, '/') + 1; | 50 | device_name = strrchr(path, '/') + 1; |
52 | type = strncmp(path+5, "block/" ,6) ? S_IFCHR : S_IFBLK; | 51 | type = strncmp(path+5, "block/" ,6) ? S_IFCHR : S_IFBLK; |
53 | major = minor = 0; | 52 | if(sscanf(temp, "%d:%d", &major, &minor) != 2) goto end; |
54 | for (s = temp; *s; s++) { | ||
55 | if (*s == ':') { | ||
56 | major = minor; | ||
57 | minor = 0; | ||
58 | } else { | ||
59 | minor *= 10; | ||
60 | minor += (*s) - '0'; | ||
61 | } | ||
62 | } | ||
63 | 53 | ||
64 | /* If we have a config file, look up permissions for this device */ | 54 | /* If we have a config file, look up permissions for this device */ |
65 | 55 | ||
@@ -202,7 +192,7 @@ static void find_dev(char *path) | |||
202 | 192 | ||
203 | /* If there's a dev entry, mknod it */ | 193 | /* If there's a dev entry, mknod it */ |
204 | 194 | ||
205 | if (strcmp(entry->d_name, "dev")) make_device(path); | 195 | if (!strcmp(entry->d_name, "dev")) make_device(path); |
206 | } | 196 | } |
207 | 197 | ||
208 | closedir(dir); | 198 | closedir(dir); |