diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2009-04-13 02:15:57 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2009-04-13 02:15:57 +0000 |
| commit | 1fb26da0717312dbee703b5204876facd99262a9 (patch) | |
| tree | a5a13498e34caf244814d66aecb0b8faf083d7a7 /util-linux | |
| parent | 1d925affa9f183658f7652e9abda7b45638b343c (diff) | |
| download | busybox-w32-1fb26da0717312dbee703b5204876facd99262a9.tar.gz busybox-w32-1fb26da0717312dbee703b5204876facd99262a9.tar.bz2 busybox-w32-1fb26da0717312dbee703b5204876facd99262a9.zip | |
mdev: ignore events with "$SUBSYSTEM" == "firmware" && "$ACTION" == "remove"
function old new delta
mdev_main 665 676 +11
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/mdev.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c index b7b311aaa..6eaa66bf4 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c | |||
| @@ -436,11 +436,10 @@ int mdev_main(int argc UNUSED_PARAM, char **argv) | |||
| 436 | ACTION_RECURSE | ACTION_FOLLOWLINKS, | 436 | ACTION_RECURSE | ACTION_FOLLOWLINKS, |
| 437 | fileAction, dirAction, temp, 0); | 437 | fileAction, dirAction, temp, 0); |
| 438 | } else { | 438 | } else { |
| 439 | char *fw; | ||
| 439 | char *seq; | 440 | char *seq; |
| 440 | char *action; | 441 | char *action; |
| 441 | char *env_path; | 442 | char *env_path; |
| 442 | char seqbuf[sizeof(int)*3 + 2]; | ||
| 443 | int seqlen = seqlen; /* for compiler */ | ||
| 444 | 443 | ||
| 445 | /* Hotplug: | 444 | /* Hotplug: |
| 446 | * env ACTION=... DEVPATH=... [SEQNUM=...] mdev | 445 | * env ACTION=... DEVPATH=... [SEQNUM=...] mdev |
| @@ -451,14 +450,23 @@ int mdev_main(int argc UNUSED_PARAM, char **argv) | |||
| 451 | env_path = getenv("DEVPATH"); | 450 | env_path = getenv("DEVPATH"); |
| 452 | if (!action || !env_path) | 451 | if (!action || !env_path) |
| 453 | bb_show_usage(); | 452 | bb_show_usage(); |
| 453 | fw = getenv("FIRMWARE"); | ||
| 454 | 454 | ||
| 455 | /* If it exists, does /dev/mdev.seq match $SEQNUM? | ||
| 456 | * If it does not match, earlier mdev is running | ||
| 457 | * in parallel, and we need to wait */ | ||
| 455 | seq = getenv("SEQNUM"); | 458 | seq = getenv("SEQNUM"); |
| 456 | if (seq) { | 459 | if (seq) { |
| 457 | int timeout = 2000 / 32; | 460 | int timeout = 2000 / 32; /* 2000 msec */ |
| 458 | do { | 461 | do { |
| 462 | int seqlen; | ||
| 463 | char seqbuf[sizeof(int)*3 + 2]; | ||
| 464 | |||
| 459 | seqlen = open_read_close("mdev.seq", seqbuf, sizeof(seqbuf-1)); | 465 | seqlen = open_read_close("mdev.seq", seqbuf, sizeof(seqbuf-1)); |
| 460 | if (seqlen < 0) | 466 | if (seqlen < 0) { |
| 467 | seq = NULL; | ||
| 461 | break; | 468 | break; |
| 469 | } | ||
| 462 | seqbuf[seqlen] = '\0'; | 470 | seqbuf[seqlen] = '\0'; |
| 463 | if (seqbuf[0] == '\n' /* seed file? */ | 471 | if (seqbuf[0] == '\n' /* seed file? */ |
| 464 | || strcmp(seq, seqbuf) == 0 /* correct idx? */ | 472 | || strcmp(seq, seqbuf) == 0 /* correct idx? */ |
| @@ -470,19 +478,22 @@ int mdev_main(int argc UNUSED_PARAM, char **argv) | |||
| 470 | } | 478 | } |
| 471 | 479 | ||
| 472 | snprintf(temp, PATH_MAX, "/sys%s", env_path); | 480 | snprintf(temp, PATH_MAX, "/sys%s", env_path); |
| 473 | if (!strcmp(action, "remove")) | 481 | if (strcmp(action, "remove") == 0) { |
| 474 | make_device(temp, 1); | 482 | /* Ignoring "remove firmware". It was reported |
| 475 | else if (!strcmp(action, "add")) { | 483 | * to happen and to cause erroneous deletion |
| 484 | * of device nodes. */ | ||
| 485 | if (!fw) | ||
| 486 | make_device(temp, 1); | ||
| 487 | } | ||
| 488 | else if (strcmp(action, "add") == 0) { | ||
| 476 | make_device(temp, 0); | 489 | make_device(temp, 0); |
| 477 | |||
| 478 | if (ENABLE_FEATURE_MDEV_LOAD_FIRMWARE) { | 490 | if (ENABLE_FEATURE_MDEV_LOAD_FIRMWARE) { |
| 479 | char *fw = getenv("FIRMWARE"); | ||
| 480 | if (fw) | 491 | if (fw) |
| 481 | load_firmware(fw, temp); | 492 | load_firmware(fw, temp); |
| 482 | } | 493 | } |
| 483 | } | 494 | } |
| 484 | 495 | ||
| 485 | if (seq && seqlen >= 0) { | 496 | if (seq) { |
| 486 | xopen_xwrite_close("mdev.seq", utoa(xatou(seq) + 1)); | 497 | xopen_xwrite_close("mdev.seq", utoa(xatou(seq) + 1)); |
| 487 | } | 498 | } |
| 488 | } | 499 | } |
