diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-05-18 11:39:57 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-05-18 11:39:57 +0200 |
| commit | ea57f51819a358a6c1309cf028a1a2dcd90dd7a5 (patch) | |
| tree | 91ae47398abb8401bc6cadb2eaff13e6d14acb33 /util-linux | |
| parent | 516530c932bd17d87c9eb4347a490be051e495f4 (diff) | |
| download | busybox-w32-ea57f51819a358a6c1309cf028a1a2dcd90dd7a5.tar.gz busybox-w32-ea57f51819a358a6c1309cf028a1a2dcd90dd7a5.tar.bz2 busybox-w32-ea57f51819a358a6c1309cf028a1a2dcd90dd7a5.zip | |
mdev: when found, print major,minor into mdev.log
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/mdev.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c index 70d19033d..101acb78a 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c | |||
| @@ -471,7 +471,7 @@ static void make_device(char *device_name, char *path, int operation) | |||
| 471 | int major, minor, type, len; | 471 | int major, minor, type, len; |
| 472 | 472 | ||
| 473 | if (G.verbose) | 473 | if (G.verbose) |
| 474 | bb_error_msg("make_device: %s, %s, op:%d", device_name, path, operation); | 474 | bb_error_msg("device: %s, %s", device_name, path); |
| 475 | 475 | ||
| 476 | /* Try to read major/minor string. Note that the kernel puts \n after | 476 | /* Try to read major/minor string. Note that the kernel puts \n after |
| 477 | * the data, so we don't need to worry about null terminating the string | 477 | * the data, so we don't need to worry about null terminating the string |
| @@ -479,7 +479,7 @@ static void make_device(char *device_name, char *path, int operation) | |||
| 479 | * We also depend on path having writeable space after it. | 479 | * We also depend on path having writeable space after it. |
| 480 | */ | 480 | */ |
| 481 | major = -1; | 481 | major = -1; |
| 482 | if (operation != OP_remove) { | 482 | if (operation == OP_add) { |
| 483 | char *dev_maj_min = path + strlen(path); | 483 | char *dev_maj_min = path + strlen(path); |
| 484 | 484 | ||
| 485 | strcpy(dev_maj_min, "/dev"); | 485 | strcpy(dev_maj_min, "/dev"); |
| @@ -490,7 +490,10 @@ static void make_device(char *device_name, char *path, int operation) | |||
| 490 | return; | 490 | return; |
| 491 | /* no "dev" file, but we can still run scripts | 491 | /* no "dev" file, but we can still run scripts |
| 492 | * based on device name */ | 492 | * based on device name */ |
| 493 | } else if (sscanf(++dev_maj_min, "%u:%u", &major, &minor) != 2) { | 493 | } else if (sscanf(++dev_maj_min, "%u:%u", &major, &minor) == 2) { |
| 494 | if (G.verbose) | ||
| 495 | bb_error_msg("maj,min: %u,%u", major, minor); | ||
| 496 | } else { | ||
| 494 | major = -1; | 497 | major = -1; |
| 495 | } | 498 | } |
| 496 | } | 499 | } |
| @@ -502,7 +505,8 @@ static void make_device(char *device_name, char *path, int operation) | |||
| 502 | /* http://kernel.org/doc/pending/hotplug.txt says that only | 505 | /* http://kernel.org/doc/pending/hotplug.txt says that only |
| 503 | * "/sys/block/..." is for block devices. "/sys/bus" etc is not. | 506 | * "/sys/block/..." is for block devices. "/sys/bus" etc is not. |
| 504 | * But since 2.6.25 block devices are also in /sys/class/block. | 507 | * But since 2.6.25 block devices are also in /sys/class/block. |
| 505 | * We use strstr("/block/") to forestall future surprises. */ | 508 | * We use strstr("/block/") to forestall future surprises. |
| 509 | */ | ||
| 506 | type = S_IFCHR; | 510 | type = S_IFCHR; |
| 507 | if (strstr(path, "/block/") || (G.subsystem && strncmp(G.subsystem, "block", 5) == 0)) | 511 | if (strstr(path, "/block/") || (G.subsystem && strncmp(G.subsystem, "block", 5) == 0)) |
| 508 | type = S_IFBLK; | 512 | type = S_IFBLK; |
| @@ -669,12 +673,12 @@ static void make_device(char *device_name, char *path, int operation) | |||
| 669 | bb_error_msg("mknod: %s (%d,%d) %o", node_name, major, minor, rule->mode | type); | 673 | bb_error_msg("mknod: %s (%d,%d) %o", node_name, major, minor, rule->mode | type); |
| 670 | if (mknod(node_name, rule->mode | type, makedev(major, minor)) && errno != EEXIST) | 674 | if (mknod(node_name, rule->mode | type, makedev(major, minor)) && errno != EEXIST) |
| 671 | bb_perror_msg("can't create '%s'", node_name); | 675 | bb_perror_msg("can't create '%s'", node_name); |
| 672 | if (major == G.root_major && minor == G.root_minor) | ||
| 673 | symlink(node_name, "root"); | ||
| 674 | if (ENABLE_FEATURE_MDEV_CONF) { | 676 | if (ENABLE_FEATURE_MDEV_CONF) { |
| 675 | chmod(node_name, rule->mode); | 677 | chmod(node_name, rule->mode); |
| 676 | chown(node_name, rule->ugid.uid, rule->ugid.gid); | 678 | chown(node_name, rule->ugid.uid, rule->ugid.gid); |
| 677 | } | 679 | } |
| 680 | if (major == G.root_major && minor == G.root_minor) | ||
| 681 | symlink(node_name, "root"); | ||
| 678 | if (ENABLE_FEATURE_MDEV_RENAME && alias) { | 682 | if (ENABLE_FEATURE_MDEV_RENAME && alias) { |
| 679 | if (aliaslink == '>') { | 683 | if (aliaslink == '>') { |
| 680 | //TODO: on devtmpfs, device_name already exists and symlink() fails. | 684 | //TODO: on devtmpfs, device_name already exists and symlink() fails. |
| @@ -890,13 +894,13 @@ int mdev_main(int argc UNUSED_PARAM, char **argv) | |||
| 890 | * DEVPATH is like "/block/sda" or "/class/input/mice" | 894 | * DEVPATH is like "/block/sda" or "/class/input/mice" |
| 891 | */ | 895 | */ |
| 892 | action = getenv("ACTION"); | 896 | action = getenv("ACTION"); |
| 897 | op = index_in_strings(keywords, action); | ||
| 893 | env_devname = getenv("DEVNAME"); /* can be NULL */ | 898 | env_devname = getenv("DEVNAME"); /* can be NULL */ |
| 894 | env_devpath = getenv("DEVPATH"); | 899 | env_devpath = getenv("DEVPATH"); |
| 895 | G.subsystem = getenv("SUBSYSTEM"); | 900 | G.subsystem = getenv("SUBSYSTEM"); |
| 896 | if (!action || !env_devpath /*|| !G.subsystem*/) | 901 | if (!action || !env_devpath /*|| !G.subsystem*/) |
| 897 | bb_show_usage(); | 902 | bb_show_usage(); |
| 898 | fw = getenv("FIRMWARE"); | 903 | fw = getenv("FIRMWARE"); |
| 899 | op = index_in_strings(keywords, action); | ||
| 900 | /* If it exists, does /dev/mdev.seq match $SEQNUM? | 904 | /* If it exists, does /dev/mdev.seq match $SEQNUM? |
| 901 | * If it does not match, earlier mdev is running | 905 | * If it does not match, earlier mdev is running |
| 902 | * in parallel, and we need to wait */ | 906 | * in parallel, and we need to wait */ |
| @@ -927,7 +931,7 @@ int mdev_main(int argc UNUSED_PARAM, char **argv) | |||
| 927 | if (logfd >= 0) { | 931 | if (logfd >= 0) { |
| 928 | xmove_fd(logfd, STDERR_FILENO); | 932 | xmove_fd(logfd, STDERR_FILENO); |
| 929 | G.verbose = 1; | 933 | G.verbose = 1; |
| 930 | bb_error_msg("pid: %u seq: %s action: %s", getpid(), seq, action); | 934 | bb_error_msg("seq: %s action: %s", seq, action); |
| 931 | } | 935 | } |
| 932 | } | 936 | } |
| 933 | 937 | ||
