summaryrefslogtreecommitdiff
path: root/util-linux/mdev.c
diff options
context:
space:
mode:
authorRob Landley2006-01-22 23:14:16 +0000
committerRob Landley2006-01-22 23:14:16 +0000
commite927743bb022996e9f5c75d3ef20696fc5049dbf (patch)
treef71daa487c79705a1f47f766cd2bdafba6e159c0 /util-linux/mdev.c
parent86f5c9906beac527f3d7966f24811b571a589e08 (diff)
downloadbusybox-e927743bb022996e9f5c75d3ef20696fc5049dbf.zip
busybox-e927743bb022996e9f5c75d3ef20696fc5049dbf.tar.gz
There was a missing ! on strcmp (despite the fact it worked in my testing,
I have no idea _how_), and a simpler fix for the extra \n problem. I tested this and it worked for me, for what that's worth...
Diffstat (limited to 'util-linux/mdev.c')
-rw-r--r--util-linux/mdev.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 1358435..a18e448 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -43,23 +43,13 @@ static void make_device(char *path)
fd = open(temp, O_RDONLY);
len = read(fd, temp, PATH_MAX-1);
if (len<1) goto end;
- temp[--len] = 0; // remove trailing \n
close(fd);
/* Determine device name, type, major and minor */
device_name = strrchr(path, '/') + 1;
type = strncmp(path+5, "block/" ,6) ? S_IFCHR : S_IFBLK;
- major = minor = 0;
- for (s = temp; *s; s++) {
- if (*s == ':') {
- major = minor;
- minor = 0;
- } else {
- minor *= 10;
- minor += (*s) - '0';
- }
- }
+ if(sscanf(temp, "%d:%d", &major, &minor) != 2) goto end;
/* If we have a config file, look up permissions for this device */
@@ -202,7 +192,7 @@ static void find_dev(char *path)
/* If there's a dev entry, mknod it */
- if (strcmp(entry->d_name, "dev")) make_device(path);
+ if (!strcmp(entry->d_name, "dev")) make_device(path);
}
closedir(dir);