# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# Set the following to `true' to make a debuggable build.
+# Set the following to control the use of syslog
+# Set it to `false' to remove all logging
+LOG = true
+
+# Set the following to `true' to log the debug
+# and make a unstripped, unoptimized binary.
# Leave this set to `false' for production use.
DEBUG = false
CFLAGS+=-pipe
endif
+ifeq ($(strip $(LOG)),true)
+ CFLAGS += -DLOG
+endif
+
# if DEBUG is enabled, then we do not strip or optimize
ifeq ($(strip $(DEBUG)),true)
CFLAGS += $(WARNINGS) -O1 -g -DDEBUG -D_GNU_SOURCE
$(OBJS): $(GEN_HEADERS)
-$(ROOT): $(OBJS) udev.h namedev.h udev_version.h udev_dbus.h udevdb.h klibc_fixups.h list.h
+$(ROOT): $(OBJS) udev.h namedev.h udev_version.h udev_dbus.h udevdb.h klibc_fixups.h logging.h list.h
$(LD) $(LDFLAGS) -o $(ROOT) $(CRT0) $(OBJS) $(LIB_OBJS) $(ARCH_LIB_OBJS)
$(STRIPCMD) $(ROOT)
#include <sys/types.h>
#include <unistd.h>
#include <syslog.h>
-#include "udev.h"
-#ifdef DEBUG
+#include "logging.h"
+
static int logging_init = 0;
static unsigned char udev_logname[42];
va_end(args);
return 1;
}
-
-#endif
--- /dev/null
+/*
+ * udev.h
+ *
+ * Userspace devfs
+ *
+ * Copyright (C) 2003 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
+ * 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.
+ *
+ */
+
+#ifndef LOGGING_H
+#define LOGGING_H
+
+#ifdef LOG
+#include <syslog.h>
+#define info(format, arg...) \
+ do { \
+ log_message (LOG_INFO , format , ## arg); \
+ } while (0)
+#else
+ #define info(format, arg...) do { } while (0)
+#endif
+
+#ifdef DEBUG
+#define dbg(format, arg...) \
+ do { \
+ log_message (LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
+ } while (0)
+#else
+ #define dbg(format, arg...) do { } while (0)
+#endif
+
+/* Parser needs it's own debugging statement, we usually don't care about this at all */
+#ifdef DEBUG_PARSER
+#define dbg_parse(format, arg...) \
+ do { \
+ log_message (LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
+ } while (0)
+#else
+ #define dbg_parse(format, arg...) do { } while (0)
+#endif
+
+
+extern int log_message (int level, const char *format, ...)
+ __attribute__ ((format (printf, 2, 3)));
+
+#endif
#include "list.h"
#include "udev.h"
#include "udev_version.h"
+#include "logging.h"
#include "namedev.h"
#include "libsysfs/libsysfs.h"
#include "klibc_fixups.h"
/* sleep to give the kernel a chance to create the file */
sleep(1);
}
- dbg("Timed out waiting for '%s' file, continuing on anyway...", b->file);
+ dbg("timed out waiting for '%s' file, continuing on anyway...", b->file);
goto exit;
}
b++;
}
- dbg("Did not find bus type '%s' on list of bus_id_files, contact greg@kroah.com", sysfs_device->bus);
+ dbg("did not find bus type '%s' on list of bus_id_files, contact greg@kroah.com", sysfs_device->bus);
exit:
return; /* here to prevent compiler warning... */
}
if (sysfs_device != NULL)
goto device_found;
}
- dbg("Timed out waiting for device symlink, continuing on anyway...");
+ dbg("timed out waiting for device symlink, continuing on anyway...");
device_found:
/* We have another issue with just the wait above - the sysfs part of
if (sysfs_device->bus[0] != '\0')
goto bus_found;
}
- dbg("Timed out waiting to find the device bus, continuing on anyway\n");
+ dbg("timed out waiting to find the device bus, continuing on anyway");
goto exit;
bus_found:
- dbg("Device %s is registered with bus %s\n",
+ dbg("device %s is registered with bus '%s'",
sysfs_device->name, sysfs_device->bus);
}
exit:
}
/* Yup, this rule belongs to us! */
- dbg("found matching rule, '%s' becomes '%s'", dev->kernel, dev->name);
+ info("configured rule in '%s' at line %i applied, '%s' becomes '%s'",
+ udev_rules_filename, dev->config_line, udev->kernel_name, dev->name);
strfieldcpy(udev->name, dev->name);
strfieldcpy(udev->symlink, dev->symlink);
goto found;
char name[NAME_SIZE];
char symlink[NAME_SIZE];
struct sysfs_pair sysfs_pair[MAX_SYSFS_PAIRS];
+ int config_line;
};
struct perm_device {
#include <errno.h>
#include "udev.h"
+#include "logging.h"
#include "namedev.h"
static int add_config_dev(struct config_device *new_dev)
goto error;
}
+ dev.config_line = lineno;
retval = add_config_dev(&dev);
if (retval) {
dbg("add_config_dev returned with error %d", retval);
#include "udev.h"
#include "udev_version.h"
#include "udev_dbus.h"
+#include "logging.h"
#include "namedev.h"
#include "udevdb.h"
#include "libsysfs/libsysfs.h"
if (strrchr(dev->name, '/'))
create_path(filename);
+ info("creating device node '%s'", filename);
dbg("mknod(%s, %#o, %u, %u)", filename, dev->mode, dev->major, dev->minor);
retval = mknod(filename, dev->mode, res);
if (retval)
#include "udev.h"
#include "udev_version.h"
#include "udev_dbus.h"
+#include "logging.h"
#include "namedev.h"
#include "udevdb.h"
#include "libsysfs/libsysfs.h"
strncpy(filename, udev_root, sizeof(filename));
strncat(filename, dev->name, sizeof(filename));
- dbg("unlinking node '%s'", filename);
+ info("removing device node '%s'", filename);
retval = unlink(filename);
if (retval) {
dbg("unlink(%s) failed with error '%s'",
#include "udev.h"
#include "udev_version.h"
#include "udev_dbus.h"
+#include "logging.h"
#include "namedev.h"
#include "udevdb.h"
#include "libsysfs/libsysfs.h"
#include "libsysfs/libsysfs.h"
#include <sys/param.h>
-#ifdef DEBUG
-#include <syslog.h>
-#define dbg(format, arg...) \
- do { \
- log_message (LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
- } while (0)
-#else
- #define dbg(format, arg...) do { } while (0)
-#endif
-
-/* Parser needs it's own debugging statement, we usually don't care about this at all */
-#ifdef DEBUG_PARSER
-#define dbg_parse(format, arg...) \
- do { \
- log_message (LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \
- } while (0)
-#else
- #define dbg_parse(format, arg...) do { } while (0)
-#endif
-
-
-extern int log_message (int level, const char *format, ...)
- __attribute__ ((format (printf, 2, 3)));
-
#define COMMENT_CHARACTER '#'
#define NAME_SIZE 100
unsigned char program_result[NAME_SIZE];
unsigned char kernel_number[NAME_SIZE];
unsigned char kernel_name[NAME_SIZE];
-
};
#define strfieldcpy(to, from) \
#include "udev.h"
#include "udev_version.h"
+#include "logging.h"
#include "namedev.h"
#include "libsysfs/libsysfs.h"
#include "udev_version.h"
#include "udev.h"
+#include "logging.h"
#include "namedev.h"
#include "udevdb.h"
#include "tdb/tdb.h"