mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
move syslog wrapper to libudev
This commit is contained in:
parent
119f66fc36
commit
9060b066d9
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
17
udev/udev.h
17
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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
10
udev/udevd.c
10
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user