diff options
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/mdev.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c index f0a885482..2341a5a67 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c | |||
| @@ -72,8 +72,14 @@ static void make_device(char *path, int delete) | |||
| 72 | /* Determine device name, type, major and minor */ | 72 | /* Determine device name, type, major and minor */ |
| 73 | device_name = bb_basename(path); | 73 | device_name = bb_basename(path); |
| 74 | /* http://kernel.org/doc/pending/hotplug.txt says that only | 74 | /* http://kernel.org/doc/pending/hotplug.txt says that only |
| 75 | * "/sys/block/..." is for block devices. "sys/bus" etc is not! */ | 75 | * "/sys/block/..." is for block devices. "/sys/bus" etc is not! |
| 76 | type = (strncmp(&path[5], "block/", 6) == 0 ? S_IFBLK : S_IFCHR); | 76 | * Since kernel 2.6.25 block devices are also in /sys/class/block. */ |
| 77 | /* TODO: would it be acceptable to just use strstr(path, "/block/")? */ | ||
| 78 | if (strncmp(&path[5], "class/block/"+6, 6) != 0 | ||
| 79 | && strncmp(&path[5], "class/block/", 12) != 0) | ||
| 80 | type = S_IFCHR; | ||
| 81 | else | ||
| 82 | type = S_IFBLK; | ||
| 77 | 83 | ||
| 78 | if (ENABLE_FEATURE_MDEV_CONF) { | 84 | if (ENABLE_FEATURE_MDEV_CONF) { |
| 79 | FILE *fp; | 85 | FILE *fp; |
| @@ -172,8 +178,9 @@ static void make_device(char *path, int delete) | |||
| 172 | /* substitute %1..9 with off[1..9], if any */ | 178 | /* substitute %1..9 with off[1..9], if any */ |
| 173 | n = 0; | 179 | n = 0; |
| 174 | s = val; | 180 | s = val; |
| 175 | while (*s && *s++ == '%') | 181 | while (*s) |
| 176 | n++; | 182 | if (*s++ == '%') |
| 183 | n++; | ||
| 177 | 184 | ||
| 178 | p = alias = xzalloc(strlen(val) + n * strlen(device_name)); | 185 | p = alias = xzalloc(strlen(val) + n * strlen(device_name)); |
| 179 | s = val + 1; | 186 | s = val + 1; |
