summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2005-07-06 02:02:05 +0200
committerKay Sievers <kay.sievers@suse.de>2005-07-06 02:02:05 +0200
commitebfc1acd48606d9f2967d92f265010edf010634b (patch)
treee96bcabea099586d2d61baaabf7c19ce3f122bb2
parent2858b86c6a2cabe809088c545e39de76ae906ee7 (diff)
udevd: optimize env-key parsing
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
-rw-r--r--udevd.c30
-rw-r--r--udevd.h1
2 files changed, 17 insertions, 14 deletions
diff --git a/udevd.c b/udevd.c
index f69abc4c09..8782c615e3 100644
--- a/udevd.c
+++ b/udevd.c
@@ -105,7 +105,7 @@ static void msg_dump_queue(void)
#endif
}
-static void run_queue_delete(struct uevent_msg *msg)
+static void msg_queue_delete(struct uevent_msg *msg)
{
list_del(&msg->node);
free(msg);
@@ -189,7 +189,7 @@ static void execute_udev(struct uevent_msg *msg)
break;
case -1:
err("fork of child failed");
- run_queue_delete(msg);
+ msg_queue_delete(msg);
break;
default:
/* get SIGCHLD in main loop */
@@ -457,6 +457,8 @@ static struct uevent_msg *get_msg_from_envbuf(const char *buf, int buf_size)
int bufpos;
int i;
struct uevent_msg *msg;
+ int major = 0;
+ int minor = 0;
msg = malloc(sizeof(struct uevent_msg) + buf_size);
if (msg == NULL)
@@ -479,22 +481,22 @@ static struct uevent_msg *get_msg_from_envbuf(const char *buf, int buf_size)
/* remember some keys for further processing */
if (strncmp(key, "ACTION=", 7) == 0)
msg->action = &key[7];
-
- if (strncmp(key, "DEVPATH=", 8) == 0)
+ else if (strncmp(key, "DEVPATH=", 8) == 0)
msg->devpath = &key[8];
-
- if (strncmp(key, "SUBSYSTEM=", 10) == 0)
+ else if (strncmp(key, "SUBSYSTEM=", 10) == 0)
msg->subsystem = &key[10];
-
- if (strncmp(key, "SEQNUM=", 7) == 0)
+ else if (strncmp(key, "SEQNUM=", 7) == 0)
msg->seqnum = strtoull(&key[7], NULL, 10);
-
- if (strncmp(key, "PHYSDEVPATH=", 12) == 0)
+ else if (strncmp(key, "PHYSDEVPATH=", 12) == 0)
msg->physdevpath = &key[12];
-
- if (strncmp(key, "TIMEOUT=", 8) == 0)
+ else if (strncmp(key, "MAJOR=", 6) == 0)
+ major = strtoull(&key[6], NULL, 10);
+ else if (strncmp(key, "MINOR=", 6) == 0)
+ minor = strtoull(&key[6], NULL, 10);
+ else if (strncmp(key, "TIMEOUT=", 8) == 0)
msg->timeout = strtoull(&key[8], NULL, 10);
}
+ msg->devt = makedev(major, minor);
msg->envp[i++] = "UDEVD_EVENT=1";
msg->envp[i] = NULL;
@@ -604,7 +606,7 @@ static struct uevent_msg *get_netlink_msg(void)
if ((size_t)size > sizeof(buffer)-1)
size = sizeof(buffer)-1;
buffer[size] = '\0';
- dbg("uevent_size=%li", (long)size);
+ dbg("uevent_size=%zi", size);
/* start of event payload */
bufpos = strlen(buffer)+1;
@@ -679,7 +681,7 @@ static void udev_done(int pid)
if (msg->pid == pid) {
sysinfo(&info);
info("seq %llu exit, %ld seconds old", msg->seqnum, info.uptime - msg->queue_time);
- run_queue_delete(msg);
+ msg_queue_delete(msg);
/* we want to run the exec queue manager since there may
* be events waiting with the devpath of the one that
diff --git a/udevd.h b/udevd.h
index 34bfe931ba..c60fb139c0 100644
--- a/udevd.h
+++ b/udevd.h
@@ -74,6 +74,7 @@ struct uevent_msg {
char *action;
char *devpath;
char *subsystem;
+ dev_t devt;
unsigned long long seqnum;
char *physdevpath;
unsigned int timeout;