diff options
-rw-r--r-- | extras/ata_id/Makefile.am | 3 | ||||
-rw-r--r-- | extras/ata_id/ata_id.c | 7 | ||||
-rw-r--r-- | extras/cdrom_id/Makefile.am | 1 | ||||
-rw-r--r-- | extras/cdrom_id/cdrom_id.c | 7 | ||||
-rw-r--r-- | extras/edd_id/edd_id.c | 7 | ||||
-rw-r--r-- | extras/floppy/Makefile.am | 1 | ||||
-rw-r--r-- | extras/floppy/create_floppy_devices.c | 5 | ||||
-rw-r--r-- | extras/fstab_import/fstab_import.c | 7 | ||||
-rw-r--r-- | extras/path_id/path_id.c | 6 | ||||
-rw-r--r-- | extras/scsi_id/scsi_id.c | 7 | ||||
-rw-r--r-- | extras/scsi_id/scsi_serial.c | 3 | ||||
-rw-r--r-- | extras/usb_id/usb_id.c | 7 | ||||
-rw-r--r-- | libudev/libudev-private.h | 26 | ||||
-rw-r--r-- | udev/udev.h | 17 | ||||
-rw-r--r-- | udev/udevadm.c | 4 | ||||
-rw-r--r-- | udev/udevd.c | 10 |
16 files changed, 62 insertions, 56 deletions
diff --git a/extras/ata_id/Makefile.am b/extras/ata_id/Makefile.am index ffbdba32f2..0c37d8029a 100644 --- a/extras/ata_id/Makefile.am +++ b/extras/ata_id/Makefile.am @@ -6,7 +6,8 @@ udevhome_PROGRAMS = \ ata_id_SOURCES = \ ata_id.c \ - ../../udev/udev.h \ + ../../libudev/libudev.h \ + ../../libudev/libudev-private.h \ ../../libudev/libudev.c \ ../../libudev/libudev-list.c \ ../../libudev/libudev-util.c diff --git a/extras/ata_id/ata_id.c b/extras/ata_id/ata_id.c index dd28d91f4a..d976467817 100644 --- a/extras/ata_id/ata_id.c +++ b/extras/ata_id/ata_id.c @@ -35,7 +35,8 @@ #include <linux/types.h> #include <linux/hdreg.h> -#include "../../udev/udev.h" +#include "libudev.h" +#include "libudev-private.h" static void log_fn(struct udev *udev, int priority, const char *file, int line, const char *fn, @@ -66,7 +67,7 @@ int main(int argc, char *argv[]) if (udev == NULL) goto exit; - logging_init("ata_id"); + udev_log_init("ata_id"); udev_set_log_fn(udev, log_fn); while (1) { @@ -164,6 +165,6 @@ close: close(fd); exit: udev_unref(udev); - logging_close(); + udev_log_close(); return rc; } diff --git a/extras/cdrom_id/Makefile.am b/extras/cdrom_id/Makefile.am index 8e1968e6e1..bfdfdd3735 100644 --- a/extras/cdrom_id/Makefile.am +++ b/extras/cdrom_id/Makefile.am @@ -11,6 +11,7 @@ dist_udevrules_DATA = \ cdrom_id_SOURCES = \ cdrom_id.c \ ../../libudev/libudev.h \ + ../../libudev/libudev-private.h \ ../../libudev/libudev.c \ ../../libudev/libudev-list.c \ ../../libudev/libudev-util.c diff --git a/extras/cdrom_id/cdrom_id.c b/extras/cdrom_id/cdrom_id.c index 2306d9ad71..d4156ce7ac 100644 --- a/extras/cdrom_id/cdrom_id.c +++ b/extras/cdrom_id/cdrom_id.c @@ -37,7 +37,8 @@ #include <sys/ioctl.h> #include <linux/cdrom.h> -#include "../../udev/udev.h" +#include "libudev.h" +#include "libudev-private.h" static int debug; @@ -528,7 +529,7 @@ int main(int argc, char *argv[]) if (udev == NULL) goto exit; - logging_init("cdrom_id"); + udev_log_init("cdrom_id"); udev_set_log_fn(udev, log_fn); while (1) { @@ -706,7 +707,7 @@ exit: if (fd >= 0) close(fd); udev_unref(udev); - logging_close(); + udev_log_close(); return rc; } diff --git a/extras/edd_id/edd_id.c b/extras/edd_id/edd_id.c index 90656b4411..15295ed31f 100644 --- a/extras/edd_id/edd_id.c +++ b/extras/edd_id/edd_id.c @@ -23,7 +23,8 @@ #include <dirent.h> #include <stdint.h> -#include "../../udev/udev.h" +#include "libudev.h" +#include "libudev-private.h" static void log_fn(struct udev *udev, int priority, const char *file, int line, const char *fn, @@ -52,7 +53,7 @@ int main(int argc, char *argv[]) if (udev == NULL) goto exit; - logging_init("edd_id"); + udev_log_init("edd_id"); udev_set_log_fn(udev, log_fn); for (i = 1 ; i < argc; i++) { @@ -181,6 +182,6 @@ closedir: closedir(dir); exit: udev_unref(udev); - logging_close(); + udev_log_close(); return rc; } diff --git a/extras/floppy/Makefile.am b/extras/floppy/Makefile.am index 2baaa10f02..365ece9ee9 100644 --- a/extras/floppy/Makefile.am +++ b/extras/floppy/Makefile.am @@ -12,6 +12,7 @@ create_floppy_devices_SOURCES = \ ../../libudev/libudev-util.c \ ../../libudev/libudev-device.c \ ../../libudev/libudev-enumerate.c \ + ../../udev/udev.h \ ../../udev/udev-util.c if USE_SELINUX diff --git a/extras/floppy/create_floppy_devices.c b/extras/floppy/create_floppy_devices.c index 0698fcd3e8..b0d7b0bc85 100644 --- a/extras/floppy/create_floppy_devices.c +++ b/extras/floppy/create_floppy_devices.c @@ -24,6 +24,8 @@ #include <pwd.h> #include <grp.h> +#include "libudev.h" +#include "libudev-private.h" #include "../../udev/udev.h" static char *table[] = { @@ -66,7 +68,7 @@ int main(int argc, char **argv) if (udev == NULL) goto exit; - logging_init("create_floppy_devices"); + udev_log_init("create_floppy_devices"); udev_set_log_fn(udev, log_fn); udev_selinux_init(udev); @@ -164,6 +166,7 @@ int main(int argc, char **argv) udev_selinux_exit(udev); udev_unref(udev); + udev_log_close(); exit: return 0; } diff --git a/extras/fstab_import/fstab_import.c b/extras/fstab_import/fstab_import.c index e46ba7ec44..98ee75f174 100644 --- a/extras/fstab_import/fstab_import.c +++ b/extras/fstab_import/fstab_import.c @@ -24,7 +24,8 @@ #include <mntent.h> #include <sys/stat.h> -#include "../../udev/udev.h" +#include "libudev.h" +#include "libudev-private.h" static int debug; @@ -80,7 +81,7 @@ int main(int argc, char *argv[]) if (udev == NULL) goto exit; - logging_init("fstab_id"); + udev_log_init("fstab_id"); udev_set_log_fn(udev, log_fn); while (1) { @@ -197,6 +198,6 @@ int main(int argc, char *argv[]) exit: udev_unref(udev); - logging_close(); + udev_log_close(); return rc; } diff --git a/extras/path_id/path_id.c b/extras/path_id/path_id.c index dbb52bad21..4b57dec0d3 100644 --- a/extras/path_id/path_id.c +++ b/extras/path_id/path_id.c @@ -29,7 +29,7 @@ #include <getopt.h> #include "libudev.h" -#include "../../udev/udev.h" +#include "libudev-private.h" int debug; @@ -366,7 +366,7 @@ int main(int argc, char **argv) if (udev == NULL) goto exit; - logging_init("path_id"); + udev_log_init("path_id"); udev_set_log_fn(udev, log_fn); while (1) { @@ -465,6 +465,6 @@ out: udev_device_unref(dev); exit: udev_unref(udev); - logging_close(); + udev_log_close(); return rc; } diff --git a/extras/scsi_id/scsi_id.c b/extras/scsi_id/scsi_id.c index 213a267afa..7cf2f3765d 100644 --- a/extras/scsi_id/scsi_id.c +++ b/extras/scsi_id/scsi_id.c @@ -27,7 +27,8 @@ #include <getopt.h> #include <sys/stat.h> -#include "../../udev/udev.h" +#include "libudev.h" +#include "libudev-private.h" #include "scsi_id.h" static const struct option options[] = { @@ -613,7 +614,7 @@ int main(int argc, char **argv) if (udev == NULL) goto exit; - logging_init("scsi_id"); + udev_log_init("scsi_id"); udev_set_log_fn(udev, log_fn); /* @@ -649,6 +650,6 @@ int main(int argc, char **argv) exit: udev_unref(udev); - logging_close(); + udev_log_close(); return retval; } diff --git a/extras/scsi_id/scsi_serial.c b/extras/scsi_id/scsi_serial.c index cbacf379fe..c47712d859 100644 --- a/extras/scsi_id/scsi_serial.c +++ b/extras/scsi_id/scsi_serial.c @@ -30,7 +30,8 @@ /* #include <linux/bsg.h> */ #include "bsg.h" -#include "../../udev/udev.h" +#include "libudev.h" +#include "libudev-private.h" #include "scsi.h" #include "scsi_id.h" diff --git a/extras/usb_id/usb_id.c b/extras/usb_id/usb_id.c index 4679f94fde..b412598d35 100644 --- a/extras/usb_id/usb_id.c +++ b/extras/usb_id/usb_id.c @@ -21,7 +21,8 @@ #include <errno.h> #include <getopt.h> -#include "../../udev/udev.h" +#include "libudev.h" +#include "libudev-private.h" int debug; @@ -464,7 +465,7 @@ int main(int argc, char **argv) if (udev == NULL) goto exit; - logging_init("usb_id"); + udev_log_init("usb_id"); udev_set_log_fn(udev, log_fn); while (1) { @@ -558,6 +559,6 @@ int main(int argc, char **argv) exit: udev_device_unref(dev); udev_unref(udev); - logging_close(); + udev_log_close(); return retval; } diff --git a/libudev/libudev-private.h b/libudev/libudev-private.h index db5dde3164..21eb626dc1 100644 --- a/libudev/libudev-private.h +++ b/libudev/libudev-private.h @@ -40,7 +40,17 @@ udev_log_null(struct udev *udev, const char *format, ...) {} # define err(udev, arg...) udev_log_null(udev, ## arg) #endif -/* libudev */ +static inline void udev_log_init(const char *program_name) +{ + openlog(program_name, LOG_PID | LOG_CONS, LOG_DAEMON); +} + +static inline void udev_log_close(void) +{ + closelog(); +} + +/* libudev.c */ void udev_log(struct udev *udev, int priority, const char *file, int line, const char *fn, const char *format, ...) @@ -50,7 +60,7 @@ int udev_get_run(struct udev *udev); struct udev_list_entry *udev_add_property(struct udev *udev, const char *key, const char *value); struct udev_list_entry *udev_get_properties_list_entry(struct udev *udev); -/* libudev-device */ +/* libudev-device.c */ struct udev_device *udev_device_new(struct udev *udev); int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath); int udev_device_set_subsystem(struct udev_device *udev_device, const char *subsystem); @@ -91,14 +101,14 @@ int udev_device_update_db(struct udev_device *udev_device); int udev_device_delete_db(struct udev_device *udev_device); int udev_device_rename_db(struct udev_device *udev_device, const char *devpath); -/* libudev-monitor - netlink/unix socket communication */ +/* libudev-monitor.c - netlink/unix socket communication */ int udev_monitor_disconnect(struct udev_monitor *udev_monitor); int udev_monitor_allow_unicast_sender(struct udev_monitor *udev_monitor, struct udev_monitor *sender); int udev_monitor_send_device(struct udev_monitor *udev_monitor, struct udev_monitor *destination, struct udev_device *udev_device); int udev_monitor_set_receive_buffer_size(struct udev_monitor *udev_monitor, int size); -/* libudev-ctrl - daemon runtime setup */ +/* libudev-ctrl.c - daemon runtime setup */ struct udev_ctrl; struct udev_ctrl *udev_ctrl_new_from_socket(struct udev *udev, const char *socket_path); int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl); @@ -126,7 +136,7 @@ pid_t udev_ctrl_get_settle(struct udev_ctrl_msg *ctrl_msg); const char *udev_ctrl_get_set_env(struct udev_ctrl_msg *ctrl_msg); int udev_ctrl_get_set_max_childs(struct udev_ctrl_msg *ctrl_msg); -/* libudev-list */ +/* libudev-list.c */ struct udev_list_node { struct udev_list_node *next, *prev; }; @@ -158,13 +168,13 @@ void udev_list_entry_set_flag(struct udev_list_entry *list_entry, int flag); entry != NULL; \ entry = tmp, tmp = udev_list_entry_get_next(tmp)) -/* libudev-queue */ +/* libudev-queue.c */ unsigned long long int udev_get_kernel_seqnum(struct udev *udev); int udev_queue_read_seqnum(FILE *queue_file, unsigned long long int *seqnum); ssize_t udev_queue_read_devpath(FILE *queue_file, char *devpath, size_t size); ssize_t udev_queue_skip_devpath(FILE *queue_file); -/* libudev-queue-export */ +/* libudev-queue-export.c */ struct udev_queue_export *udev_queue_export_new(struct udev *udev); void udev_queue_export_unref(struct udev_queue_export *udev_queue_export); void udev_queue_export_cleanup(struct udev_queue_export *udev_queue_export); @@ -172,7 +182,7 @@ int udev_queue_export_device_queued(struct udev_queue_export *udev_queue_export, int udev_queue_export_device_finished(struct udev_queue_export *udev_queue_export, struct udev_device *udev_device); int udev_queue_export_device_failed(struct udev_queue_export *udev_queue_export, struct udev_device *udev_device); -/* libudev-utils */ +/* libudev-utils.c */ #define UTIL_PATH_SIZE 1024 #define UTIL_LINE_SIZE 2048 #define UTIL_NAME_SIZE 512 diff --git a/udev/udev.h b/udev/udev.h index 8926dee932..bd3686b28a 100644 --- a/udev/udev.h +++ b/udev/udev.h @@ -34,23 +34,6 @@ #define READ_END 0 #define WRITE_END 1 -static inline void logging_init(const char *program_name) -{ - openlog(program_name, LOG_PID | LOG_CONS, LOG_DAEMON); -} - -static inline void logging_msg(struct udev *udev, int priority, - const char *file, int line, const char *fn, - const char *format, va_list args) -{ - vsyslog(priority, format, args); -} - -static inline void logging_close(void) -{ - closelog(); -} - struct udev_event { struct udev *udev; struct udev_device *dev; diff --git a/udev/udevadm.c b/udev/udevadm.c index 072280a58e..99ac330082 100644 --- a/udev/udevadm.c +++ b/udev/udevadm.c @@ -138,7 +138,7 @@ int main(int argc, char *argv[]) if (udev == NULL) goto out; - logging_init("udevadm"); + udev_log_init("udevadm"); udev_set_log_fn(udev, log_fn); udev_selinux_init(udev); @@ -214,6 +214,6 @@ int main(int argc, char *argv[]) out: udev_selinux_exit(udev); udev_unref(udev); - logging_close(); + udev_log_close(); return rc; } diff --git a/udev/udevd.c b/udev/udevd.c index d63fa7f486..292f4374d7 100644 --- a/udev/udevd.c +++ b/udev/udevd.c @@ -213,8 +213,8 @@ static void worker_new(struct event *event) udev_ctrl_unref(udev_ctrl); close(pfd[FD_SIGNAL].fd); close(worker_watch[READ_END]); - logging_close(); - logging_init("udevd-work"); + udev_log_close(); + udev_log_init("udevd-work"); setpriority(PRIO_PROCESS, 0, UDEV_PRIORITY); /* set signal handlers */ @@ -288,7 +288,7 @@ static void worker_new(struct event *event) } udev_monitor_unref(worker_monitor); - logging_close(); + udev_log_close(); exit(0); } case -1: @@ -763,7 +763,7 @@ int main(int argc, char *argv[]) if (udev == NULL) goto exit; - logging_init("udevd"); + udev_log_init("udevd"); udev_set_log_fn(udev, log_fn); info(udev, "version %s\n", VERSION); udev_selinux_init(udev); @@ -1069,6 +1069,6 @@ exit: udev_monitor_unref(monitor); udev_selinux_exit(udev); udev_unref(udev); - logging_close(); + udev_log_close(); return rc; } |