summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMichael Knudsen <mk@cvs.openbsd.org>2006-05-28 01:35:39 +0000
committerMichael Knudsen <mk@cvs.openbsd.org>2006-05-28 01:35:39 +0000
commitae479e810cafca3ac8f4dc1330f9417f65342899 (patch)
treede71573a8d052323c05ab47ff3306f337c32331e /usr.sbin
parentc2a515d420306ea8e24621710865c86c172efa40 (diff)
Include device id in hotplug event logging. id is passed as new
script parameter so only scripts that are picky about arg count needs updating. ok henning.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/hotplugd/hotplugd.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/usr.sbin/hotplugd/hotplugd.c b/usr.sbin/hotplugd/hotplugd.c
index 6d5e0289414..cca952d00ab 100644
--- a/usr.sbin/hotplugd/hotplugd.c
+++ b/usr.sbin/hotplugd/hotplugd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hotplugd.c,v 1.5 2006/04/05 08:22:21 grange Exp $ */
+/* $OpenBSD: hotplugd.c,v 1.6 2006/05/28 01:35:38 mk Exp $ */
/*
* Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
*
@@ -48,7 +48,7 @@ volatile sig_atomic_t quit = 0;
char *device = _PATH_DEV_HOTPLUG;
int devfd = -1;
-void exec_script(const char *, int, char *);
+void exec_script(const char *, int, char *, int);
void sigchild(int);
void sigquit(int);
@@ -104,16 +104,16 @@ main(int argc, char *argv[])
switch (he.he_type) {
case HOTPLUG_DEVAT:
- syslog(LOG_INFO, "%s attached, class %d",
- he.he_devname, he.he_devclass);
+ syslog(LOG_INFO, "%s attached, class %d, id %d",
+ he.he_devname, he.he_devclass, he.he_devid);
exec_script(_PATH_ETC_HOTPLUG_ATTACH, he.he_devclass,
- he.he_devname);
+ he.he_devname, he.he_devid);
break;
case HOTPLUG_DEVDT:
- syslog(LOG_INFO, "%s detached, class %d",
- he.he_devname, he.he_devclass);
+ syslog(LOG_INFO, "%s detached, class %d id %d",
+ he.he_devname, he.he_devclass, he.he_devid);
exec_script(_PATH_ETC_HOTPLUG_DETACH, he.he_devclass,
- he.he_devname);
+ he.he_devname, he.he_devid);
break;
default:
syslog(LOG_NOTICE, "unknown event (0x%x)", he.he_type);
@@ -129,12 +129,14 @@ main(int argc, char *argv[])
}
void
-exec_script(const char *file, int class, char *name)
+exec_script(const char *file, int class, char *name, int id)
{
char strclass[8];
+ char strid[8];
pid_t pid;
snprintf(strclass, sizeof(strclass), "%d", class);
+ snprintf(strid, sizeof(strid), "%d", id);
if (access(file, X_OK | R_OK))
/* do nothing if file can't be accessed */
@@ -146,7 +148,7 @@ exec_script(const char *file, int class, char *name)
}
if (pid == 0) {
/* child process */
- execl(file, basename(file), strclass, name, (char *)NULL);
+ execl(file, basename(file), strclass, name, strid, (char *)NULL);
syslog(LOG_ERR, "execl %s: %m", file);
_exit(1);
/* NOTREACHED */