summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko2009-04-13 02:15:57 +0000
committerDenis Vlasenko2009-04-13 02:15:57 +0000
commit1fb26da0717312dbee703b5204876facd99262a9 (patch)
treea5a13498e34caf244814d66aecb0b8faf083d7a7
parent1d925affa9f183658f7652e9abda7b45638b343c (diff)
downloadbusybox-1fb26da0717312dbee703b5204876facd99262a9.zip
busybox-1fb26da0717312dbee703b5204876facd99262a9.tar.gz
mdev: ignore events with "$SUBSYSTEM" == "firmware" && "$ACTION" == "remove"
function old new delta mdev_main 665 676 +11
-rw-r--r--util-linux/mdev.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index b7b311a..6eaa66b 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -436,11 +436,10 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
ACTION_RECURSE | ACTION_FOLLOWLINKS,
fileAction, dirAction, temp, 0);
} else {
+ char *fw;
char *seq;
char *action;
char *env_path;
- char seqbuf[sizeof(int)*3 + 2];
- int seqlen = seqlen; /* for compiler */
/* Hotplug:
* env ACTION=... DEVPATH=... [SEQNUM=...] mdev
@@ -451,14 +450,23 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
env_path = getenv("DEVPATH");
if (!action || !env_path)
bb_show_usage();
+ fw = getenv("FIRMWARE");
+ /* If it exists, does /dev/mdev.seq match $SEQNUM?
+ * If it does not match, earlier mdev is running
+ * in parallel, and we need to wait */
seq = getenv("SEQNUM");
if (seq) {
- int timeout = 2000 / 32;
+ int timeout = 2000 / 32; /* 2000 msec */
do {
+ int seqlen;
+ char seqbuf[sizeof(int)*3 + 2];
+
seqlen = open_read_close("mdev.seq", seqbuf, sizeof(seqbuf-1));
- if (seqlen < 0)
+ if (seqlen < 0) {
+ seq = NULL;
break;
+ }
seqbuf[seqlen] = '\0';
if (seqbuf[0] == '\n' /* seed file? */
|| strcmp(seq, seqbuf) == 0 /* correct idx? */
@@ -470,19 +478,22 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
}
snprintf(temp, PATH_MAX, "/sys%s", env_path);
- if (!strcmp(action, "remove"))
- make_device(temp, 1);
- else if (!strcmp(action, "add")) {
+ if (strcmp(action, "remove") == 0) {
+ /* Ignoring "remove firmware". It was reported
+ * to happen and to cause erroneous deletion
+ * of device nodes. */
+ if (!fw)
+ make_device(temp, 1);
+ }
+ else if (strcmp(action, "add") == 0) {
make_device(temp, 0);
-
if (ENABLE_FEATURE_MDEV_LOAD_FIRMWARE) {
- char *fw = getenv("FIRMWARE");
if (fw)
load_firmware(fw, temp);
}
}
- if (seq && seqlen >= 0) {
+ if (seq) {
xopen_xwrite_close("mdev.seq", utoa(xatou(seq) + 1));
}
}