From 49b78fc1a8f1591fa172399b3be1dba4b7f23554 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Thu, 5 Jun 2008 01:10:03 +0000 Subject: Apply post-1.10.2 fixes, bump version to 1.10.3 --- util-linux/mdev.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'util-linux') diff --git a/util-linux/mdev.c b/util-linux/mdev.c index f0a8854..2341a5a 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c @@ -72,8 +72,14 @@ static void make_device(char *path, int delete) /* Determine device name, type, major and minor */ device_name = bb_basename(path); /* http://kernel.org/doc/pending/hotplug.txt says that only - * "/sys/block/..." is for block devices. "sys/bus" etc is not! */ - type = (strncmp(&path[5], "block/", 6) == 0 ? S_IFBLK : S_IFCHR); + * "/sys/block/..." is for block devices. "/sys/bus" etc is not! + * Since kernel 2.6.25 block devices are also in /sys/class/block. */ + /* TODO: would it be acceptable to just use strstr(path, "/block/")? */ + if (strncmp(&path[5], "class/block/"+6, 6) != 0 + && strncmp(&path[5], "class/block/", 12) != 0) + type = S_IFCHR; + else + type = S_IFBLK; if (ENABLE_FEATURE_MDEV_CONF) { FILE *fp; @@ -172,8 +178,9 @@ static void make_device(char *path, int delete) /* substitute %1..9 with off[1..9], if any */ n = 0; s = val; - while (*s && *s++ == '%') - n++; + while (*s) + if (*s++ == '%') + n++; p = alias = xzalloc(strlen(val) + n * strlen(device_name)); s = val + 1; -- cgit v1.1