From 80df994cc22eb7f98187df9bc2281c7fd7b96af7 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 25 Dec 2011 18:59:42 +0100 Subject: [PATCH] builtin: kmod - hook up udev main logging to libkmod --- udev/udev-builtin-kmod.c | 8 ++++++++ udev/udev.h | 35 ++++++++++++++++++++--------------- udev/udevadm.c | 4 ++-- udev/udevd.c | 4 ++-- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/udev/udev-builtin-kmod.c b/udev/udev-builtin-kmod.c index e6c4d951..f5b41b1a 100644 --- a/udev/udev-builtin-kmod.c +++ b/udev/udev-builtin-kmod.c @@ -316,6 +316,12 @@ static int insmod(struct kmod_ctx *ctx, const char *name, const char *extra_opti return insmod_alias(ctx, name, extra_options); } +static void udev_kmod_log(void *data, int priority, const char *file, int line, + const char *fn, const char *format, va_list args) +{ + udev_main_log(data, priority, file, line, fn, format, args); +} + static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool test) { struct udev *udev = udev_device_get_udev(dev); @@ -327,6 +333,7 @@ static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool te return -ENOMEM; info(udev, "load module index\n"); + kmod_set_log_fn(ctx, udev_kmod_log, udev); kmod_load_resources(ctx); } @@ -353,6 +360,7 @@ static int builtin_kmod_init(struct udev *udev) return -ENOMEM; info(udev, "load module index\n"); + kmod_set_log_fn(ctx, udev_kmod_log, udev); kmod_load_resources(ctx); return 0; } diff --git a/udev/udev.h b/udev/udev.h index 3327031e..46dafd68 100644 --- a/udev/udev.h +++ b/udev/udev.h @@ -131,21 +131,6 @@ int udev_ctrl_get_exit(struct udev_ctrl_msg *ctrl_msg); const char *udev_ctrl_get_set_env(struct udev_ctrl_msg *ctrl_msg); int udev_ctrl_get_set_children_max(struct udev_ctrl_msg *ctrl_msg); -/* udevadm commands */ -struct udevadm_cmd { - const char *name; - int (*cmd)(struct udev *udev, int argc, char *argv[]); - const char *help; - int debug; -}; -extern const struct udevadm_cmd udevadm_monitor; -extern const struct udevadm_cmd udevadm_info; -extern const struct udevadm_cmd udevadm_control; -extern const struct udevadm_cmd udevadm_trigger; -extern const struct udevadm_cmd udevadm_settle; -extern const struct udevadm_cmd udevadm_test; -extern const struct udevadm_cmd udevadm_test_builtin; - /* built-in commands */ enum udev_builtin_cmd { UDEV_BUILTIN_BLKID, @@ -178,4 +163,24 @@ bool udev_builtin_run_once(enum udev_builtin_cmd cmd); int udev_builtin_run(struct udev_device *dev, enum udev_builtin_cmd cmd, const char *command, bool test); int udev_builtin_list(struct udev *udev); int udev_builtin_add_property(struct udev_device *dev, bool test, const char *key, const char *val); + +/* udev logging */ +void udev_main_log(struct udev *udev, int priority, + const char *file, int line, const char *fn, + const char *format, va_list args); + +/* udevadm commands */ +struct udevadm_cmd { + const char *name; + int (*cmd)(struct udev *udev, int argc, char *argv[]); + const char *help; + int debug; +}; +extern const struct udevadm_cmd udevadm_info; +extern const struct udevadm_cmd udevadm_trigger; +extern const struct udevadm_cmd udevadm_settle; +extern const struct udevadm_cmd udevadm_control; +extern const struct udevadm_cmd udevadm_monitor; +extern const struct udevadm_cmd udevadm_test; +extern const struct udevadm_cmd udevadm_test_builtin; #endif diff --git a/udev/udevadm.c b/udev/udevadm.c index 178981eb..5410f00c 100644 --- a/udev/udevadm.c +++ b/udev/udevadm.c @@ -27,7 +27,7 @@ static bool debug; -static void log_fn(struct udev *udev, int priority, +void udev_main_log(struct udev *udev, int priority, const char *file, int line, const char *fn, const char *format, va_list args) { @@ -113,7 +113,7 @@ int main(int argc, char *argv[]) goto out; udev_log_init("udevadm"); - udev_set_log_fn(udev, log_fn); + udev_set_log_fn(udev, udev_main_log); udev_selinux_init(udev); for (;;) { diff --git a/udev/udevd.c b/udev/udevd.c index 299f5d3f..37eb4ba4 100644 --- a/udev/udevd.c +++ b/udev/udevd.c @@ -49,7 +49,7 @@ static bool debug; -static void log_fn(struct udev *udev, int priority, +void udev_main_log(struct udev *udev, int priority, const char *file, int line, const char *fn, const char *format, va_list args) { @@ -1198,7 +1198,7 @@ int main(int argc, char *argv[]) goto exit; udev_log_init("udevd"); - udev_set_log_fn(udev, log_fn); + udev_set_log_fn(udev, udev_main_log); info(udev, "version %s\n", VERSION); udev_selinux_init(udev); -- 2.39.5