udev-add.o \
udev-remove.o \
udevdb.o \
- logging.o \
namedev.o \
namedev_parse.o \
$(SYSFS) \
$(STRIPCMD) $@
$(HELPER): udevinfo.o $(OBJS) $(HEADERS)
- $(LD) $(LDFLAGS) -o $@ $(CRT0) udevinfo.o logging.o udev_config.o udevdb.o $(SYSFS) $(TDB) $(LIB_OBJS) $(ARCH_LIB_OBJS)
+ $(LD) $(LDFLAGS) -o $@ $(CRT0) udevinfo.o udev_config.o udevdb.o $(SYSFS) $(TDB) $(LIB_OBJS) $(ARCH_LIB_OBJS)
$(STRIPCMD) $@
-$(DAEMON): udevd.h udevd.o udevd.o logging.o
- $(LD) $(LDFLAGS) -lpthread -o $@ $(CRT0) udevd.o logging.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
+$(DAEMON): udevd.h udevd.o
+ $(LD) $(LDFLAGS) -lpthread -o $@ $(CRT0) udevd.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
$(STRIPCMD) $@
-$(SENDER): udevd.h udevsend.o udevd.o logging.o
- $(LD) $(LDFLAGS) -o $@ $(CRT0) udevsend.o logging.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
+$(SENDER): udevd.h udevsend.o
+ $(LD) $(LDFLAGS) -o $@ $(CRT0) udevsend.o $(LIB_OBJS) $(ARCH_LIB_OBJS)
$(STRIPCMD) $@
clean:
/* Debugging */
#ifdef DEBUG
-#include <syslog.h>
+#include "../logging.h"
#define dprintf(format, arg...) \
do { \
log_message (LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
#define dprintf(format, arg...) do { } while (0)
#endif
-extern int log_message (int level, const char *format, ...)
- __attribute__ ((format (printf, 2, 3)));
-
-
#endif /* _SYSFS_H_ */
/*
* logging.h
*
- * Userspace devfs
+ * Simple logging functions that can be compiled away into nothing.
*
- * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
* Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
*
* This program is free software; you can redistribute it and/or modify it
#define dbg_parse(format, arg...) do { } while (0)
#ifdef LOG
+#include <stdarg.h>
#include <syslog.h>
#undef info
} while (0)
#endif
-#endif /* LOG */
-
-extern int log_message (int level, const char *format, ...)
+static void log_message (int level, const char *format, ...)
__attribute__ ((format (printf, 2, 3)));
+static inline void log_message (int level, const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ vsyslog(level, format, args);
+ va_end(args);
+}
+
+/* each program must declare this variable somewhere */
+extern unsigned char logname[42];
+
+static inline void init_logging(char *program_name)
+{
+ snprintf(logname, 42,"%s[%d]", program_name, getpid());
+ openlog(logname, 0, LOG_DAEMON);
+}
+
+#endif /* LOG */
#endif
/* global variables */
char **main_argv;
char **main_envp;
+unsigned char logname[42];
static void sig_handler(int signum)
{
main_argv = argv;
main_envp = envp;
+ init_logging("udev");
dbg("version %s", UDEV_VERSION);
return udev_hotplug(argc, argv);
#include "logging.h"
+unsigned char logname[42];
static pthread_mutex_t msg_lock;
static pthread_mutex_t msg_active_lock;
static pthread_cond_t msg_active;
pthread_t mgr_exec_tid;
int retval;
+ init_logging("udevd");
+
/* only let one version of the daemon run at any one time */
if (one_and_only() != 0)
exit(0);
char **main_argv;
int main_argc;
+unsigned char logname[42];
static int print_all_attributes(const char *path)
{
main_argv = argv;
main_argc = argc;
+ init_logging("udevinfo");
+
/* initialize our configuration */
udev_init_config();
#include "udevd.h"
#include "logging.h"
+unsigned char logname[42];
static inline char *get_action(void)
{
int sock;
struct sockaddr_un saddr;
+ init_logging("udevsend");
+
subsystem = argv[1];
if (subsystem == NULL) {
dbg("no subsystem");