aboutsummaryrefslogtreecommitdiff
path: root/util-linux/mdev.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-08-10 01:09:37 +0000
committerRob Landley <rob@landley.net>2006-08-10 01:09:37 +0000
commit10b36f94bb3e10681acaf43938f25622baf4d6b9 (patch)
tree486972a4553c75528863727f3de7e80040da40da /util-linux/mdev.c
parentb988462d3e419559cf34c59d06323c59ba0a38df (diff)
downloadbusybox-w32-10b36f94bb3e10681acaf43938f25622baf4d6b9.tar.gz
busybox-w32-10b36f94bb3e10681acaf43938f25622baf4d6b9.tar.bz2
busybox-w32-10b36f94bb3e10681acaf43938f25622baf4d6b9.zip
Patch from Chris Steel to fix mdev deleting device nodes.
Diffstat (limited to 'util-linux/mdev.c')
-rw-r--r--util-linux/mdev.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 7c1223dcb..b6ca00409 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -37,18 +37,19 @@ static void make_device(char *path, int delete)
37 * because sscanf() will stop at the first nondigit, which \n is. We 37 * because sscanf() will stop at the first nondigit, which \n is. We
38 * also depend on path having writeable space after it. */ 38 * also depend on path having writeable space after it. */
39 39
40 strcat(path, "/dev"); 40 if (!delete) {
41 fd = open(path, O_RDONLY); 41 strcat(path, "/dev");
42 len = read(fd, temp + 1, 64); 42 fd = open(path, O_RDONLY);
43 *temp++ = 0; 43 len = read(fd, temp + 1, 64);
44 close(fd); 44 *temp++ = 0;
45 if (len < 1) return; 45 close(fd);
46 if (len < 1) return;
47 }
46 48
47 /* Determine device name, type, major and minor */ 49 /* Determine device name, type, major and minor */
48 50
49 device_name = strrchr(path, '/') + 1; 51 device_name = strrchr(path, '/') + 1;
50 type = path[5]=='c' ? S_IFCHR : S_IFBLK; 52 type = path[5]=='c' ? S_IFCHR : S_IFBLK;
51 if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
52 53
53 /* 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 */
54 55
@@ -164,6 +165,7 @@ static void make_device(char *path, int delete)
164 165
165 umask(0); 166 umask(0);
166 if (!delete) { 167 if (!delete) {
168 if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
167 if (mknod(device_name, mode | type, makedev(major, minor)) && errno != EEXIST) 169 if (mknod(device_name, mode | type, makedev(major, minor)) && errno != EEXIST)
168 bb_perror_msg_and_die("mknod %s failed", device_name); 170 bb_perror_msg_and_die("mknod %s failed", device_name);
169 171