From: Denis Vlasenko Date: Sat, 12 Jul 2008 10:28:41 +0000 (-0000) Subject: mdev: check for "/block/" substring for block dev detection X-Git-Tag: 1_12_0~196 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a87045ce37e01971bd40219293afdacd4c2317e2;p=oweals%2Fbusybox.git mdev: check for "/block/" substring for block dev detection function old new delta make_device 1294 1269 -25 --- diff --git a/util-linux/mdev.c b/util-linux/mdev.c index 4ac5c430a..dd9522999 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c @@ -96,13 +96,11 @@ 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! - * 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 + * "/sys/block/..." is for block devices. "/sys/bus" etc is not. + * But since 2.6.25 block devices are also in /sys/class/block. + * We use strstr("/block/") to forestall future surprises. */ + type = S_IFCHR; + if (strstr(path, "/block/")) type = S_IFBLK; if (ENABLE_FEATURE_MDEV_CONF) {