chiark / gitweb /
replace udeveventrecorder by a shell script
authorKay Sievers <kay.sievers@suse.de>
Thu, 10 Nov 2005 01:06:43 +0000 (02:06 +0100)
committerKay Sievers <kay.sievers@suse.de>
Thu, 10 Nov 2005 01:06:43 +0000 (02:06 +0100)
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
.gitignore
Makefile
etc/udev/suse/95-debug.rules
extras/eventrecorder.sh [new file with mode: 0755]
udeveventrecorder.c [deleted file]

index a83700c93077019842f48aa1f70e704999446fcc..c37b70c524a9426b27233f1478f005a9f7b2e794 100644 (file)
@@ -9,6 +9,5 @@ udevinfo
 udevmonitor
 udevstart
 udevtest
-udeveventrecorder
 udev_version.h
 
index c105dab2e28fc5313743423e587337ba296e03ff..ab75bb3d9a19c4e66d77f151f2dc609b1d6554fa 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,6 @@ PROGRAMS = \
        udev                            \
        udevd                           \
        udevsend                        \
-       udeveventrecorder               \
        udevcontrol                     \
        udevmonitor                     \
        udevinfo                        \
@@ -359,7 +358,6 @@ uninstall-bin:
        - rm -f $(DESTDIR)$(sbindir)/udev
        - rm -f $(DESTDIR)$(sbindir)/udevd
        - rm -f $(DESTDIR)$(sbindir)/udevsend
-       - rm -f $(DESTDIR)$(sbindir)/udeveventrecoreder
        - rm -f $(DESTDIR)$(sbindir)/udevcontrol
        - rm -f $(DESTDIR)$(sbindir)/udevstart
        - rm -f $(DESTDIR)$(usrsbindir)/udevmonitor
index fad54b963211a29e71a94bef143a6121d946eddc..280287c1a78939fe9e39016b5d393509422be0f3 100644 (file)
@@ -1,5 +1,5 @@
 # debug events to /events, but not on default udev_log="err"
-ENV{UDEV_LOG}=="[4-9]", RUN+="/sbin/udeventrecorder"
+ENV{UDEV_LOG}=="[4-9]", RUN+="/lib/udev/eventrecorder.sh"
 
 # event to be catched by udevmonitor
 RUN+="socket:/org/kernel/udev/monitor"
diff --git a/extras/eventrecorder.sh b/extras/eventrecorder.sh
new file mode 100755 (executable)
index 0000000..90cfe68
--- /dev/null
@@ -0,0 +1,4 @@
+#/bin/sh
+
+[ -d /events ] || exit 0
+set > /events/debug.$SEQNUM.$1.$ACTION.$$
diff --git a/udeveventrecorder.c b/udeveventrecorder.c
deleted file mode 100644 (file)
index 422cf88..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * udeveventrecorder.c
- *
- * Copyright (C) 2004-2005 SuSE Linux Products GmbH
- * Author:
- *     Olaf Hering <olh@suse.de>
- *
- *     This program is free software; you can redistribute it and/or modify it
- *     under the terms of the GNU General Public License as published by the
- *     Free Software Foundation version 2 of the License.
- * 
- *     This program is distributed in the hope that it will be useful, but
- *     WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *     General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License along
- *     with this program; if not, write to the Free Software Foundation, Inc.,
- *     675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include "udev.h"
-#include "udev_version.h"
-#include "udev_utils.h"
-#include "logging.h"
-
-#define BUFSIZE 12345
-#define FNSIZE  123
-
-static int udev_log = 0;
-
-#ifdef USE_LOG
-void log_message (int priority, const char *format, ...)
-{
-       va_list args;
-
-       if (priority > udev_log)
-               return;
-
-       va_start(args, format);
-       vsyslog(priority, format, args);
-       va_end(args);
-}
-#endif
-
-int main(int argc, char **argv, char **envp)
-{
-       int fd, i;
-       unsigned long seq;
-       char **ep = envp;
-       char *buf, *p, *a;
-       struct stat sb;
-       const char *env;
-
-       if (stat("/events", &sb) || !(S_ISDIR(sb.st_mode)))
-               return 0;
-
-       env = getenv("UDEV_LOG");
-       if (env)
-               udev_log = log_priority(env);
-
-       logging_init("udeveventrecorder");
-       dbg("version %s", UDEV_VERSION);
-
-       p = getenv("SEQNUM");
-       a = getenv("ACTION");
-       buf = malloc(FNSIZE);
-       if (!(buf && a && argv[1]))
-               goto error;
-       if (p)
-               seq = strtoul(p, NULL, 0);
-       else
-               seq = 0;
-
-       snprintf(buf, FNSIZE, "/events/debug.%05lu.%s.%s.%u", seq, argv[1], a ? a : "", getpid());
-       if ((fd = open(buf, O_CREAT | O_WRONLY | O_TRUNC, 0644)) < 0) {
-               err("error creating '%s': %s", buf, strerror(errno));
-               goto error;
-       }
-       free(buf);
-       p = malloc(BUFSIZE);
-       buf = p;
-       buf += snprintf(buf, p + BUFSIZE - buf, "set --");
-       for (i = 1; i < argc; ++i) {
-               buf += snprintf(buf, p + BUFSIZE - buf, " %s", argv[i]);
-               if (buf > p + BUFSIZE)
-                       goto full;
-       }
-       buf += snprintf(buf, p + BUFSIZE - buf, "\n");
-       if (buf > p + BUFSIZE)
-               goto full;
-       while (*ep) {
-               unsigned char *t;
-               t = memchr(*ep, '=', strlen(*ep));
-               if (t) {
-                       *t = '\0';
-                       t++;
-                       buf += snprintf(buf, p + BUFSIZE - buf, "%s='%s'\n", *ep, t);
-                       --t;
-                       *t = '=';
-               }
-               ep++;
-               if (buf > p + BUFSIZE)
-                       break;
-       }
-
-full:
-       buf = p;
-       write(fd, buf, strlen(buf));
-       close(fd);
-       free(buf);
-       return 0;
-
-error:
-       fprintf(stderr, "record enviroment to /events, to be called from udev context\n");
-       return 1;
-}