From baa30fbc2c04b23209d0b8fb3c86cd15ef9ea81a Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 8 Apr 2012 16:06:20 +0200 Subject: udev: switch to systemd logging functions --- Makefile.am | 18 +- TODO | 1 + src/udev/accelerometer/accelerometer.c | 6 +- src/udev/ata_id/ata_id.c | 11 +- src/udev/cdrom_id/cdrom_id.c | 164 +++++++-------- src/udev/libudev-device-private.c | 2 +- src/udev/libudev-device.c | 46 +---- src/udev/libudev-enumerate.c | 19 +- src/udev/libudev-list.c | 4 - src/udev/libudev-monitor.c | 25 +-- src/udev/libudev-private.h | 26 +-- src/udev/libudev-queue-private.c | 8 +- src/udev/libudev-queue.c | 12 +- src/udev/libudev-selinux-private.c | 2 +- src/udev/libudev-util-private.c | 6 +- src/udev/libudev-util.c | 4 - src/udev/libudev.c | 10 +- src/udev/scsi_id/scsi_id.c | 49 ++--- src/udev/scsi_id/scsi_serial.c | 92 ++++----- src/udev/test-udev.c | 8 +- src/udev/udev-builtin-blkid.c | 6 +- src/udev/udev-builtin-firmware.c | 14 +- src/udev/udev-builtin-input_id.c | 16 +- src/udev/udev-builtin-kmod.c | 20 +- src/udev/udev-builtin-usb_id.c | 28 ++- src/udev/udev-builtin.c | 2 +- src/udev/udev-ctrl.c | 26 ++- src/udev/udev-event.c | 101 ++++------ src/udev/udev-node.c | 56 +++--- src/udev/udev-rules.c | 357 ++++++++++++++------------------- src/udev/udev-watch.c | 16 +- src/udev/udevadm-info.c | 6 +- src/udev/udevadm-monitor.c | 6 +- src/udev/udevadm-settle.c | 19 +- src/udev/udevadm-test-builtin.c | 2 - src/udev/udevadm-test.c | 7 +- src/udev/udevadm-trigger.c | 11 +- src/udev/udevadm.c | 39 ++-- src/udev/udevd.c | 153 +++++++------- 39 files changed, 570 insertions(+), 828 deletions(-) diff --git a/Makefile.am b/Makefile.am index 5a8d22d613..8d3ec4c89b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1297,7 +1297,8 @@ udevd_CFLAGS = \ $(udev_common_CFLAGS) udevd_LDADD = \ - $(udev_common_LDADD) + $(udev_common_LDADD) \ + libsystemd-basic.la udevd_CPPFLAGS = \ $(udev_common_CPPFLAGS) @@ -1317,7 +1318,8 @@ udevadm_CFLAGS = \ $(udev_common_CFLAGS) udevadm_LDADD = \ - $(udev_common_LDADD) + $(udev_common_LDADD) \ + libsystemd-basic.la udevadm_CPPFLAGS = \ $(udev_common_CPPFLAGS) @@ -1371,7 +1373,8 @@ ata_id_SOURCES = \ src/udev/ata_id/ata_id.c ata_id_LDADD = \ - libudev-private.la + libudev-private.la \ + libsystemd-basic.la udevlibexec_PROGRAMS += \ ata_id @@ -1381,7 +1384,8 @@ cdrom_id_SOURCES = \ src/udev/cdrom_id/cdrom_id.c cdrom_id_LDADD = \ - libudev-private.la + libudev-private.la \ + libsystemd-basic.la udevlibexec_PROGRAMS += \ cdrom_id @@ -1407,7 +1411,8 @@ scsi_id_SOURCES =\ src/udev/scsi_id/scsi_id.h scsi_id_LDADD = \ - libudev-private.la + libudev-private.la \ + libsystemd-basic.la udevlibexec_PROGRAMS += \ scsi_id @@ -1433,7 +1438,8 @@ accelerometer_SOURCES = \ src/udev/accelerometer/accelerometer.c accelerometer_LDADD = \ - libudev-private.la -lm + libudev-private.la -lm \ + libsystemd-basic.la udevlibexec_PROGRAMS += \ accelerometer diff --git a/TODO b/TODO index bee3b2b5a9..4c1de283a2 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,5 @@ Bugfixes: +* do not link selinux and attr against all binaries * swap units that are activated by one name but shown in the kernel under another are semi-broken diff --git a/src/udev/accelerometer/accelerometer.c b/src/udev/accelerometer/accelerometer.c index bc9715b264..4c5e47d0b7 100644 --- a/src/udev/accelerometer/accelerometer.c +++ b/src/udev/accelerometer/accelerometer.c @@ -263,7 +263,7 @@ int main (int argc, char** argv) if (udev == NULL) return 1; - udev_log_init("input_id"); + log_open(); udev_set_log_fn(udev, log_fn); /* CLI argument parsing */ @@ -349,9 +349,9 @@ int main (int argc, char** argv) return 0; } - info(udev, "Opening accelerometer device %s\n", devnode); + log_debug("opening accelerometer device %s\n", devnode); test_orientation(udev, dev, devnode); free(devnode); - + log_close(); return 0; } diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c index d2fe917217..fe160bf1ee 100644 --- a/src/udev/ata_id/ata_id.c +++ b/src/udev/ata_id/ata_id.c @@ -43,6 +43,7 @@ #include "libudev.h" #include "libudev-private.h" +#include "log.h" #define COMMAND_TIMEOUT_MSEC (30 * 1000) @@ -462,7 +463,7 @@ int main(int argc, char *argv[]) if (udev == NULL) goto exit; - udev_log_init("ata_id"); + log_open(); udev_set_log_fn(udev, log_fn); while (1) { @@ -486,14 +487,14 @@ int main(int argc, char *argv[]) node = argv[optind]; if (node == NULL) { - err(udev, "no node specified\n"); + log_error("no node specified\n"); rc = 1; goto exit; } fd = open(node, O_RDONLY|O_NONBLOCK); if (fd < 0) { - err(udev, "unable to open '%s'\n", node); + log_error("unable to open '%s'\n", node); rc = 1; goto exit; } @@ -525,7 +526,7 @@ int main(int argc, char *argv[]) } else { /* If this fails, then try HDIO_GET_IDENTITY */ if (ioctl(fd, HDIO_GET_IDENTITY, &id) != 0) { - info(udev, "HDIO_GET_IDENTITY failed for '%s': %m\n", node); + log_info("HDIO_GET_IDENTITY failed for '%s': %m\n", node); rc = 2; goto close; } @@ -709,6 +710,6 @@ close: close(fd); exit: udev_unref(udev); - udev_log_close(); + log_close(); return rc; } diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c index 6d5b081617..a199dd7ddc 100644 --- a/src/udev/cdrom_id/cdrom_id.c +++ b/src/udev/cdrom_id/cdrom_id.c @@ -141,10 +141,10 @@ static bool is_mounted(const char *device) static void info_scsi_cmd_err(struct udev *udev, const char *cmd, int err) { if (err == -1) { - info(udev, "%s failed\n", cmd); + log_debug("%s failed\n", cmd); return; } - info(udev, "%s failed with SK=%Xh/ASC=%02Xh/ACQ=%02Xh\n", cmd, SK(err), ASC(err), ASCQ(err)); + log_debug("%s failed with SK=%Xh/ASC=%02Xh/ACQ=%02Xh\n", cmd, SK(err), ASC(err), ASCQ(err)); } struct scsi_cmd { @@ -209,11 +209,11 @@ static int media_lock(struct udev *udev, int fd, bool lock) /* disable the kernel's lock logic */ err = ioctl(fd, CDROM_CLEAR_OPTIONS, CDO_LOCK); if (err < 0) - info(udev, "CDROM_CLEAR_OPTIONS, CDO_LOCK failed\n"); + log_debug("CDROM_CLEAR_OPTIONS, CDO_LOCK failed\n"); err = ioctl(fd, CDROM_LOCKDOOR, lock ? 1 : 0); if (err < 0) - info(udev, "CDROM_LOCKDOOR failed\n"); + log_debug("CDROM_LOCKDOOR failed\n"); return err; } @@ -241,7 +241,7 @@ static int cd_capability_compat(struct udev *udev, int fd) capability = ioctl(fd, CDROM_GET_CAPABILITY, NULL); if (capability < 0) { - info(udev, "CDROM_GET_CAPABILITY failed\n"); + log_debug("CDROM_GET_CAPABILITY failed\n"); return -1; } @@ -265,7 +265,7 @@ static int cd_capability_compat(struct udev *udev, int fd) static int cd_media_compat(struct udev *udev, int fd) { if (ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) != CDS_DISC_OK) { - info(udev, "CDROM_DRIVE_STATUS != CDS_DISC_OK\n"); + log_debug("CDROM_DRIVE_STATUS != CDS_DISC_OK\n"); return -1; } cd_media = 1; @@ -289,11 +289,11 @@ static int cd_inquiry(struct udev *udev, int fd) } if ((inq[0] & 0x1F) != 5) { - info(udev, "not an MMC unit\n"); + log_debug("not an MMC unit\n"); return -1; } - info(udev, "INQUIRY: [%.8s][%.16s][%.4s]\n", inq + 8, inq + 16, inq + 32); + log_debug("INQUIRY: [%.8s][%.16s][%.4s]\n", inq + 8, inq + 16, inq + 32); return 0; } @@ -303,105 +303,105 @@ static void feature_profile_media(struct udev *udev, int cur_profile) case 0x03: case 0x04: case 0x05: - info(udev, "profile 0x%02x \n", cur_profile); + log_debug("profile 0x%02x \n", cur_profile); cd_media = 1; cd_media_mo = 1; break; case 0x08: - info(udev, "profile 0x%02x media_cd_rom\n", cur_profile); + log_debug("profile 0x%02x media_cd_rom\n", cur_profile); cd_media = 1; cd_media_cd_rom = 1; break; case 0x09: - info(udev, "profile 0x%02x media_cd_r\n", cur_profile); + log_debug("profile 0x%02x media_cd_r\n", cur_profile); cd_media = 1; cd_media_cd_r = 1; break; case 0x0a: - info(udev, "profile 0x%02x media_cd_rw\n", cur_profile); + log_debug("profile 0x%02x media_cd_rw\n", cur_profile); cd_media = 1; cd_media_cd_rw = 1; break; case 0x10: - info(udev, "profile 0x%02x media_dvd_ro\n", cur_profile); + log_debug("profile 0x%02x media_dvd_ro\n", cur_profile); cd_media = 1; cd_media_dvd_rom = 1; break; case 0x11: - info(udev, "profile 0x%02x media_dvd_r\n", cur_profile); + log_debug("profile 0x%02x media_dvd_r\n", cur_profile); cd_media = 1; cd_media_dvd_r = 1; break; case 0x12: - info(udev, "profile 0x%02x media_dvd_ram\n", cur_profile); + log_debug("profile 0x%02x media_dvd_ram\n", cur_profile); cd_media = 1; cd_media_dvd_ram = 1; break; case 0x13: - info(udev, "profile 0x%02x media_dvd_rw_ro\n", cur_profile); + log_debug("profile 0x%02x media_dvd_rw_ro\n", cur_profile); cd_media = 1; cd_media_dvd_rw = 1; cd_media_dvd_rw_ro = 1; break; case 0x14: - info(udev, "profile 0x%02x media_dvd_rw_seq\n", cur_profile); + log_debug("profile 0x%02x media_dvd_rw_seq\n", cur_profile); cd_media = 1; cd_media_dvd_rw = 1; cd_media_dvd_rw_seq = 1; break; case 0x1B: - info(udev, "profile 0x%02x media_dvd_plus_r\n", cur_profile); + log_debug("profile 0x%02x media_dvd_plus_r\n", cur_profile); cd_media = 1; cd_media_dvd_plus_r = 1; break; case 0x1A: - info(udev, "profile 0x%02x media_dvd_plus_rw\n", cur_profile); + log_debug("profile 0x%02x media_dvd_plus_rw\n", cur_profile); cd_media = 1; cd_media_dvd_plus_rw = 1; break; case 0x2A: - info(udev, "profile 0x%02x media_dvd_plus_rw_dl\n", cur_profile); + log_debug("profile 0x%02x media_dvd_plus_rw_dl\n", cur_profile); cd_media = 1; cd_media_dvd_plus_rw_dl = 1; break; case 0x2B: - info(udev, "profile 0x%02x media_dvd_plus_r_dl\n", cur_profile); + log_debug("profile 0x%02x media_dvd_plus_r_dl\n", cur_profile); cd_media = 1; cd_media_dvd_plus_r_dl = 1; break; case 0x40: - info(udev, "profile 0x%02x media_bd\n", cur_profile); + log_debug("profile 0x%02x media_bd\n", cur_profile); cd_media = 1; cd_media_bd = 1; break; case 0x41: case 0x42: - info(udev, "profile 0x%02x media_bd_r\n", cur_profile); + log_debug("profile 0x%02x media_bd_r\n", cur_profile); cd_media = 1; cd_media_bd_r = 1; break; case 0x43: - info(udev, "profile 0x%02x media_bd_re\n", cur_profile); + log_debug("profile 0x%02x media_bd_re\n", cur_profile); cd_media = 1; cd_media_bd_re = 1; break; case 0x50: - info(udev, "profile 0x%02x media_hddvd\n", cur_profile); + log_debug("profile 0x%02x media_hddvd\n", cur_profile); cd_media = 1; cd_media_hddvd = 1; break; case 0x51: - info(udev, "profile 0x%02x media_hddvd_r\n", cur_profile); + log_debug("profile 0x%02x media_hddvd_r\n", cur_profile); cd_media = 1; cd_media_hddvd_r = 1; break; case 0x52: - info(udev, "profile 0x%02x media_hddvd_rw\n", cur_profile); + log_debug("profile 0x%02x media_hddvd_rw\n", cur_profile); cd_media = 1; cd_media_hddvd_rw = 1; break; default: - info(udev, "profile 0x%02x \n", cur_profile); + log_debug("profile 0x%02x \n", cur_profile); break; } } @@ -418,77 +418,77 @@ static int feature_profiles(struct udev *udev, const unsigned char *profiles, si case 0x03: case 0x04: case 0x05: - info(udev, "profile 0x%02x mo\n", profile); + log_debug("profile 0x%02x mo\n", profile); cd_mo = 1; break; case 0x08: - info(udev, "profile 0x%02x cd_rom\n", profile); + log_debug("profile 0x%02x cd_rom\n", profile); cd_cd_rom = 1; break; case 0x09: - info(udev, "profile 0x%02x cd_r\n", profile); + log_debug("profile 0x%02x cd_r\n", profile); cd_cd_r = 1; break; case 0x0A: - info(udev, "profile 0x%02x cd_rw\n", profile); + log_debug("profile 0x%02x cd_rw\n", profile); cd_cd_rw = 1; break; case 0x10: - info(udev, "profile 0x%02x dvd_rom\n", profile); + log_debug("profile 0x%02x dvd_rom\n", profile); cd_dvd_rom = 1; break; case 0x12: - info(udev, "profile 0x%02x dvd_ram\n", profile); + log_debug("profile 0x%02x dvd_ram\n", profile); cd_dvd_ram = 1; break; case 0x13: case 0x14: - info(udev, "profile 0x%02x dvd_rw\n", profile); + log_debug("profile 0x%02x dvd_rw\n", profile); cd_dvd_rw = 1; break; case 0x1B: - info(udev, "profile 0x%02x dvd_plus_r\n", profile); + log_debug("profile 0x%02x dvd_plus_r\n", profile); cd_dvd_plus_r = 1; break; case 0x1A: - info(udev, "profile 0x%02x dvd_plus_rw\n", profile); + log_debug("profile 0x%02x dvd_plus_rw\n", profile); cd_dvd_plus_rw = 1; break; case 0x2A: - info(udev, "profile 0x%02x dvd_plus_rw_dl\n", profile); + log_debug("profile 0x%02x dvd_plus_rw_dl\n", profile); cd_dvd_plus_rw_dl = 1; break; case 0x2B: - info(udev, "profile 0x%02x dvd_plus_r_dl\n", profile); + log_debug("profile 0x%02x dvd_plus_r_dl\n", profile); cd_dvd_plus_r_dl = 1; break; case 0x40: cd_bd = 1; - info(udev, "profile 0x%02x bd\n", profile); + log_debug("profile 0x%02x bd\n", profile); break; case 0x41: case 0x42: cd_bd_r = 1; - info(udev, "profile 0x%02x bd_r\n", profile); + log_debug("profile 0x%02x bd_r\n", profile); break; case 0x43: cd_bd_re = 1; - info(udev, "profile 0x%02x bd_re\n", profile); + log_debug("profile 0x%02x bd_re\n", profile); break; case 0x50: cd_hddvd = 1; - info(udev, "profile 0x%02x hddvd\n", profile); + log_debug("profile 0x%02x hddvd\n", profile); break; case 0x51: cd_hddvd_r = 1; - info(udev, "profile 0x%02x hddvd_r\n", profile); + log_debug("profile 0x%02x hddvd_r\n", profile); break; case 0x52: cd_hddvd_rw = 1; - info(udev, "profile 0x%02x hddvd_rw\n", profile); + log_debug("profile 0x%02x hddvd_rw\n", profile); break; default: - info(udev, "profile 0x%02x \n", profile); + log_debug("profile 0x%02x \n", profile); break; } } @@ -511,11 +511,11 @@ static int cd_profiles_old_mmc(struct udev *udev, int fd) if ((err != 0)) { info_scsi_cmd_err(udev, "READ DISC INFORMATION", err); if (cd_media == 1) { - info(udev, "no current profile, but disc is present; assuming CD-ROM\n"); + log_debug("no current profile, but disc is present; assuming CD-ROM\n"); cd_media_cd_rom = 1; return 0; } else { - info(udev, "no current profile, assuming no media\n"); + log_debug("no current profile, assuming no media\n"); return -1; } }; @@ -524,13 +524,13 @@ static int cd_profiles_old_mmc(struct udev *udev, int fd) if (header[2] & 16) { cd_media_cd_rw = 1; - info(udev, "profile 0x0a media_cd_rw\n"); + log_debug("profile 0x0a media_cd_rw\n"); } else if ((header[2] & 3) < 2 && cd_cd_r) { cd_media_cd_r = 1; - info(udev, "profile 0x09 media_cd_r\n"); + log_debug("profile 0x09 media_cd_r\n"); } else { cd_media_cd_rom = 1; - info(udev, "profile 0x08 media_cd_rom\n"); + log_debug("profile 0x08 media_cd_rom\n"); } return 0; } @@ -558,8 +558,8 @@ static int cd_profiles(struct udev *udev, int fd) info_scsi_cmd_err(udev, "GET CONFIGURATION", err); /* handle pre-MMC2 drives which do not support GET CONFIGURATION */ if (SK(err) == 0x5 && ASC(err) == 0x20) { - info(udev, "drive is pre-MMC2 and does not support 46h get configuration command\n"); - info(udev, "trying to work around the problem\n"); + log_debug("drive is pre-MMC2 and does not support 46h get configuration command\n"); + log_debug("trying to work around the problem\n"); ret = cd_profiles_old_mmc(udev, fd); } goto out; @@ -567,18 +567,18 @@ static int cd_profiles(struct udev *udev, int fd) cur_profile = features[6] << 8 | features[7]; if (cur_profile > 0) { - info(udev, "current profile 0x%02x\n", cur_profile); + log_debug("current profile 0x%02x\n", cur_profile); feature_profile_media (udev, cur_profile); ret = 0; /* we have media */ } else { - info(udev, "no current profile, assuming no media\n"); + log_debug("no current profile, assuming no media\n"); } len = features[0] << 24 | features[1] << 16 | features[2] << 8 | features[3]; - info(udev, "GET CONFIGURATION: size of features buffer 0x%04x\n", len); + log_debug("GET CONFIGURATION: size of features buffer 0x%04x\n", len); if (len > sizeof(features)) { - info(udev, "can not get features in a single query, truncating\n"); + log_debug("can not get features in a single query, truncating\n"); len = sizeof(features); } else if (len <= 8) { len = sizeof(features); @@ -598,10 +598,10 @@ static int cd_profiles(struct udev *udev, int fd) /* parse the length once more, in case the drive decided to have other features suddenly :) */ len = features[0] << 24 | features[1] << 16 | features[2] << 8 | features[3]; - info(udev, "GET CONFIGURATION: size of features buffer 0x%04x\n", len); + log_debug("GET CONFIGURATION: size of features buffer 0x%04x\n", len); if (len > sizeof(features)) { - info(udev, "can not get features in a single query, truncating\n"); + log_debug("can not get features in a single query, truncating\n"); len = sizeof(features); } @@ -613,11 +613,11 @@ static int cd_profiles(struct udev *udev, int fd) switch (feature) { case 0x00: - info(udev, "GET CONFIGURATION: feature 'profiles', with %i entries\n", features[i+3] / 4); + log_debug("GET CONFIGURATION: feature 'profiles', with %i entries\n", features[i+3] / 4); feature_profiles(udev, &features[i]+4, features[i+3]); break; default: - info(udev, "GET CONFIGURATION: feature 0x%04x , with 0x%02x bytes\n", feature, features[i+3]); + log_debug("GET CONFIGURATION: feature 0x%04x , with 0x%02x bytes\n", feature, features[i+3]); break; } } @@ -648,8 +648,8 @@ static int cd_media_info(struct udev *udev, int fd) }; cd_media = 1; - info(udev, "disk type %02x\n", header[8]); - info(udev, "hardware reported media status: %s\n", media_status[header[2] & 3]); + log_debug("disk type %02x\n", header[8]); + log_debug("hardware reported media status: %s\n", media_status[header[2] & 3]); /* exclude plain CDROM, some fake cdroms return 0 for "blank" media here */ if (!cd_media_cd_rom) @@ -687,7 +687,7 @@ static int cd_media_info(struct udev *udev, int fd) } if (dvdstruct[4] & 0x02) { cd_media_state = media_status[2]; - info(udev, "write-protected DVD-RAM media inserted\n"); + log_debug("write-protected DVD-RAM media inserted\n"); goto determined; } @@ -704,13 +704,13 @@ static int cd_media_info(struct udev *udev, int fd) len = format[3]; if (len & 7 || len < 16) { - info(udev, "invalid format capacities length\n"); + log_debug("invalid format capacities length\n"); return -1; } switch(format[8] & 3) { case 1: - info(udev, "unformatted DVD-RAM media inserted\n"); + log_debug("unformatted DVD-RAM media inserted\n"); /* This means that last format was interrupted * or failed, blank dvd-ram discs are factory * formatted. Take no action here as it takes @@ -719,12 +719,12 @@ static int cd_media_info(struct udev *udev, int fd) goto determined; case 2: - info(udev, "formatted DVD-RAM media inserted\n"); + log_debug("formatted DVD-RAM media inserted\n"); break; case 3: cd_media = 0; //return no media - info(udev, "format capacities returned no media\n"); + log_debug("format capacities returned no media\n"); return -1; } } @@ -760,9 +760,9 @@ static int cd_media_info(struct udev *udev, int fd) if (!result) { cd_media_state = media_status[0]; - info(udev, "no data in blocks 0 or 16, assuming blank\n"); + log_debug("no data in blocks 0 or 16, assuming blank\n"); } else { - info(udev, "data in blocks 0 or 16, assuming complete\n"); + log_debug("data in blocks 0 or 16, assuming complete\n"); } } @@ -798,7 +798,7 @@ static int cd_media_toc(struct udev *udev, int fd) } len = (header[0] << 8 | header[1]) + 2; - info(udev, "READ TOC: len: %d, start track: %d, end track: %d\n", len, header[2], header[3]); + log_debug("READ TOC: len: %d, start track: %d, end track: %d\n", len, header[2], header[3]); if (len > sizeof(toc)) return -1; if (len < 2) @@ -832,7 +832,7 @@ static int cd_media_toc(struct udev *udev, int fd) is_data_track = (p[1] & 0x04) != 0; block = p[4] << 24 | p[5] << 16 | p[6] << 8 | p[7]; - info(udev, "track=%u info=0x%x(%s) start_block=%u\n", + log_debug("track=%u info=0x%x(%s) start_block=%u\n", p[2], p[1] & 0x0f, is_data_track ? "data":"audio", block); if (is_data_track) @@ -852,7 +852,7 @@ static int cd_media_toc(struct udev *udev, int fd) return -1; } len = header[4+4] << 24 | header[4+5] << 16 | header[4+6] << 8 | header[4+7]; - info(udev, "last track %u starts at block %u\n", header[4+2], len); + log_debug("last track %u starts at block %u\n", header[4+2], len); cd_media_session_last_offset = (unsigned long long int)len * 2048; return 0; } @@ -880,7 +880,7 @@ int main(int argc, char *argv[]) if (udev == NULL) goto exit; - udev_log_init("cdrom_id"); + log_open(); udev_set_log_fn(udev, log_fn); while (1) { @@ -921,7 +921,7 @@ int main(int argc, char *argv[]) node = argv[optind]; if (!node) { - err(udev, "no device\n"); + log_error("no device\n"); fprintf(stderr, "no device\n"); rc = 1; goto exit; @@ -939,12 +939,12 @@ int main(int argc, char *argv[]) nanosleep(&duration, NULL); } if (fd < 0) { - info(udev, "unable to open '%s'\n", node); + log_debug("unable to open '%s'\n", node); fprintf(stderr, "unable to open '%s'\n", node); rc = 1; goto exit; } - info(udev, "probing: '%s'\n", node); + log_debug("probing: '%s'\n", node); /* same data as original cdrom_id */ if (cd_capability_compat(udev, fd) < 0) { @@ -975,19 +975,19 @@ int main(int argc, char *argv[]) work: /* lock the media, so we enable eject button events */ if (lock && cd_media) { - info(udev, "PREVENT_ALLOW_MEDIUM_REMOVAL (lock)\n"); + log_debug("PREVENT_ALLOW_MEDIUM_REMOVAL (lock)\n"); media_lock(udev, fd, true); } if (unlock && cd_media) { - info(udev, "PREVENT_ALLOW_MEDIUM_REMOVAL (unlock)\n"); + log_debug("PREVENT_ALLOW_MEDIUM_REMOVAL (unlock)\n"); media_lock(udev, fd, false); } if (eject) { - info(udev, "PREVENT_ALLOW_MEDIUM_REMOVAL (unlock)\n"); + log_debug("PREVENT_ALLOW_MEDIUM_REMOVAL (unlock)\n"); media_lock(udev, fd, false); - info(udev, "START_STOP_UNIT (eject)\n"); + log_debug("START_STOP_UNIT (eject)\n"); media_eject(udev, fd); } @@ -1094,6 +1094,6 @@ exit: if (fd >= 0) close(fd); udev_unref(udev); - udev_log_close(); + log_close(); return rc; } diff --git a/src/udev/libudev-device-private.c b/src/udev/libudev-device-private.c index 13fdb8eb57..91fd06c025 100644 --- a/src/udev/libudev-device-private.c +++ b/src/udev/libudev-device-private.c @@ -165,7 +165,7 @@ int udev_device_update_db(struct udev_device *udev_device) fclose(f); rename(filename_tmp, filename); - info(udev, "created %s file '%s' for '%s'\n", has_info ? "db" : "empty", + dbg(udev, "created %s file '%s' for '%s'\n", has_info ? "db" : "empty", filename, udev_device_get_devpath(udev_device)); return 0; } diff --git a/src/udev/libudev-device.c b/src/udev/libudev-device.c index 98bfa903d3..40b00ac5d2 100644 --- a/src/udev/libudev-device.c +++ b/src/udev/libudev-device.c @@ -479,7 +479,7 @@ int udev_device_read_db(struct udev_device *udev_device, const char *dbfile) f = fopen(dbfile, "re"); if (f == NULL) { - info(udev_device->udev, "no db file to read %s: %m\n", dbfile); + dbg(udev_device->udev, "no db file to read %s: %m\n", dbfile); return -1; } udev_device->is_initialized = true; @@ -519,7 +519,7 @@ int udev_device_read_db(struct udev_device *udev_device, const char *dbfile) } fclose(f); - info(udev_device->udev, "device %p filled with db file data\n", udev_device); + dbg(udev_device->udev, "device %p filled with db file data\n", udev_device); return 0; } @@ -605,7 +605,6 @@ struct udev_device *udev_device_new(struct udev *udev) udev_device_add_property(udev_device, udev_list_entry_get_name(list_entry), udev_list_entry_get_value(list_entry)); - dbg(udev_device->udev, "udev_device: %p created\n", udev_device); return udev_device; } @@ -640,17 +639,15 @@ _public_ struct udev_device *udev_device_new_from_syspath(struct udev *udev, con /* path starts in sys */ len = strlen(udev_get_sys_path(udev)); if (strncmp(syspath, udev_get_sys_path(udev), len) != 0) { - info(udev, "not in sys :%s\n", syspath); + dbg(udev, "not in sys :%s\n", syspath); return NULL; } /* path is not a root directory */ subdir = &syspath[len+1]; pos = strrchr(subdir, '/'); - if (pos == NULL || pos[1] == '\0' || pos < &subdir[2]) { - dbg(udev, "not a subdir :%s\n", syspath); + if (pos == NULL || pos[1] == '\0' || pos < &subdir[2]) return NULL; - } /* resolve possible symlink to real path */ util_strscpy(path, sizeof(path), syspath); @@ -661,16 +658,12 @@ _public_ struct udev_device *udev_device_new_from_syspath(struct udev *udev, con /* all "devices" require a "uevent" file */ util_strscpyl(file, sizeof(file), path, "/uevent", NULL); - if (stat(file, &statbuf) != 0) { - dbg(udev, "not a device: %s\n", syspath); + if (stat(file, &statbuf) != 0) return NULL; - } } else { /* everything else just needs to be a directory */ - if (stat(path, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode)) { - dbg(udev, "directory not found: %s\n", syspath); + if (stat(path, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode)) return NULL; - } } udev_device = udev_device_new(udev); @@ -678,7 +671,7 @@ _public_ struct udev_device *udev_device_new_from_syspath(struct udev *udev, con return NULL; udev_device_set_syspath(udev_device, path); - info(udev, "device %p has devpath '%s'\n", udev_device, udev_device_get_devpath(udev_device)); + dbg(udev, "device %p has devpath '%s'\n", udev_device, udev_device_get_devpath(udev_device)); return udev_device; } @@ -885,7 +878,7 @@ _public_ struct udev_device *udev_device_new_from_environment(struct udev *udev) udev_device_add_property_from_string_parse(udev_device, environ[i]); if (udev_device_add_property_from_string_parse_finish(udev_device) < 0) { - info(udev, "missing values, invalid device\n"); + dbg(udev, "missing values, invalid device\n"); udev_device_unref(udev_device); udev_device = NULL; } @@ -942,8 +935,6 @@ _public_ struct udev_device *udev_device_get_parent(struct udev_device *udev_dev udev_device->parent_set = true; udev_device->parent_device = device_new_from_parent(udev_device); } - if (udev_device->parent_device != NULL) - dbg(udev_device->udev, "returning existing parent %p\n", udev_device->parent_device); return udev_device->parent_device; } @@ -1058,7 +1049,6 @@ _public_ void udev_device_unref(struct udev_device *udev_device) free(udev_device->id_filename); free(udev_device->envp); free(udev_device->monitor_buf); - dbg(udev_device->udev, "udev_device: %p released\n", udev_device); free(udev_device); } @@ -1310,15 +1300,11 @@ _public_ const char *udev_device_get_sysattr_value(struct udev_device *udev_devi /* look for possibly already cached result */ list_entry = udev_list_get_entry(&udev_device->sysattr_value_list); list_entry = udev_list_entry_get_by_name(list_entry, sysattr); - if (list_entry != NULL) { - dbg(udev_device->udev, "got '%s' (%s) from cache\n", - sysattr, udev_list_entry_get_value(list_entry)); + if (list_entry != NULL) return udev_list_entry_get_value(list_entry); - } util_strscpyl(path, sizeof(path), udev_device_get_syspath(udev_device), "/", sysattr, NULL); if (lstat(path, &statbuf) != 0) { - dbg(udev_device->udev, "no attribute '%s', keep negative entry\n", path); udev_list_entry_add(&udev_device->sysattr_value_list, sysattr, NULL); goto out; } @@ -1336,7 +1322,6 @@ _public_ const char *udev_device_get_sysattr_value(struct udev_device *udev_devi if (util_get_sys_core_link_value(udev_device->udev, sysattr, udev_device->syspath, value, sizeof(value)) < 0) return NULL; - dbg(udev_device->udev, "cache '%s' with link value '%s'\n", sysattr, value); list_entry = udev_list_entry_add(&udev_device->sysattr_value_list, sysattr, value); val = udev_list_entry_get_value(list_entry); goto out; @@ -1365,10 +1350,8 @@ _public_ const char *udev_device_get_sysattr_value(struct udev_device *udev_devi /* read attribute value */ fd = open(path, O_RDONLY|O_CLOEXEC); - if (fd < 0) { - dbg(udev_device->udev, "attribute '%s' can not be opened\n", path); + if (fd < 0) goto out; - } size = read(fd, value, sizeof(value)); close(fd); if (size < 0) @@ -1379,7 +1362,6 @@ _public_ const char *udev_device_get_sysattr_value(struct udev_device *udev_devi /* got a valid value, store it in cache and return it */ value[size] = '\0'; util_remove_trailing_chars(value, '\n'); - dbg(udev_device->udev, "'%s' has attribute value '%s'\n", path, value); list_entry = udev_list_entry_add(&udev_device->sysattr_value_list, sysattr, value); val = udev_list_entry_get_value(list_entry); out: @@ -1398,11 +1380,8 @@ static int udev_device_sysattr_list_read(struct udev_device *udev_device) return 0; dir = opendir(udev_device_get_syspath(udev_device)); - if (!dir) { - dbg(udev_device->udev, "sysfs dir '%s' can not be opened\n", - udev_device_get_syspath(udev_device)); + if (!dir) return -1; - } for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) { char path[UTIL_PATH_SIZE]; @@ -1423,7 +1402,6 @@ static int udev_device_sysattr_list_read(struct udev_device *udev_device) } closedir(dir); - dbg(udev_device->udev, "found %d sysattrs for '%s'\n", num, udev_device_get_syspath(udev_device)); udev_device->sysattr_list_read = true; return num; @@ -1675,8 +1653,6 @@ static int update_envp_monitor_buf(struct udev_device *udev_device) udev_device->envp[i] = NULL; udev_device->monitor_buf_len = s - udev_device->monitor_buf; udev_device->envp_uptodate = true; - dbg(udev_device->udev, "filled envp/monitor buffer, %u properties, %zu bytes\n", - i, udev_device->monitor_buf_len); return 0; } diff --git a/src/udev/libudev-enumerate.c b/src/udev/libudev-enumerate.c index 7f40367bf1..7b9a732ce6 100644 --- a/src/udev/libudev-enumerate.c +++ b/src/udev/libudev-enumerate.c @@ -209,10 +209,8 @@ static bool devices_delay_end(struct udev *udev, const char *syspath) len = strlen(udev_get_sys_path(udev)); for (i = 0; delay_device_list[i] != NULL; i++) { - if (strstr(&syspath[len], delay_device_list[i]) != NULL) { - dbg(udev, "delaying: %s\n", syspath); + if (strstr(&syspath[len], delay_device_list[i]) != NULL) return true; - } } return false; } @@ -870,12 +868,9 @@ static int scan_devices_all(struct udev_enumerate *udev_enumerate) util_strscpyl(base, sizeof(base), udev_get_sys_path(udev), "/subsystem", NULL); if (stat(base, &statbuf) == 0) { /* we have /subsystem/, forget all the old stuff */ - dbg(udev, "searching '/subsystem/*/devices/*' dir\n"); scan_dir(udev_enumerate, "subsystem", "devices", NULL); } else { - dbg(udev, "searching '/bus/*/devices/*' dir\n"); scan_dir(udev_enumerate, "bus", "devices", NULL); - dbg(udev, "searching '/class/*' dir\n"); scan_dir(udev_enumerate, "class", NULL, NULL); } return 0; @@ -921,10 +916,8 @@ _public_ int udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerat return -EINVAL; /* all kernel modules */ - if (match_subsystem(udev_enumerate, "module")) { - dbg(udev, "searching 'modules/*' dir\n"); + if (match_subsystem(udev_enumerate, "module")) scan_dir_and_add_devices(udev_enumerate, "module", NULL, NULL); - } util_strscpyl(base, sizeof(base), udev_get_sys_path(udev), "/subsystem", NULL); if (stat(base, &statbuf) == 0) @@ -933,15 +926,11 @@ _public_ int udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerat subsysdir = "bus"; /* all subsystems (only buses support coldplug) */ - if (match_subsystem(udev_enumerate, "subsystem")) { - dbg(udev, "searching '%s/*' dir\n", subsysdir); + if (match_subsystem(udev_enumerate, "subsystem")) scan_dir_and_add_devices(udev_enumerate, subsysdir, NULL, NULL); - } /* all subsystem drivers */ - if (match_subsystem(udev_enumerate, "drivers")) { - dbg(udev, "searching '%s/*/drivers/*' dir\n", subsysdir); + if (match_subsystem(udev_enumerate, "drivers")) scan_dir(udev_enumerate, subsysdir, "drivers", "drivers"); - } return 0; } diff --git a/src/udev/libudev-list.c b/src/udev/libudev-list.c index b5d6bfd213..054c0a931c 100644 --- a/src/udev/libudev-list.c +++ b/src/udev/libudev-list.c @@ -148,17 +148,14 @@ struct udev_list_entry *udev_list_entry_add(struct udev_list *list, const char * if (i >= 0) { entry = list->entries[i]; - dbg(list->udev, "'%s' is already in the list\n", name); free(entry->value); if (value == NULL) { entry->value = NULL; - dbg(list->udev, "'%s' value unset\n", name); return entry; } entry->value = strdup(value); if (entry->value == NULL) return NULL; - dbg(list->udev, "'%s' value replaced with '%s'\n", name, value); return entry; } } @@ -216,7 +213,6 @@ struct udev_list_entry *udev_list_entry_add(struct udev_list *list, const char * udev_list_entry_append(entry, list); } - dbg(list->udev, "'%s=%s' added\n", entry->name, entry->value); return entry; } diff --git a/src/udev/libudev-monitor.c b/src/udev/libudev-monitor.c index d707b21aea..7fcf7e52f2 100644 --- a/src/udev/libudev-monitor.c +++ b/src/udev/libudev-monitor.c @@ -157,7 +157,6 @@ _public_ struct udev_monitor *udev_monitor_new_from_socket(struct udev *udev, co return NULL; } - dbg(udev, "monitor %p created with '%s'\n", udev_monitor, socket_path); return udev_monitor; } @@ -201,7 +200,6 @@ struct udev_monitor *udev_monitor_new_from_netlink_fd(struct udev *udev, const c udev_monitor->snl_destination.nl_family = AF_NETLINK; udev_monitor->snl_destination.nl_groups = UDEV_MONITOR_UDEV; - dbg(udev, "monitor %p created with NETLINK_KOBJECT_UEVENT (%u)\n", udev_monitor, group); return udev_monitor; } @@ -485,7 +483,6 @@ _public_ void udev_monitor_unref(struct udev_monitor *udev_monitor) close(udev_monitor->sock); udev_list_cleanup(&udev_monitor->filter_subsystem_list); udev_list_cleanup(&udev_monitor->filter_tag_list); - dbg(udev_monitor->udev, "monitor %p released\n", udev_monitor); free(udev_monitor); } @@ -604,12 +601,12 @@ retry: buflen = recvmsg(udev_monitor->sock, &smsg, 0); if (buflen < 0) { if (errno != EINTR) - info(udev_monitor->udev, "unable to receive message\n"); + dbg(udev_monitor->udev, "unable to receive message\n"); return NULL; } if (buflen < 32 || (size_t)buflen >= sizeof(buf)) { - info(udev_monitor->udev, "invalid message length\n"); + dbg(udev_monitor->udev, "invalid message length\n"); return NULL; } @@ -618,12 +615,12 @@ retry: /* unicast message, check if we trust the sender */ if (udev_monitor->snl_trusted_sender.nl_pid == 0 || snl.nl_pid != udev_monitor->snl_trusted_sender.nl_pid) { - info(udev_monitor->udev, "unicast netlink message ignored\n"); + dbg(udev_monitor->udev, "unicast netlink message ignored\n"); return NULL; } } else if (snl.nl_groups == UDEV_MONITOR_KERNEL) { if (snl.nl_pid > 0) { - info(udev_monitor->udev, "multicast kernel netlink message from pid %d ignored\n", + dbg(udev_monitor->udev, "multicast kernel netlink message from pid %d ignored\n", snl.nl_pid); return NULL; } @@ -632,13 +629,13 @@ retry: cmsg = CMSG_FIRSTHDR(&smsg); if (cmsg == NULL || cmsg->cmsg_type != SCM_CREDENTIALS) { - info(udev_monitor->udev, "no sender credentials received, message ignored\n"); + dbg(udev_monitor->udev, "no sender credentials received, message ignored\n"); return NULL; } cred = (struct ucred *)CMSG_DATA(cmsg); if (cred->uid != 0) { - info(udev_monitor->udev, "sender uid=%d, message ignored\n", cred->uid); + dbg(udev_monitor->udev, "sender uid=%d, message ignored\n", cred->uid); return NULL; } @@ -657,13 +654,13 @@ retry: /* kernel message with header */ bufpos = strlen(buf) + 1; if ((size_t)bufpos < sizeof("a@/d") || bufpos >= buflen) { - info(udev_monitor->udev, "invalid message length\n"); + dbg(udev_monitor->udev, "invalid message length\n"); return NULL; } /* check message header */ if (strstr(buf, "@/") == NULL) { - info(udev_monitor->udev, "unrecognized message header\n"); + dbg(udev_monitor->udev, "unrecognized message header\n"); return NULL; } } @@ -686,7 +683,7 @@ retry: } if (udev_device_add_property_from_string_parse_finish(udev_device) < 0) { - info(udev_monitor->udev, "missing values, invalid device\n"); + dbg(udev_monitor->udev, "missing values, invalid device\n"); udev_device_unref(udev_device); return NULL; } @@ -748,7 +745,7 @@ int udev_monitor_send_device(struct udev_monitor *udev_monitor, smsg.msg_name = &udev_monitor->sun; smsg.msg_namelen = udev_monitor->addrlen; count = sendmsg(udev_monitor->sock, &smsg, 0); - info(udev_monitor->udev, "passed %zi bytes to socket monitor %p\n", count, udev_monitor); + dbg(udev_monitor->udev, "passed %zi bytes to socket monitor %p\n", count, udev_monitor); return count; } @@ -803,7 +800,7 @@ int udev_monitor_send_device(struct udev_monitor *udev_monitor, smsg.msg_name = &udev_monitor->snl_destination; smsg.msg_namelen = sizeof(struct sockaddr_nl); count = sendmsg(udev_monitor->sock, &smsg, 0); - info(udev_monitor->udev, "passed %zi bytes to netlink monitor %p\n", count, udev_monitor); + dbg(udev_monitor->udev, "passed %zi bytes to netlink monitor %p\n", count, udev_monitor); return count; } diff --git a/src/udev/libudev-private.h b/src/udev/libudev-private.h index df11e3743c..d914aa4599 100644 --- a/src/udev/libudev-private.h +++ b/src/udev/libudev-private.h @@ -1,7 +1,7 @@ /* * libudev - interface to udev device information * - * Copyright (C) 2008-2010 Kay Sievers + * Copyright (C) 2008-2012 Kay Sievers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,36 +20,20 @@ #include "libudev.h" #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#define READ_END 0 -#define WRITE_END 1 - -static inline void __attribute__((always_inline, format(printf, 2, 3))) -udev_log_null(struct udev *udev, const char *format, ...) {} +#define READ_END 0 +#define WRITE_END 1 +/* avoid (sometimes expensive) calculations of parameters for debug output */ #define udev_log_cond(udev, prio, arg...) \ do { \ if (udev_get_log_priority(udev) >= prio) \ udev_log(udev, prio, __FILE__, __LINE__, __FUNCTION__, ## arg); \ } while (0) -#ifdef ENABLE_DEBUG -# define dbg(udev, arg...) udev_log_cond(udev, LOG_DEBUG, ## arg) -#else -# define dbg(udev, arg...) udev_log_null(udev, ## arg) -#endif +#define dbg(udev, arg...) udev_log_cond(udev, LOG_DEBUG, ## arg) #define info(udev, arg...) udev_log_cond(udev, LOG_INFO, ## arg) #define err(udev, arg...) udev_log_cond(udev, LOG_ERR, ## arg) -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, diff --git a/src/udev/libudev-queue-private.c b/src/udev/libudev-queue-private.c index d3e09e8b27..ca6d229a2c 100644 --- a/src/udev/libudev-queue-private.c +++ b/src/udev/libudev-queue-private.c @@ -208,15 +208,11 @@ static int rebuild_queue_file(struct udev_queue_export *udev_queue_export) /* read old queue file */ if (udev_queue_export->queue_file != NULL) { - dbg(udev_queue_export->udev, "compacting queue file, freeing %d bytes\n", - udev_queue_export->waste_bytes); - devpaths = build_index(udev_queue_export); if (devpaths != NULL) udev_queue_export->seqnum_max += devpaths->devpaths_first; } if (devpaths == NULL) { - dbg(udev_queue_export->udev, "creating empty queue file\n"); udev_queue_export->queued_count = 0; udev_queue_export->seqnum_max = udev_queue_export->seqnum_min; } @@ -292,10 +288,8 @@ static int write_queue_record(struct udev_queue_export *udev_queue_export, { unsigned short len; - if (udev_queue_export->queue_file == NULL) { - dbg(udev_queue_export->udev, "can't record event: queue file not available\n"); + if (udev_queue_export->queue_file == NULL) return -1; - } if (fwrite(&seqnum, sizeof(unsigned long long int), 1, udev_queue_export->queue_file) != 1) goto write_error; diff --git a/src/udev/libudev-queue.c b/src/udev/libudev-queue.c index 80a75a8fd7..72408d0166 100644 --- a/src/udev/libudev-queue.c +++ b/src/udev/libudev-queue.c @@ -154,7 +154,6 @@ _public_ unsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue * return -EINVAL; seqnum = udev_get_kernel_seqnum(udev_queue->udev); - dbg(udev_queue->udev, "seqnum=%llu\n", seqnum); return seqnum; } @@ -314,19 +313,13 @@ _public_ int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue) } } - if (queued > 0) { - dbg(udev_queue->udev, "queue is not empty\n"); + if (queued > 0) goto out; - } seqnum_kernel = udev_queue_get_kernel_seqnum(udev_queue); - if (seqnum_udev < seqnum_kernel) { - dbg(udev_queue->udev, "queue is empty but kernel events still pending [%llu]<->[%llu]\n", - seqnum_kernel, seqnum_udev); + if (seqnum_udev < seqnum_kernel) goto out; - } - dbg(udev_queue->udev, "queue is empty\n"); is_empty = 1; out: @@ -409,7 +402,6 @@ _public_ int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, un if (!udev_queue_get_seqnum_sequence_is_finished(udev_queue, seqnum, seqnum)) return 0; - dbg(udev_queue->udev, "seqnum: %llu finished\n", seqnum); return 1; } diff --git a/src/udev/libudev-selinux-private.c b/src/udev/libudev-selinux-private.c index 0f2a617b18..d68097f991 100644 --- a/src/udev/libudev-selinux-private.c +++ b/src/udev/libudev-selinux-private.c @@ -26,7 +26,7 @@ void udev_selinux_init(struct udev *udev) { /* record the present security context */ selinux_enabled = (is_selinux_enabled() > 0); - info(udev, "selinux=%i\n", selinux_enabled); + dbg(udev, "selinux=%i\n", selinux_enabled); if (!selinux_enabled) return; matchpathcon_init_prefix(NULL, udev_get_dev_path(udev)); diff --git a/src/udev/libudev-util-private.c b/src/udev/libudev-util-private.c index f764ab4d8b..2b2752bb54 100644 --- a/src/udev/libudev-util-private.c +++ b/src/udev/libudev-util-private.c @@ -41,7 +41,6 @@ static int create_path(struct udev *udev, const char *path, bool selinux) return 0; pos[0] = '\0'; - dbg(udev, "stat '%s'\n", p); if (stat(p, &stats) == 0) { if ((stats.st_mode & S_IFMT) == S_IFDIR) return 0; @@ -53,7 +52,6 @@ static int create_path(struct udev *udev, const char *path, bool selinux) if (err != 0) return err; - dbg(udev, "mkdir '%s'\n", p); if (selinux) udev_selinux_setfscreatecon(udev, p, S_IFDIR|0755); err = mkdir(p, 0755); @@ -226,7 +224,7 @@ int util_resolve_subsys_kernel(struct udev *udev, const char *string, util_strscpy(result, maxsize, val); else result[0] = '\0'; - info(udev, "value '[%s/%s]%s' is '%s'\n", subsys, sysname, attr, result); + dbg(udev, "value '[%s/%s]%s' is '%s'\n", subsys, sysname, attr, result); } else { size_t l; char *s; @@ -235,7 +233,7 @@ int util_resolve_subsys_kernel(struct udev *udev, const char *string, l = util_strpcpyl(&s, maxsize, udev_device_get_syspath(dev), NULL); if (attr != NULL) util_strpcpyl(&s, l, "/", attr, NULL); - info(udev, "path '[%s/%s]%s' is '%s'\n", subsys, sysname, attr, result); + dbg(udev, "path '[%s/%s]%s' is '%s'\n", subsys, sysname, attr, result); } udev_device_unref(dev); return 0; diff --git a/src/udev/libudev-util.c b/src/udev/libudev-util.c index 387767145d..cb17c3f48c 100644 --- a/src/udev/libudev-util.c +++ b/src/udev/libudev-util.c @@ -45,7 +45,6 @@ ssize_t util_get_sys_core_link_value(struct udev *udev, const char *slink, const if (pos == NULL) return -1; pos = &pos[1]; - dbg(udev, "resolved link to: '%s'\n", pos); return util_strscpy(value, size, pos); } @@ -62,11 +61,9 @@ int util_resolve_sys_link(struct udev *udev, char *syspath, size_t size) if (len <= 0 || len == (ssize_t)sizeof(link_target)) return -1; link_target[len] = '\0'; - dbg(udev, "path link '%s' points to '%s'\n", syspath, link_target); for (back = 0; strncmp(&link_target[back * 3], "../", 3) == 0; back++) ; - dbg(udev, "base '%s', tail '%s', back %i\n", syspath, &link_target[back * 3], back); for (i = 0; i <= back; i++) { base = strrchr(syspath, '/'); if (base == NULL) @@ -75,7 +72,6 @@ int util_resolve_sys_link(struct udev *udev, char *syspath, size_t size) } if (base == NULL) return -EINVAL; - dbg(udev, "after moving back '%s'\n", syspath); util_strscpyl(base, size - (base - syspath), "/", &link_target[back * 3], NULL); return 0; } diff --git a/src/udev/libudev.c b/src/udev/libudev.c index c2c5cda7ac..755d84d9bf 100644 --- a/src/udev/libudev.c +++ b/src/udev/libudev.c @@ -272,13 +272,6 @@ _public_ struct udev *udev_new(void) udev->rules_path_count = 3; } - dbg(udev, "context %p created\n", udev); - dbg(udev, "log_priority=%d\n", udev->log_priority); - dbg(udev, "config_file='%s'\n", config_file); - dbg(udev, "dev_path='%s'\n", udev->dev_path); - dbg(udev, "sys_path='%s'\n", udev->sys_path); - dbg(udev, "run_path='%s'\n", udev->run_path); - dbg(udev, "rules_path='%s':'%s':'%s'\n", udev->rules_path[0], udev->rules_path[1], udev->rules_path[2]); free(config_file); return udev; err: @@ -326,7 +319,6 @@ _public_ void udev_unref(struct udev *udev) free(udev->rules_path[1]); free(udev->rules_path[2]); free(udev->run_path); - dbg(udev, "context %p released\n", udev); free(udev); } @@ -346,7 +338,7 @@ _public_ void udev_set_log_fn(struct udev *udev, const char *format, va_list args)) { udev->log_fn = log_fn; - info(udev, "custom logging function %p registered\n", log_fn); + dbg(udev, "custom logging function %p registered\n", log_fn); } /** diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c index 206cbfd095..dd8517ba96 100644 --- a/src/udev/scsi_id/scsi_id.c +++ b/src/udev/scsi_id/scsi_id.c @@ -180,14 +180,12 @@ static int get_file_options(struct udev *udev, int c; int retval = 0; - dbg(udev, "vendor='%s'; model='%s'\n", vendor, model); fd = fopen(config_file, "r"); if (fd == NULL) { - dbg(udev, "can't open %s\n", config_file); if (errno == ENOENT) { return 1; } else { - err(udev, "can't open %s: %s\n", config_file, strerror(errno)); + log_error("can't open %s: %s\n", config_file, strerror(errno)); return -1; } } @@ -200,7 +198,7 @@ static int get_file_options(struct udev *udev, buffer = malloc(MAX_BUFFER_LEN); if (!buffer) { fclose(fd); - err(udev, "can't allocate memory\n"); + log_error("can't allocate memory\n"); return -1; } @@ -214,7 +212,7 @@ static int get_file_options(struct udev *udev, break; lineno++; if (buf[strlen(buffer) - 1] != '\n') { - err(udev, "Config file line %d too long\n", lineno); + log_error("Config file line %d too long\n", lineno); break; } @@ -229,7 +227,6 @@ static int get_file_options(struct udev *udev, if (*buf == '#') continue; - dbg(udev, "lineno %d: '%s'\n", lineno, buf); str1 = strsep(&buf, "="); if (str1 && strcasecmp(str1, "VENDOR") == 0) { str1 = get_value(&buf); @@ -259,22 +256,18 @@ static int get_file_options(struct udev *udev, } options_in = str1; } - dbg(udev, "config file line %d:\n" - " vendor '%s'; model '%s'; options '%s'\n", - lineno, vendor_in, model_in, options_in); + /* * Only allow: [vendor=foo[,model=bar]]options=stuff */ if (!options_in || (!vendor_in && model_in)) { - err(udev, "Error parsing config file line %d '%s'\n", lineno, buffer); + log_error("Error parsing config file line %d '%s'\n", lineno, buffer); retval = -1; break; } if (vendor == NULL) { - if (vendor_in == NULL) { - dbg(udev, "matched global option\n"); + if (vendor_in == NULL) break; - } } else if ((vendor_in && strncmp(vendor, vendor_in, strlen(vendor_in)) == 0) && (!model_in || (strncmp(model, model_in, @@ -286,10 +279,7 @@ static int get_file_options(struct udev *udev, * give a partial match (that is FOO * matches FOOBAR). */ - dbg(udev, "matched vendor/model\n"); break; - } else { - dbg(udev, "no match\n"); } } @@ -304,7 +294,7 @@ static int get_file_options(struct udev *udev, c = argc_count(buffer) + 2; *newargv = calloc(c, sizeof(**newargv)); if (!*newargv) { - err(udev, "can't allocate memory\n"); + log_error("can't allocate memory\n"); retval = -1; } else { *argc = c; @@ -346,11 +336,6 @@ static int set_options(struct udev *udev, if (option == -1) break; - if (optarg) - dbg(udev, "option '%c' arg '%s'\n", option, optarg); - else - dbg(udev, "option '%c'\n", option); - switch (option) { case 'b': all_good = 0; @@ -396,7 +381,7 @@ static int set_options(struct udev *udev, } else if (strcmp(optarg, "pre-spc3-83") == 0) { default_page_code = PAGE_83_PRE_SPC3; } else { - err(udev, "Unknown page code '%s'\n", optarg); + log_error("Unknown page code '%s'\n", optarg); return -1; } break; @@ -404,7 +389,7 @@ static int set_options(struct udev *udev, case 's': sg_version = atoi(optarg); if (sg_version < 3 || sg_version > 4) { - err(udev, "Unknown SG version '%s'\n", optarg); + log_error("Unknown SG version '%s'\n", optarg); return -1; } break; @@ -456,11 +441,6 @@ static int per_dev_options(struct udev *udev, if (option == -1) break; - if (optarg) - dbg(udev, "option '%c' arg '%s'\n", option, optarg); - else - dbg(udev, "option '%c'\n", option); - switch (option) { case 'b': *good_bad = 0; @@ -478,13 +458,13 @@ static int per_dev_options(struct udev *udev, } else if (strcmp(optarg, "pre-spc3-83") == 0) { *page_code = PAGE_83_PRE_SPC3; } else { - err(udev, "Unknown page code '%s'\n", optarg); + log_error("Unknown page code '%s'\n", optarg); retval = -1; } break; default: - err(udev, "Unknown or bad option '%c' (0x%x)\n", option, option); + log_error("Unknown or bad option '%c' (0x%x)\n", option, option); retval = -1; break; } @@ -540,7 +520,6 @@ static int scsi_id(struct udev *udev, char *maj_min_dev) /* get per device (vendor + model) options from the config file */ per_dev_options(udev, &dev_scsi, &good_dev, &page_code); - dbg(udev, "per dev options: good %d; page code 0x%x\n", good_dev, page_code); if (!good_dev) { retval = 1; goto out; @@ -616,7 +595,7 @@ int main(int argc, char **argv) if (udev == NULL) goto exit; - udev_log_init("scsi_id"); + log_open(); udev_set_log_fn(udev, log_fn); /* @@ -643,7 +622,7 @@ int main(int argc, char **argv) exit(1); if (!dev_specified) { - err(udev, "no device specified\n"); + log_error("no device specified\n"); retval = 1; goto exit; } @@ -652,6 +631,6 @@ int main(int argc, char **argv) exit: udev_unref(udev); - udev_log_close(); + log_close(); return retval; } diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c index f1d63f40cc..6bfb7f780c 100644 --- a/src/udev/scsi_id/scsi_serial.c +++ b/src/udev/scsi_id/scsi_serial.c @@ -196,10 +196,8 @@ static int scsi_dump_sense(struct udev *udev, * we'll retry the command. */ - dbg(udev, "got check condition\n"); - if (sb_len < 1) { - info(udev, "%s: sense buffer empty\n", dev_scsi->kernel); + log_debug("%s: sense buffer empty\n", dev_scsi->kernel); return -1; } @@ -212,7 +210,7 @@ static int scsi_dump_sense(struct udev *udev, */ s = sense_buffer[7] + 8; if (sb_len < s) { - info(udev, "%s: sense buffer too small %d bytes, %d bytes too short\n", + log_debug("%s: sense buffer too small %d bytes, %d bytes too short\n", dev_scsi->kernel, sb_len, s - sb_len); return -1; } @@ -222,7 +220,7 @@ static int scsi_dump_sense(struct udev *udev, /* * Possible? */ - info(udev, "%s: sense result too" " small %d bytes\n", + log_debug("%s: sense result too" " small %d bytes\n", dev_scsi->kernel, s); return -1; } @@ -233,39 +231,38 @@ static int scsi_dump_sense(struct udev *udev, asc = sense_buffer[2]; ascq = sense_buffer[3]; } else { - info(udev, "%s: invalid sense code 0x%x\n", + log_debug("%s: invalid sense code 0x%x\n", dev_scsi->kernel, code); return -1; } - info(udev, "%s: sense key 0x%x ASC 0x%x ASCQ 0x%x\n", + log_debug("%s: sense key 0x%x ASC 0x%x ASCQ 0x%x\n", dev_scsi->kernel, sense_key, asc, ascq); } else { if (sb_len < 4) { - info(udev, "%s: sense buffer too small %d bytes, %d bytes too short\n", + log_debug("%s: sense buffer too small %d bytes, %d bytes too short\n", dev_scsi->kernel, sb_len, 4 - sb_len); return -1; } if (sense_buffer[0] < 15) - info(udev, "%s: old sense key: 0x%x\n", dev_scsi->kernel, sense_buffer[0] & 0x0f); + log_debug("%s: old sense key: 0x%x\n", dev_scsi->kernel, sense_buffer[0] & 0x0f); else - info(udev, "%s: sense = %2x %2x\n", + log_debug("%s: sense = %2x %2x\n", dev_scsi->kernel, sense_buffer[0], sense_buffer[2]); - info(udev, "%s: non-extended sense class %d code 0x%0x\n", + log_debug("%s: non-extended sense class %d code 0x%0x\n", dev_scsi->kernel, sense_class, code); } #ifdef DUMP_SENSE for (i = 0, j = 0; (i < s) && (j < 254); i++) { - dbg(udev, "i %d, j %d\n", i, j); out_buffer[j++] = hex_str[(sense_buffer[i] & 0xf0) >> 4]; out_buffer[j++] = hex_str[sense_buffer[i] & 0x0f]; out_buffer[j++] = ' '; } out_buffer[j] = '\0'; - info(udev, "%s: sense dump:\n", dev_scsi->kernel); - info(udev, "%s: %s\n", dev_scsi->kernel, out_buffer); + log_debug("%s: sense dump:\n", dev_scsi->kernel); + log_debug("%s: %s\n", dev_scsi->kernel, out_buffer); #endif return -1; @@ -279,11 +276,11 @@ static int scsi_dump(struct udev *udev, /* * Impossible, should not be called. */ - info(udev, "%s: called with no error\n", __FUNCTION__); + log_debug("%s: called with no error\n", __FUNCTION__); return -1; } - info(udev, "%s: sg_io failed status 0x%x 0x%x 0x%x 0x%x\n", + log_debug("%s: sg_io failed status 0x%x 0x%x 0x%x 0x%x\n", dev_scsi->kernel, io->driver_status, io->host_status, io->msg_status, io->status); if (io->status == SCSI_CHECK_CONDITION) return scsi_dump_sense(udev, dev_scsi, io->sbp, io->sb_len_wr); @@ -299,11 +296,11 @@ static int scsi_dump_v4(struct udev *udev, /* * Impossible, should not be called. */ - info(udev, "%s: called with no error\n", __FUNCTION__); + log_debug("%s: called with no error\n", __FUNCTION__); return -1; } - info(udev, "%s: sg_io failed status 0x%x 0x%x 0x%x\n", + log_debug("%s: sg_io failed status 0x%x 0x%x 0x%x\n", dev_scsi->kernel, io->driver_status, io->transport_status, io->device_status); if (io->device_status == SCSI_CHECK_CONDITION) @@ -328,13 +325,11 @@ static int scsi_inquiry(struct udev *udev, int retval; if (buflen > SCSI_INQ_BUFF_LEN) { - info(udev, "buflen %d too long\n", buflen); + log_debug("buflen %d too long\n", buflen); return -1; } resend: - dbg(udev, "%s evpd %d, page 0x%x\n", dev_scsi->kernel, evpd, page); - if (dev_scsi->use_sg == 4) { memset(&io_v4, 0, sizeof(struct sg_io_v4)); io_v4.guard = 'Q'; @@ -367,7 +362,7 @@ resend: dev_scsi->use_sg = 3; goto resend; } - info(udev, "%s: ioctl failed: %s\n", dev_scsi->kernel, strerror(errno)); + log_debug("%s: ioctl failed: %s\n", dev_scsi->kernel, strerror(errno)); goto error; } @@ -395,16 +390,14 @@ resend: if (!retval) { retval = buflen; } else if (retval > 0) { - if (--retry > 0) { - dbg(udev, "%s: Retrying ...\n", dev_scsi->kernel); + if (--retry > 0) goto resend; - } retval = -1; } error: if (retval < 0) - info(udev, "%s: Unable to get INQUIRY vpd %d page 0x%x.\n", + log_debug("%s: Unable to get INQUIRY vpd %d page 0x%x.\n", dev_scsi->kernel, evpd, page); return retval; @@ -423,11 +416,11 @@ static int do_scsi_page0_inquiry(struct udev *udev, return 1; if (buffer[1] != 0) { - info(udev, "%s: page 0 not available.\n", dev_scsi->kernel); + log_debug("%s: page 0 not available.\n", dev_scsi->kernel); return 1; } if (buffer[3] > len) { - info(udev, "%s: page 0 buffer too long %d\n", dev_scsi->kernel, buffer[3]); + log_debug("%s: page 0 buffer too long %d\n", dev_scsi->kernel, buffer[3]); return 1; } @@ -444,7 +437,7 @@ static int do_scsi_page0_inquiry(struct udev *udev, * invalid. */ if (!strncmp((char *)&buffer[VENDOR_LENGTH], dev_scsi->vendor, VENDOR_LENGTH)) { - info(udev, "%s: invalid page0 data\n", dev_scsi->kernel); + log_debug("%s: invalid page0 data\n", dev_scsi->kernel); return 1; } } @@ -469,7 +462,7 @@ static int prepend_vendor_model(struct udev *udev, * above, ind will never be too large. */ if (ind != (VENDOR_LENGTH + MODEL_LENGTH)) { - info(udev, "%s: expected length %d, got length %d\n", + log_debug("%s: expected length %d, got length %d\n", dev_scsi->kernel, (VENDOR_LENGTH + MODEL_LENGTH), ind); return -1; } @@ -535,7 +528,7 @@ static int check_fill_0x83_id(struct udev *udev, len += VENDOR_LENGTH + MODEL_LENGTH; if (max_len < len) { - info(udev, "%s: length %d too short - need %d\n", + log_debug("%s: length %d too short - need %d\n", dev_scsi->kernel, max_len, len); return 1; } @@ -557,10 +550,8 @@ static int check_fill_0x83_id(struct udev *udev, * included in the identifier. */ if (id_search->id_type == SCSI_ID_VENDOR_SPECIFIC) - if (prepend_vendor_model(udev, dev_scsi, &serial[1]) < 0) { - dbg(udev, "prepend failed\n"); + if (prepend_vendor_model(udev, dev_scsi, &serial[1]) < 0) return 1; - } i = 4; /* offset to the start of the identifier */ s = j = strlen(serial); @@ -603,7 +594,6 @@ static int check_fill_0x83_prespc3(struct udev *udev, { int i, j; - dbg(udev, "using pre-spc3-83 for %s\n", dev_scsi->kernel); serial[0] = hex_str[id_search->id_type]; /* serial has been memset to zero before */ j = strlen(serial); /* j = 1; */ @@ -639,7 +629,7 @@ static int do_scsi_page83_inquiry(struct udev *udev, return 1; if (page_83[1] != PAGE_83) { - info(udev, "%s: Invalid page 0x83\n", dev_scsi->kernel); + log_debug("%s: Invalid page 0x83\n", dev_scsi->kernel); return 1; } @@ -695,19 +685,10 @@ static int do_scsi_page83_inquiry(struct udev *udev, serial, serial_short, len, wwn, wwn_vendor_extension, tgpt_group); - dbg(udev, "%s id desc %d/%d/%d\n", dev_scsi->kernel, - id_search_list[id_ind].id_type, - id_search_list[id_ind].naa_type, - id_search_list[id_ind].code_set); - if (!retval) { - dbg(udev, " used\n"); + if (!retval) return retval; - } else if (retval < 0) { - dbg(udev, " failed\n"); + else if (retval < 0) return retval; - } else { - dbg(udev, " not used\n"); - } } } return 1; @@ -734,7 +715,7 @@ static int do_scsi_page83_prespc3_inquiry(struct udev *udev, return 1; if (page_83[1] != PAGE_83) { - info(udev, "%s: Invalid page 0x83\n", dev_scsi->kernel); + log_debug("%s: Invalid page 0x83\n", dev_scsi->kernel); return 1; } /* @@ -778,7 +759,6 @@ static int do_scsi_page83_prespc3_inquiry(struct udev *udev, serial[j++] = hex_str[page_83[i] & 0x0f]; i++; } - dbg(udev, "using pre-spc3-83 for %s\n", dev_scsi->kernel); return 0; } @@ -799,13 +779,13 @@ static int do_scsi_page80_inquiry(struct udev *udev, return retval; if (buf[1] != PAGE_80) { - info(udev, "%s: Invalid page 0x80\n", dev_scsi->kernel); + log_debug("%s: Invalid page 0x80\n", dev_scsi->kernel); return 1; } len = 1 + VENDOR_LENGTH + MODEL_LENGTH + buf[3]; if (max_len < len) { - info(udev, "%s: length %d too short - need %d\n", + log_debug("%s: length %d too short - need %d\n", dev_scsi->kernel, max_len, len); return 1; } @@ -837,16 +817,15 @@ int scsi_std_inquiry(struct udev *udev, struct stat statbuf; int err = 0; - dbg(udev, "opening %s\n", devname); fd = open(devname, O_RDONLY | O_NONBLOCK); if (fd < 0) { - info(udev, "scsi_id: cannot open %s: %s\n", + log_debug("scsi_id: cannot open %s: %s\n", devname, strerror(errno)); return 1; } if (fstat(fd, &statbuf) < 0) { - info(udev, "scsi_id: cannot stat %s: %s\n", + log_debug("scsi_id: cannot stat %s: %s\n", devname, strerror(errno)); err = 2; goto out; @@ -884,7 +863,6 @@ int scsi_get_serial(struct udev *udev, int retval; memset(dev_scsi->serial, 0, len); - dbg(udev, "opening %s\n", devname); srand((unsigned int)getpid()); for (cnt = 20; cnt > 0; cnt--) { struct timespec duration; @@ -941,7 +919,7 @@ int scsi_get_serial(struct udev *udev, goto completed; } } else if (page_code != 0x00) { - info(udev, "%s: unsupported page code 0x%d\n", dev_scsi->kernel, page_code); + log_debug("%s: unsupported page code 0x%d\n", dev_scsi->kernel, page_code); return 1; } @@ -959,8 +937,6 @@ int scsi_get_serial(struct udev *udev, goto completed; } - dbg(udev, "%s: Checking page0\n", dev_scsi->kernel); - for (ind = 4; ind <= page0[3] + 3; ind++) if (page0[ind] == PAGE_83) if (!do_scsi_page83_inquiry(udev, dev_scsi, fd, diff --git a/src/udev/test-udev.c b/src/udev/test-udev.c index c9712e974d..8cf07cc578 100644 --- a/src/udev/test-udev.c +++ b/src/udev/test-udev.c @@ -49,20 +49,20 @@ int main(int argc, char *argv[]) udev = udev_new(); if (udev == NULL) exit(1); - info(udev, "version %s\n", VERSION); + log_debug("version %s\n", VERSION); udev_selinux_init(udev); sigprocmask(SIG_SETMASK, NULL, &sigmask_orig); action = argv[1]; if (action == NULL) { - err(udev, "action missing\n"); + log_error("action missing\n"); goto out; } devpath = argv[2]; if (devpath == NULL) { - err(udev, "devpath missing\n"); + log_error("devpath missing\n"); goto out; } @@ -71,7 +71,7 @@ int main(int argc, char *argv[]) util_strscpyl(syspath, sizeof(syspath), udev_get_sys_path(udev), devpath, NULL); dev = udev_device_new_from_syspath(udev, syspath); if (dev == NULL) { - info(udev, "unknown device '%s'\n", devpath); + log_debug("unknown device '%s'\n", devpath); goto out; } diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index e57f03e5a1..174e20e2fa 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -174,9 +174,9 @@ static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool t if (err < 0) goto out; - info(udev, "probe %s %sraid offset=%llu\n", - udev_device_get_devnode(dev), - noraid ? "no" : "", (unsigned long long) offset); + log_debug("probe %s %sraid offset=%llu\n", + udev_device_get_devnode(dev), + noraid ? "no" : "", (unsigned long long) offset); err = probe_superblocks(pr); if (err < 0) diff --git a/src/udev/udev-builtin-firmware.c b/src/udev/udev-builtin-firmware.c index d212c64b4d..0bc09e004f 100644 --- a/src/udev/udev-builtin-firmware.c +++ b/src/udev/udev-builtin-firmware.c @@ -33,7 +33,7 @@ static bool set_loading(struct udev *udev, char *loadpath, const char *state) ldfile = fopen(loadpath, "we"); if (ldfile == NULL) { - err(udev, "error: can not open '%s'\n", loadpath); + log_error("error: can not open '%s'\n", loadpath); return false; }; fprintf(ldfile, "%s\n", state); @@ -49,11 +49,11 @@ static bool copy_firmware(struct udev *udev, const char *source, const char *tar buf = malloc(size); if (buf == NULL) { - err(udev,"No memory available to load firmware file"); + log_error("No memory available to load firmware file"); return false; } - info(udev, "writing '%s' (%zi) to '%s'\n", source, size, target); + log_debug("writing '%s' (%zi) to '%s'\n", source, size, target); fsource = fopen(source, "re"); if (fsource == NULL) @@ -92,7 +92,7 @@ static int builtin_firmware(struct udev_device *dev, int argc, char *argv[], boo firmware = udev_device_get_property_value(dev, "FIRMWARE"); if (firmware == NULL) { - err(udev, "firmware parameter missing\n\n"); + log_error("firmware parameter missing\n\n"); rc = EXIT_FAILURE; goto exit; } @@ -101,13 +101,11 @@ static int builtin_firmware(struct udev_device *dev, int argc, char *argv[], boo uname(&kernel); for (i = 0; i < ARRAY_SIZE(searchpath); i++) { util_strscpyl(fwpath, sizeof(fwpath), searchpath[i], kernel.release, "/", firmware, NULL); - dbg(udev, "trying %s\n", fwpath); fwfile = fopen(fwpath, "re"); if (fwfile != NULL) break; util_strscpyl(fwpath, sizeof(fwpath), searchpath[i], firmware, NULL); - dbg(udev, "trying %s\n", fwpath); fwfile = fopen(fwpath, "re"); if (fwfile != NULL) break; @@ -121,7 +119,7 @@ static int builtin_firmware(struct udev_device *dev, int argc, char *argv[], boo int err; /* This link indicates the missing firmware file and the associated device */ - info(udev, "did not find firmware file '%s'\n", firmware); + log_debug("did not find firmware file '%s'\n", firmware); do { err = util_create_path(udev, misspath); if (err != 0 && err != -ENOENT) @@ -147,7 +145,7 @@ static int builtin_firmware(struct udev_device *dev, int argc, char *argv[], boo util_strscpyl(datapath, sizeof(datapath), udev_device_get_syspath(dev), "/data", NULL); if (!copy_firmware(udev, fwpath, datapath, statbuf.st_size)) { - err(udev, "error sending firmware '%s' to device\n", firmware); + log_error("error sending firmware '%s' to device\n", firmware); set_loading(udev, loadpath, "-1"); rc = EXIT_FAILURE; goto exit; diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c index a062ef7c7a..ee8294b700 100644 --- a/src/udev/udev-builtin-input_id.c +++ b/src/udev/udev-builtin-input_id.c @@ -56,7 +56,7 @@ static void get_cap_mask(struct udev_device *dev, unsigned long val; snprintf(text, sizeof(text), "%s", udev_device_get_sysattr_value(pdev, attr)); - info(udev, "%s raw kernel attribute: %s\n", attr, text); + log_debug("%s raw kernel attribute: %s\n", attr, text); memset (bitmask, 0, bitmask_size); i = 0; @@ -65,7 +65,7 @@ static void get_cap_mask(struct udev_device *dev, if (i < bitmask_size/sizeof(unsigned long)) bitmask[i] = val; else - info(udev, "ignoring %s block %lX which is larger than maximum size\n", attr, val); + log_debug("ignoring %s block %lX which is larger than maximum size\n", attr, val); *word = '\0'; ++i; } @@ -73,18 +73,18 @@ static void get_cap_mask(struct udev_device *dev, if (i < bitmask_size / sizeof(unsigned long)) bitmask[i] = val; else - info(udev, "ignoring %s block %lX which is larger than maximum size\n", attr, val); + log_debug("ignoring %s block %lX which is larger than maximum size\n", attr, val); if (test) { /* printf pattern with the right unsigned long number of hex chars */ snprintf(text, sizeof(text), " bit %%4u: %%0%zilX\n", 2 * sizeof(unsigned long)); - info(udev, "%s decoded bit map:\n", attr); + log_debug("%s decoded bit map:\n", attr); val = bitmask_size / sizeof (unsigned long); /* skip over leading zeros */ while (bitmask[val-1] == 0 && val > 0) --val; for (i = 0; i < val; ++i) - info(udev, text, i * BITS_PER_LONG, bitmask[i]); + log_debug(text, i * BITS_PER_LONG, bitmask[i]); } } @@ -150,7 +150,7 @@ static void test_key (struct udev_device *dev, /* do we have any KEY_* capability? */ if (!test_bit (EV_KEY, bitmask_ev)) { - info(udev, "test_key: no EV_KEY capability\n"); + log_debug("test_key: no EV_KEY capability\n"); return; } @@ -158,13 +158,13 @@ static void test_key (struct udev_device *dev, found = 0; for (i = 0; i < BTN_MISC/BITS_PER_LONG; ++i) { found |= bitmask_key[i]; - info(udev, "test_key: checking bit block %lu for any keys; found=%i\n", i*BITS_PER_LONG, found > 0); + log_debug("test_key: checking bit block %lu for any keys; found=%i\n", i*BITS_PER_LONG, found > 0); } /* If there are no keys in the lower block, check the higher block */ if (!found) { for (i = KEY_OK; i < BTN_TRIGGER_HAPPY; ++i) { if (test_bit (i, bitmask_key)) { - info(udev, "test_key: Found key %x in high block\n", i); + log_debug("test_key: Found key %x in high block\n", i); found = 1; break; } diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c index 57e813f863..87a81bfaab 100644 --- a/src/udev/udev-builtin-kmod.c +++ b/src/udev/udev-builtin-kmod.c @@ -44,18 +44,18 @@ static int load_module(struct udev *udev, const char *alias) return err; if (list == NULL) - info(udev, "no module matches '%s'\n", alias); + log_debug("no module matches '%s'\n", alias); kmod_list_foreach(l, list) { struct kmod_module *mod = kmod_module_get_module(l); err = kmod_module_probe_insert_module(mod, KMOD_PROBE_APPLY_BLACKLIST, NULL, NULL, NULL, NULL); if (err == KMOD_PROBE_APPLY_BLACKLIST) - info(udev, "module '%s' is blacklisted\n", kmod_module_get_name(mod)); + log_debug("module '%s' is blacklisted\n", kmod_module_get_name(mod)); else if (err == 0) - info(udev, "inserted '%s'\n", kmod_module_get_name(mod)); + log_debug("inserted '%s'\n", kmod_module_get_name(mod)); else - info(udev, "failed to insert '%s'\n", kmod_module_get_name(mod)); + log_debug("failed to insert '%s'\n", kmod_module_get_name(mod)); kmod_module_unref(mod); } @@ -81,18 +81,18 @@ static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool te if (!ctx) return -ENOMEM; - info(udev, "load module index\n"); + log_debug("load module index\n"); kmod_set_log_fn(ctx, udev_kmod_log, udev); kmod_load_resources(ctx); } if (argc < 3 || strcmp(argv[1], "load")) { - err(udev, "expect: %s load \n", argv[0]); + log_error("expect: %s load \n", argv[0]); return EXIT_FAILURE; } for (i = 2; argv[i]; i++) { - info(udev, "execute '%s' '%s'\n", argv[1], argv[i]); + log_debug("execute '%s' '%s'\n", argv[1], argv[i]); load_module(udev, argv[i]); } @@ -109,7 +109,7 @@ static int builtin_kmod_init(struct udev *udev) if (!ctx) return -ENOMEM; - info(udev, "load module index\n"); + log_debug("load module index\n"); kmod_set_log_fn(ctx, udev_kmod_log, udev); kmod_load_resources(ctx); return 0; @@ -118,14 +118,14 @@ static int builtin_kmod_init(struct udev *udev) /* called on udev shutdown and reload request */ static void builtin_kmod_exit(struct udev *udev) { - info(udev, "unload module index\n"); + log_debug("unload module index\n"); ctx = kmod_unref(ctx); } /* called every couple of seconds during event activity; 'true' if config has changed */ static bool builtin_kmod_validate(struct udev *udev) { - info(udev, "validate module index\n"); + log_debug("validate module index\n"); if (kmod_validate_resources(ctx) != KMOD_RESOURCES_OK) return true; return false; diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c index 85828e32d7..6481b35ae7 100644 --- a/src/udev/udev-builtin-usb_id.c +++ b/src/udev/udev-builtin-usb_id.c @@ -273,8 +273,6 @@ static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool type_str[0] = '\0'; instance_str[0] = '\0'; - dbg(udev, "syspath %s\n", udev_device_get_syspath(dev)); - /* shortcut, if we are called directly for a "usb_device" type */ if (udev_device_get_devtype(dev) != NULL && strcmp(udev_device_get_devtype(dev), "usb_device") == 0) { dev_if_packed_info(dev, packed_if_str, sizeof(packed_if_str)); @@ -285,7 +283,7 @@ static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool /* usb interface directory */ dev_interface = udev_device_get_parent_with_subsystem_devtype(dev, "usb", "usb_interface"); if (dev_interface == NULL) { - info(udev, "unable to access usb_interface device of '%s'\n", + log_debug("unable to access usb_interface device of '%s'\n", udev_device_get_syspath(dev)); return EXIT_FAILURE; } @@ -295,7 +293,7 @@ static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool if_class = udev_device_get_sysattr_value(dev_interface, "bInterfaceClass"); if (!if_class) { - info(udev, "%s: cannot get bInterfaceClass attribute\n", + log_debug("%s: cannot get bInterfaceClass attribute\n", udev_device_get_sysname(dev)); return EXIT_FAILURE; } @@ -310,13 +308,13 @@ static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool set_usb_iftype(type_str, if_class_num, sizeof(type_str)-1); } - info(udev, "%s: if_class %d protocol %d\n", + log_debug("%s: if_class %d protocol %d\n", udev_device_get_syspath(dev_interface), if_class_num, protocol); /* usb device directory */ dev_usb = udev_device_get_parent_with_subsystem_devtype(dev_interface, "usb", "usb_device"); if (!dev_usb) { - info(udev, "unable to find parent 'usb' device of '%s'\n", + log_debug("unable to find parent 'usb' device of '%s'\n", udev_device_get_syspath(dev)); return EXIT_FAILURE; } @@ -333,19 +331,19 @@ static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool /* get scsi device */ dev_scsi = udev_device_get_parent_with_subsystem_devtype(dev, "scsi", "scsi_device"); if (dev_scsi == NULL) { - info(udev, "unable to find parent 'scsi' device of '%s'\n", + log_debug("unable to find parent 'scsi' device of '%s'\n", udev_device_get_syspath(dev)); goto fallback; } if (sscanf(udev_device_get_sysname(dev_scsi), "%d:%d:%d:%d", &host, &bus, &target, &lun) != 4) { - info(udev, "invalid scsi device '%s'\n", udev_device_get_sysname(dev_scsi)); + log_debug("invalid scsi device '%s'\n", udev_device_get_sysname(dev_scsi)); goto fallback; } /* Generic SPC-2 device */ scsi_vendor = udev_device_get_sysattr_value(dev_scsi, "vendor"); if (!scsi_vendor) { - info(udev, "%s: cannot get SCSI vendor attribute\n", + log_debug("%s: cannot get SCSI vendor attribute\n", udev_device_get_sysname(dev_scsi)); goto fallback; } @@ -355,7 +353,7 @@ static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool scsi_model = udev_device_get_sysattr_value(dev_scsi, "model"); if (!scsi_model) { - info(udev, "%s: cannot get SCSI model attribute\n", + log_debug("%s: cannot get SCSI model attribute\n", udev_device_get_sysname(dev_scsi)); goto fallback; } @@ -365,7 +363,7 @@ static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool scsi_type = udev_device_get_sysattr_value(dev_scsi, "type"); if (!scsi_type) { - info(udev, "%s: cannot get SCSI type attribute\n", + log_debug("%s: cannot get SCSI type attribute\n", udev_device_get_sysname(dev_scsi)); goto fallback; } @@ -373,7 +371,7 @@ static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool scsi_rev = udev_device_get_sysattr_value(dev_scsi, "rev"); if (!scsi_rev) { - info(udev, "%s: cannot get SCSI revision attribute\n", + log_debug("%s: cannot get SCSI revision attribute\n", udev_device_get_sysname(dev_scsi)); goto fallback; } @@ -399,7 +397,7 @@ fallback: if (!usb_vendor) usb_vendor = vendor_id; if (!usb_vendor) { - info(udev, "No USB vendor information available\n"); + log_debug("No USB vendor information available\n"); return EXIT_FAILURE; } udev_util_encode_string(usb_vendor, vendor_str_enc, sizeof(vendor_str_enc)); @@ -413,10 +411,8 @@ fallback: usb_model = udev_device_get_sysattr_value(dev_usb, "product"); if (!usb_model) usb_model = product_id; - if (!usb_model) { - dbg(udev, "No USB model information available\n"); + if (!usb_model) return EXIT_FAILURE; - } udev_util_encode_string(usb_model, model_str_enc, sizeof(model_str_enc)); util_replace_whitespace(usb_model, model_str, sizeof(model_str)-1); util_replace_chars(model_str, NULL); diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c index 5bc5fa68f6..b6b3ddc019 100644 --- a/src/udev/udev-builtin.c +++ b/src/udev/udev-builtin.c @@ -127,7 +127,7 @@ int udev_builtin_add_property(struct udev_device *dev, bool test, const char *ke if (key[0] != '.') udev_list_entry_set_num(entry, true); - info(udev_device_get_udev(dev), "%s=%s\n", key, val); + log_debug("%s=%s\n", key, val); if (test) printf("%s=%s\n", key, val); return 0; diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c index 5556f1a77c..dd345f80a2 100644 --- a/src/udev/udev-ctrl.c +++ b/src/udev/udev-ctrl.c @@ -83,7 +83,7 @@ struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd) if (fd < 0) { uctrl->sock = socket(AF_LOCAL, SOCK_SEQPACKET|SOCK_NONBLOCK|SOCK_CLOEXEC, 0); if (uctrl->sock < 0) { - err(udev, "error getting socket: %m\n"); + log_error("error getting socket: %m\n"); udev_ctrl_unref(uctrl); return NULL; } @@ -117,14 +117,14 @@ int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl) if (err < 0) { err = -errno; - err(uctrl->udev, "bind failed: %m\n"); + log_error("bind failed: %m\n"); return err; } err = listen(uctrl->sock, 0); if (err < 0) { err = -errno; - err(uctrl->udev, "listen failed: %m\n"); + log_error("listen failed: %m\n"); return err; } @@ -192,18 +192,18 @@ struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) conn->sock = accept4(uctrl->sock, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK); if (conn->sock < 0) { if (errno != EINTR) - err(uctrl->udev, "unable to receive ctrl connection: %m\n"); + log_error("unable to receive ctrl connection: %m\n"); goto err; } /* check peer credential of connection */ slen = sizeof(ucred); if (getsockopt(conn->sock, SOL_SOCKET, SO_PEERCRED, &ucred, &slen) < 0) { - err(uctrl->udev, "unable to receive credentials of ctrl connection: %m\n"); + log_error("unable to receive credentials of ctrl connection: %m\n"); goto err; } if (ucred.uid > 0) { - err(uctrl->udev, "sender uid=%i, message ignored\n", ucred.uid); + log_error("sender uid=%i, message ignored\n", ucred.uid); goto err; } @@ -367,11 +367,11 @@ struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn) continue; goto err; } else if (r == 0) { - err(udev, "timeout waiting for ctrl message\n"); + log_error("timeout waiting for ctrl message\n"); goto err; } else { if (!(pfd[0].revents & POLLIN)) { - err(udev, "ctrl connection error: %m\n"); + log_error("ctrl connection error: %m\n"); goto err; } } @@ -388,28 +388,27 @@ struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn) smsg.msg_controllen = sizeof(cred_msg); size = recvmsg(conn->sock, &smsg, 0); if (size < 0) { - err(udev, "unable to receive ctrl message: %m\n"); + log_error("unable to receive ctrl message: %m\n"); goto err; } cmsg = CMSG_FIRSTHDR(&smsg); cred = (struct ucred *) CMSG_DATA(cmsg); if (cmsg == NULL || cmsg->cmsg_type != SCM_CREDENTIALS) { - err(udev, "no sender credentials received, message ignored\n"); + log_error("no sender credentials received, message ignored\n"); goto err; } if (cred->uid != 0) { - err(udev, "sender uid=%i, message ignored\n", cred->uid); + log_error("sender uid=%i, message ignored\n", cred->uid); goto err; } if (uctrl_msg->ctrl_msg_wire.magic != UDEV_CTRL_MAGIC) { - err(udev, "message magic 0x%08x doesn't match, ignore it\n", uctrl_msg->ctrl_msg_wire.magic); + log_error("message magic 0x%08x doesn't match, ignore it\n", uctrl_msg->ctrl_msg_wire.magic); goto err; } - dbg(udev, "created ctrl_msg %p (%i)\n", uctrl_msg, uctrl_msg->ctrl_msg_wire.type); return uctrl_msg; err: udev_ctrl_msg_unref(uctrl_msg); @@ -431,7 +430,6 @@ struct udev_ctrl_msg *udev_ctrl_msg_unref(struct udev_ctrl_msg *ctrl_msg) ctrl_msg->refcount--; if (ctrl_msg->refcount > 0) return ctrl_msg; - dbg(ctrl_msg->conn->uctrl->udev, "release ctrl_msg %p\n", ctrl_msg); udev_ctrl_connection_unref(ctrl_msg->conn); free(ctrl_msg); return NULL; diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index 40a6b7d33e..703581a8b3 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -50,7 +50,6 @@ struct udev_event *udev_event_new(struct udev_device *dev) event->fd_signal = -1; event->birth_usec = now_usec(); event->timeout_usec = 30 * 1000 * 1000; - dbg(event->udev, "allocated event %p\n", event); return event; } @@ -61,7 +60,6 @@ void udev_event_unref(struct udev_event *event) udev_list_cleanup(&event->run_list); free(event->program_result); free(event->name); - dbg(event->udev, "free event %p\n", event); free(event); } @@ -138,7 +136,6 @@ size_t udev_event_apply_format(struct udev_event *event, const char *src, char * if (strncmp(&from[1], map[i].name, strlen(map[i].name)) == 0) { type = map[i].type; from += strlen(map[i].name)+1; - dbg(event->udev, "will substitute format name '%s'\n", map[i].name); goto subst; } } @@ -155,7 +152,6 @@ size_t udev_event_apply_format(struct udev_event *event, const char *src, char * if (from[1] == map[i].fmt) { type = map[i].type; from += 2; - dbg(event->udev, "will substitute format char '%c'\n", map[i].fmt); goto subst; } } @@ -179,7 +175,7 @@ subst: from++; for (i = 0; from[i] != '}'; i++) { if (from[i] == '\0') { - err(event->udev, "missing closing brace for format '%s'\n", src); + log_error("missing closing brace for format '%s'\n", src); goto out; } } @@ -196,23 +192,19 @@ subst: switch (type) { case SUBST_DEVPATH: l = util_strpcpy(&s, l, udev_device_get_devpath(dev)); - dbg(event->udev, "substitute devpath '%s'\n", udev_device_get_devpath(dev)); break; case SUBST_KERNEL: l = util_strpcpy(&s, l, udev_device_get_sysname(dev)); - dbg(event->udev, "substitute kernel name '%s'\n", udev_device_get_sysname(dev)); break; case SUBST_KERNEL_NUMBER: if (udev_device_get_sysnum(dev) == NULL) break; l = util_strpcpy(&s, l, udev_device_get_sysnum(dev)); - dbg(event->udev, "substitute kernel number '%s'\n", udev_device_get_sysnum(dev)); break; case SUBST_ID: if (event->dev_parent == NULL) break; l = util_strpcpy(&s, l, udev_device_get_sysname(event->dev_parent)); - dbg(event->udev, "substitute id '%s'\n", udev_device_get_sysname(event->dev_parent)); break; case SUBST_DRIVER: { const char *driver; @@ -224,7 +216,6 @@ subst: if (driver == NULL) break; l = util_strpcpy(&s, l, driver); - dbg(event->udev, "substitute driver '%s'\n", driver); break; } case SUBST_MAJOR: { @@ -232,7 +223,6 @@ subst: sprintf(num, "%d", major(udev_device_get_devnum(dev))); l = util_strpcpy(&s, l, num); - dbg(event->udev, "substitute major number '%s'\n", num); break; } case SUBST_MINOR: { @@ -240,7 +230,6 @@ subst: sprintf(num, "%d", minor(udev_device_get_devnum(dev))); l = util_strpcpy(&s, l, num); - dbg(event->udev, "substitute minor number '%s'\n", num); break; } case SUBST_RESULT: { @@ -258,7 +247,6 @@ subst: char tmp[UTIL_PATH_SIZE]; char *cpos; - dbg(event->udev, "request part #%d of result string\n", i); util_strscpy(result, sizeof(result), event->program_result); cpos = result; while (--i) { @@ -268,7 +256,7 @@ subst: cpos++; } if (i > 0) { - err(event->udev, "requested part of result string not found\n"); + log_error("requested part of result string not found\n"); break; } util_strscpy(tmp, sizeof(tmp), cpos); @@ -279,10 +267,8 @@ subst: cpos[0] = '\0'; } l = util_strpcpy(&s, l, tmp); - dbg(event->udev, "substitute part of result string '%s'\n", tmp); } else { l = util_strpcpy(&s, l, event->program_result); - dbg(event->udev, "substitute result string '%s'\n", event->program_result); } break; } @@ -293,7 +279,7 @@ subst: int count; if (attr == NULL) { - err(event->udev, "missing file parameter for attr\n"); + log_error("missing file parameter for attr\n"); break; } @@ -320,9 +306,8 @@ subst: vbuf[len] = '\0'; count = util_replace_chars(vbuf, UDEV_ALLOWED_CHARS_INPUT); if (count > 0) - info(event->udev, "%i character(s) replaced\n" , count); + log_debug("%i character(s) replaced\n" , count); l = util_strpcpy(&s, l, vbuf); - dbg(event->udev, "substitute sysfs value '%s'\n", vbuf); break; } case SUBST_PARENT: { @@ -337,8 +322,6 @@ subst: size_t devlen = strlen(udev_get_dev_path(event->udev))+1; l = util_strpcpy(&s, l, &devnode[devlen]); - dbg(event->udev, "found parent '%s', got node name '%s'\n", - udev_device_get_syspath(dev_parent), &devnode[devlen]); } break; } @@ -349,15 +332,12 @@ subst: case SUBST_NAME: { if (event->name != NULL) { l = util_strpcpy(&s, l, event->name); - dbg(event->udev, "substitute custom node name '%s'\n", event->name); } else if (udev_device_get_devnode(dev) != NULL) { size_t devlen = strlen(udev_get_dev_path(event->udev))+1; l = util_strpcpy(&s, l, &udev_device_get_devnode(dev)[devlen]); - dbg(event->udev, "substitute node name'%s'\n", &udev_device_get_devnode(dev)[devlen]); } else { l = util_strpcpy(&s, l, udev_device_get_sysname(dev)); - dbg(event->udev, "substitute device name'%s'\n", udev_device_get_sysname(dev)); } break; } @@ -375,15 +355,12 @@ subst: } case SUBST_ROOT: l = util_strpcpy(&s, l, udev_get_dev_path(event->udev)); - dbg(event->udev, "substitute udev_root '%s'\n", udev_get_dev_path(event->udev)); break; case SUBST_SYS: l = util_strpcpy(&s, l, udev_get_sys_path(event->udev)); - dbg(event->udev, "substitute sys_path '%s'\n", udev_get_sys_path(event->udev)); break; case SUBST_ENV: if (attr == NULL) { - dbg(event->udev, "missing attribute\n"); break; } else { const char *value; @@ -391,19 +368,17 @@ subst: value = udev_device_get_property_value(event->dev, attr); if (value == NULL) break; - dbg(event->udev, "substitute env '%s=%s'\n", attr, value); l = util_strpcpy(&s, l, value); break; } default: - err(event->udev, "unknown substitution type=%i\n", type); + log_error("unknown substitution type=%i\n", type); break; } } out: s[0] = '\0'; - dbg(event->udev, "'%s' -> '%s' (%zu)\n", src, dest, l); return l; } @@ -425,7 +400,7 @@ static int spawn_exec(struct udev_event *event, dup2(fd, STDERR_FILENO); close(fd); } else { - err(udev, "open /dev/null failed: %m\n"); + log_error("open /dev/null failed: %m\n"); } /* connect pipes to std{out,err} */ @@ -449,7 +424,7 @@ static int spawn_exec(struct udev_event *event, /* exec failed */ err = -errno; - err(udev, "failed to execute '%s' '%s': %m\n", argv[0], cmd); + log_error("failed to execute '%s' '%s': %m\n", argv[0], cmd); return err; } @@ -469,7 +444,7 @@ static void spawn_read(struct udev_event *event, fd_ep = epoll_create1(EPOLL_CLOEXEC); if (fd_ep < 0) { - err(udev, "error creating epoll fd: %m\n"); + log_error("error creating epoll fd: %m\n"); goto out; } @@ -478,7 +453,7 @@ static void spawn_read(struct udev_event *event, ep_outpipe.events = EPOLLIN; ep_outpipe.data.ptr = &fd_stdout; if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_stdout, &ep_outpipe) < 0) { - err(udev, "fail to add fd to epoll: %m\n"); + log_error("fail to add fd to epoll: %m\n"); goto out; } } @@ -488,7 +463,7 @@ static void spawn_read(struct udev_event *event, ep_errpipe.events = EPOLLIN; ep_errpipe.data.ptr = &fd_stderr; if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_stderr, &ep_errpipe) < 0) { - err(udev, "fail to add fd to epoll: %m\n"); + log_error("fail to add fd to epoll: %m\n"); goto out; } } @@ -505,7 +480,7 @@ static void spawn_read(struct udev_event *event, age_usec = now_usec() - event->birth_usec; if (age_usec >= event->timeout_usec) { - err(udev, "timeout '%s'\n", cmd); + log_error("timeout '%s'\n", cmd); goto out; } timeout = ((event->timeout_usec - age_usec) / 1000) + 1000; @@ -517,11 +492,11 @@ static void spawn_read(struct udev_event *event, if (fdcount < 0) { if (errno == EINTR) continue; - err(udev, "failed to poll: %m\n"); + log_error("failed to poll: %m\n"); goto out; } if (fdcount == 0) { - err(udev, "timeout '%s'\n", cmd); + log_error("timeout '%s'\n", cmd); goto out; } @@ -543,7 +518,7 @@ static void spawn_read(struct udev_event *event, memcpy(&result[respos], buf, count); respos += count; } else { - err(udev, "'%s' ressize %zd too short\n", cmd, ressize); + log_error("'%s' ressize %zd too short\n", cmd, ressize); } } @@ -555,12 +530,12 @@ static void spawn_read(struct udev_event *event, pos = buf; while ((line = strsep(&pos, "\n"))) { if (pos != NULL || line[0] != '\0') - info(udev, "'%s'(%s) '%s'\n", cmd, *fd == fd_stdout ? "out" : "err" , line); + log_debug("'%s'(%s) '%s'\n", cmd, *fd == fd_stdout ? "out" : "err" , line); } } } else if (ev[i].events & EPOLLHUP) { if (epoll_ctl(fd_ep, EPOLL_CTL_DEL, *fd, NULL) < 0) { - err(udev, "failed to remove fd from epoll: %m\n"); + log_error("failed to remove fd from epoll: %m\n"); goto out; } *fd = -1; @@ -569,10 +544,8 @@ static void spawn_read(struct udev_event *event, } /* return the child's stdout string */ - if (result != NULL) { + if (result != NULL) result[respos] = '\0'; - dbg(udev, "result='%s'\n", result); - } out: if (fd_ep >= 0) close(fd_ep); @@ -608,11 +581,11 @@ static int spawn_wait(struct udev_event *event, const char *cmd, pid_t pid) if (errno == EINTR) continue; err = -errno; - err(udev, "failed to poll: %m\n"); + log_error("failed to poll: %m\n"); goto out; } if (fdcount == 0) { - err(udev, "timeout: killing '%s' [%u]\n", cmd, pid); + log_error("timeout: killing '%s' [%u]\n", cmd, pid); kill(pid, SIGKILL); } @@ -633,20 +606,20 @@ static int spawn_wait(struct udev_event *event, const char *cmd, pid_t pid) if (waitpid(pid, &status, WNOHANG) < 0) break; if (WIFEXITED(status)) { - info(udev, "'%s' [%u] exit with return code %i\n", cmd, pid, WEXITSTATUS(status)); + log_debug("'%s' [%u] exit with return code %i\n", cmd, pid, WEXITSTATUS(status)); if (WEXITSTATUS(status) != 0) err = -1; } else if (WIFSIGNALED(status)) { - err(udev, "'%s' [%u] terminated by signal %i (%s)\n", cmd, pid, WTERMSIG(status), strsignal(WTERMSIG(status))); + log_error("'%s' [%u] terminated by signal %i (%s)\n", cmd, pid, WTERMSIG(status), strsignal(WTERMSIG(status))); err = -1; } else if (WIFSTOPPED(status)) { - err(udev, "'%s' [%u] stopped\n", cmd, pid); + log_error("'%s' [%u] stopped\n", cmd, pid); err = -1; } else if (WIFCONTINUED(status)) { - err(udev, "'%s' [%u] continued\n", cmd, pid); + log_error("'%s' [%u] continued\n", cmd, pid); err = -1; } else { - err(udev, "'%s' [%u] exit with status 0x%04x\n", cmd, pid, status); + log_error("'%s' [%u] exit with status 0x%04x\n", cmd, pid, status); err = -1; } pid = 0; @@ -683,7 +656,6 @@ int udev_build_argv(struct udev *udev, char *cmd, int *argc, char *argv[]) while (pos[0] == ' ') pos++; } - dbg(udev, "argv[%i] '%s'\n", i, argv[i]); i++; } out: @@ -713,14 +685,14 @@ int udev_event_spawn(struct udev_event *event, if (result != NULL || udev_get_log_priority(udev) >= LOG_INFO) { if (pipe2(outpipe, O_NONBLOCK) != 0) { err = -errno; - err(udev, "pipe failed: %m\n"); + log_error("pipe failed: %m\n"); goto out; } } if (udev_get_log_priority(udev) >= LOG_INFO) { if (pipe2(errpipe, O_NONBLOCK) != 0) { err = -errno; - err(udev, "pipe failed: %m\n"); + log_error("pipe failed: %m\n"); goto out; } } @@ -744,14 +716,14 @@ int udev_event_spawn(struct udev_event *event, errpipe[READ_END] = -1; } - info(udev, "starting '%s'\n", cmd); + log_debug("starting '%s'\n", cmd); err = spawn_exec(event, cmd, argv, envp, sigmask, outpipe[WRITE_END], errpipe[WRITE_END]); _exit(2 ); case -1: - err(udev, "fork of '%s' failed: %m\n", cmd); + log_error("fork of '%s' failed: %m\n", cmd); err = -1; goto out; default: @@ -812,13 +784,13 @@ static int rename_netif(struct udev_event *event) int loop; int err; - info(event->udev, "changing net interface name from '%s' to '%s'\n", - udev_device_get_sysname(dev), event->name); + log_debug("changing net interface name from '%s' to '%s'\n", + udev_device_get_sysname(dev), event->name); sk = socket(PF_INET, SOCK_DGRAM, 0); if (sk < 0) { err = -errno; - err(event->udev, "error opening socket: %m\n"); + log_error("error opening socket: %m\n"); return err; } @@ -854,8 +826,6 @@ static int rename_netif(struct udev_event *event) while (loop--) { const struct timespec duration = { 0, 1000 * 1000 * 1000 / 20 }; - dbg(event->udev, "wait for netif '%s' to become free, loop=%i\n", - event->name, (90 * 20) - loop); nanosleep(&duration, NULL); err = ioctl(sk, SIOCSIFNAME, &ifr); @@ -870,7 +840,7 @@ static int rename_netif(struct udev_event *event) out: if (err < 0) - err(event->udev, "error changing net interface name %s to %s: %m\n", ifr.ifr_name, ifr.ifr_newname); + log_error("error changing net interface name %s to %s: %m\n", ifr.ifr_name, ifr.ifr_newname); close(sk); return err; } @@ -916,7 +886,7 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, err = rename_netif(event); if (err == 0) { - info(event->udev, "renamed netif to '%s'\n", event->name); + log_debug("renamed netif to '%s'\n", event->name); /* remember old name */ udev_device_add_property(dev, "INTERFACE_OLD", udev_device_get_sysname(dev)); @@ -929,7 +899,7 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, util_strscpy(pos, sizeof(syspath) - (pos - syspath), event->name); udev_device_set_syspath(event->dev, syspath); udev_device_add_property(dev, "INTERFACE", udev_device_get_sysname(dev)); - info(event->udev, "changed devpath to '%s'\n", udev_device_get_devpath(dev)); + log_debug("changed devpath to '%s'\n", udev_device_get_devpath(dev)); } } } @@ -978,7 +948,6 @@ int udev_event_execute_run(struct udev_event *event, const sigset_t *sigmask) struct udev_list_entry *list_entry; int err = 0; - dbg(event->udev, "executing run list\n"); udev_list_entry_foreach(list_entry, udev_list_get_entry(&event->run_list)) { const char *cmd = udev_list_entry_get_name(list_entry); @@ -995,7 +964,7 @@ int udev_event_execute_run(struct udev_event *event, const sigset_t *sigmask) char **envp; if (event->exec_delay > 0) { - info(event->udev, "delay execution of '%s'\n", program); + log_debug("delay execution of '%s'\n", program); sleep(event->exec_delay); } diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c index 7a01a479ee..95edd972f2 100644 --- a/src/udev/udev-node.c +++ b/src/udev/udev-node.c @@ -69,14 +69,14 @@ static int node_symlink(struct udev *udev, const char *node, const char *slink) if (S_ISBLK(stats.st_mode) || S_ISCHR(stats.st_mode)) { struct stat stats2; - info(udev, "found existing node instead of symlink '%s'\n", slink); + log_debug("found existing node instead of symlink '%s'\n", slink); if (lstat(node, &stats2) == 0) { if ((stats.st_mode & S_IFMT) == (stats2.st_mode & S_IFMT) && stats.st_rdev == stats2.st_rdev && stats.st_ino != stats2.st_ino) { - info(udev, "replace device node '%s' with symlink to our node '%s'\n", + log_debug("replace device node '%s' with symlink to our node '%s'\n", slink, node); } else { - err(udev, "device node '%s' already exists, " + log_error("device node '%s' already exists, " "link to '%s' will not overwrite it\n", slink, node); goto exit; @@ -86,13 +86,11 @@ static int node_symlink(struct udev *udev, const char *node, const char *slink) char buf[UTIL_PATH_SIZE]; int len; - dbg(udev, "found existing symlink '%s'\n", slink); len = readlink(slink, buf, sizeof(buf)); if (len > 0 && len < (int)sizeof(buf)) { buf[len] = '\0'; if (strcmp(target, buf) == 0) { - info(udev, "preserve already existing symlink '%s' to '%s'\n", - slink, target); + log_debug("preserve already existing symlink '%s' to '%s'\n", slink, target); udev_selinux_lsetfilecon(udev, slink, S_IFLNK); utimensat(AT_FDCWD, slink, NULL, AT_SYMLINK_NOFOLLOW); goto exit; @@ -100,7 +98,7 @@ static int node_symlink(struct udev *udev, const char *node, const char *slink) } } } else { - info(udev, "creating symlink '%s' to '%s'\n", slink, target); + log_debug("creating symlink '%s' to '%s'\n", slink, target); do { err = util_create_path_selinux(udev, slink); if (err != 0 && err != -ENOENT) @@ -115,7 +113,7 @@ static int node_symlink(struct udev *udev, const char *node, const char *slink) goto exit; } - info(udev, "atomically replace '%s'\n", slink); + log_debug("atomically replace '%s'\n", slink); util_strscpyl(slink_tmp, sizeof(slink_tmp), slink, TMP_FILE_EXT, NULL); unlink(slink_tmp); do { @@ -129,12 +127,12 @@ static int node_symlink(struct udev *udev, const char *node, const char *slink) udev_selinux_resetfscreatecon(udev); } while (err == -ENOENT); if (err != 0) { - err(udev, "symlink '%s' '%s' failed: %m\n", target, slink_tmp); + log_error("symlink '%s' '%s' failed: %m\n", target, slink_tmp); goto exit; } err = rename(slink_tmp, slink); if (err != 0) { - err(udev, "rename '%s' '%s' failed: %m\n", slink_tmp, slink); + log_error("rename '%s' '%s' failed: %m\n", slink_tmp, slink); unlink(slink_tmp); } exit: @@ -168,7 +166,7 @@ static const char *link_find_prioritized(struct udev_device *dev, bool add, cons if (dent->d_name[0] == '.') continue; - info(udev, "found '%s' claiming '%s'\n", dent->d_name, stackdir); + log_debug("found '%s' claiming '%s'\n", dent->d_name, stackdir); /* did we find ourself? */ if (strcmp(dent->d_name, udev_device_get_id_filename(dev)) == 0) @@ -180,11 +178,9 @@ static const char *link_find_prioritized(struct udev_device *dev, bool add, cons devnode = udev_device_get_devnode(dev_db); if (devnode != NULL) { - dbg(udev, "compare priority of '%s'(%i) > '%s'(%i)\n", target, priority, - udev_device_get_devnode(dev_db), udev_device_get_devlink_priority(dev_db)); if (target == NULL || udev_device_get_devlink_priority(dev_db) > priority) { - info(udev, "'%s' claims priority %i for '%s'\n", - udev_device_get_syspath(dev_db), udev_device_get_devlink_priority(dev_db), stackdir); + log_debug("'%s' claims priority %i for '%s'\n", + udev_device_get_syspath(dev_db), udev_device_get_devlink_priority(dev_db), stackdir); priority = udev_device_get_devlink_priority(dev_db); util_strscpy(buf, bufsize, devnode); target = buf; @@ -207,32 +203,26 @@ static void link_update(struct udev_device *dev, const char *slink, bool add) const char *target; char buf[UTIL_PATH_SIZE]; - dbg(udev, "update symlink '%s' of '%s'\n", slink, udev_device_get_syspath(dev)); - util_path_encode(&slink[strlen(udev_get_dev_path(udev))+1], name_enc, sizeof(name_enc)); util_strscpyl(dirname, sizeof(dirname), udev_get_run_path(udev), "/links/", name_enc, NULL); util_strscpyl(filename, sizeof(filename), dirname, "/", udev_device_get_id_filename(dev), NULL); - if (!add) { - dbg(udev, "removing index: '%s'\n", filename); - if (unlink(filename) == 0) - rmdir(dirname); - } + if (!add && unlink(filename) == 0) + rmdir(dirname); target = link_find_prioritized(dev, add, dirname, buf, sizeof(buf)); if (target == NULL) { - info(udev, "no reference left, remove '%s'\n", slink); + log_debug("no reference left, remove '%s'\n", slink); if (unlink(slink) == 0) util_delete_path(udev, slink); } else { - info(udev, "creating link '%s' to '%s'\n", slink, target); + log_debug("creating link '%s' to '%s'\n", slink, target); node_symlink(udev, target, slink); } if (add) { int err; - dbg(udev, "creating index: '%s'\n", filename); do { int fd; @@ -272,7 +262,7 @@ void udev_node_update_old_links(struct udev_device *dev, struct udev_device *dev if (found) continue; - info(udev, "update old name, '%s' no longer belonging to '%s'\n", + log_debug("update old name, '%s' no longer belonging to '%s'\n", name, udev_device_get_devpath(dev)); link_update(dev, name, 0); } @@ -293,23 +283,23 @@ static int node_fixup(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid if (lstat(devnode, &stats) != 0) { err = -errno; - info(udev, "can not stat() node '%s' (%m)\n", devnode); + log_debug("can not stat() node '%s' (%m)\n", devnode); goto out; } if (((stats.st_mode & S_IFMT) != (mode & S_IFMT)) || (stats.st_rdev != devnum)) { err = -EEXIST; - info(udev, "found node '%s' with non-matching devnum %s, skip handling\n", - udev_device_get_devnode(dev), udev_device_get_id_filename(dev)); + log_debug("found node '%s' with non-matching devnum %s, skip handling\n", + udev_device_get_devnode(dev), udev_device_get_id_filename(dev)); goto out; } if ((stats.st_mode & 0777) != (mode & 0777) || stats.st_uid != uid || stats.st_gid != gid) { - info(udev, "set permissions %s, %#o, uid=%u, gid=%u\n", devnode, mode, uid, gid); + log_debug("set permissions %s, %#o, uid=%u, gid=%u\n", devnode, mode, uid, gid); chmod(devnode, mode); chown(devnode, uid, gid); } else { - info(udev, "preserve permissions %s, %#o, uid=%u, gid=%u\n", devnode, mode, uid, gid); + log_debug("preserve permissions %s, %#o, uid=%u, gid=%u\n", devnode, mode, uid, gid); } /* @@ -334,8 +324,8 @@ void udev_node_add(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid) struct udev_list_entry *list_entry; int err = 0; - info(udev, "handling device node '%s', devnum=%s, mode=%#o, uid=%d, gid=%d\n", - udev_device_get_devnode(dev), udev_device_get_id_filename(dev), mode, uid, gid); + log_debug("handling device node '%s', devnum=%s, mode=%#o, uid=%d, gid=%d\n", + udev_device_get_devnode(dev), udev_device_get_id_filename(dev), mode, uid, gid); if (node_fixup(dev, mode, uid, gid) < 0) return; diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 8a85eae717..d9de4bb1ec 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -219,7 +219,7 @@ struct rule_tmp { unsigned int token_cur; }; -#ifdef ENABLE_DEBUG +#ifdef DEBUG static const char *operation_str(enum operation_type type) { static const char *operation_strs[] = { @@ -329,10 +329,10 @@ static void dump_token(struct udev_rules *rules, struct token *token) const char *tk_ptr = (char *)token; unsigned int idx = (tk_ptr - tks_ptr) / sizeof(struct token); - dbg(rules->udev, "* RULE %s:%u, token: %u, count: %u, label: '%s'\n", - &rules->buf[token->rule.filename_off], token->rule.filename_line, - idx, token->rule.token_count, - &rules->buf[token->rule.label_off]); + log_debug("* RULE %s:%u, token: %u, count: %u, label: '%s'\n", + &rules->buf[token->rule.filename_off], token->rule.filename_line, + idx, token->rule.token_count, + &rules->buf[token->rule.label_off]); break; } case TK_M_ACTION: @@ -360,65 +360,65 @@ static void dump_token(struct udev_rules *rules, struct token *token) case TK_A_GROUP: case TK_A_MODE: case TK_A_RUN: - dbg(rules->udev, "%s %s '%s'(%s)\n", - token_str(type), operation_str(op), value, string_glob_str(glob)); + log_debug("%s %s '%s'(%s)\n", + token_str(type), operation_str(op), value, string_glob_str(glob)); break; case TK_M_IMPORT_BUILTIN: - dbg(rules->udev, "%s %i '%s'\n", token_str(type), token->key.builtin_cmd, value); + log_debug("%s %i '%s'\n", token_str(type), token->key.builtin_cmd, value); break; case TK_M_ATTR: case TK_M_ATTRS: case TK_M_ENV: case TK_A_ATTR: case TK_A_ENV: - dbg(rules->udev, "%s %s '%s' '%s'(%s)\n", - token_str(type), operation_str(op), attr, value, string_glob_str(glob)); + log_debug("%s %s '%s' '%s'(%s)\n", + token_str(type), operation_str(op), attr, value, string_glob_str(glob)); break; case TK_M_TAG: case TK_A_TAG: - dbg(rules->udev, "%s %s '%s'\n", token_str(type), operation_str(op), value); + log_debug("%s %s '%s'\n", token_str(type), operation_str(op), value); break; case TK_A_STRING_ESCAPE_NONE: case TK_A_STRING_ESCAPE_REPLACE: case TK_A_DB_PERSIST: - dbg(rules->udev, "%s\n", token_str(type)); + log_debug("%s\n", token_str(type)); break; case TK_M_TEST: - dbg(rules->udev, "%s %s '%s'(%s) %#o\n", - token_str(type), operation_str(op), value, string_glob_str(glob), token->key.mode); + log_debug("%s %s '%s'(%s) %#o\n", + token_str(type), operation_str(op), value, string_glob_str(glob), token->key.mode); break; case TK_A_INOTIFY_WATCH: - dbg(rules->udev, "%s %u\n", token_str(type), token->key.watch); + log_debug("%s %u\n", token_str(type), token->key.watch); break; case TK_A_DEVLINK_PRIO: - dbg(rules->udev, "%s %u\n", token_str(type), token->key.devlink_prio); + log_debug("%s %u\n", token_str(type), token->key.devlink_prio); break; case TK_A_OWNER_ID: - dbg(rules->udev, "%s %s %u\n", token_str(type), operation_str(op), token->key.uid); + log_debug("%s %s %u\n", token_str(type), operation_str(op), token->key.uid); break; case TK_A_GROUP_ID: - dbg(rules->udev, "%s %s %u\n", token_str(type), operation_str(op), token->key.gid); + log_debug("%s %s %u\n", token_str(type), operation_str(op), token->key.gid); break; case TK_A_MODE_ID: - dbg(rules->udev, "%s %s %#o\n", token_str(type), operation_str(op), token->key.mode); + log_debug("%s %s %#o\n", token_str(type), operation_str(op), token->key.mode); break; case TK_A_STATIC_NODE: - dbg(rules->udev, "%s '%s'\n", token_str(type), value); + log_debug("%s '%s'\n", token_str(type), value); break; case TK_M_EVENT_TIMEOUT: - dbg(rules->udev, "%s %u\n", token_str(type), token->key.event_timeout); + log_debug("%s %u\n", token_str(type), token->key.event_timeout); break; case TK_A_GOTO: - dbg(rules->udev, "%s '%s' %u\n", token_str(type), value, token->key.rule_goto); + log_debug("%s '%s' %u\n", token_str(type), value, token->key.rule_goto); break; case TK_END: - dbg(rules->udev, "* %s\n", token_str(type)); + log_debug("* %s\n", token_str(type)); break; case TK_M_PARENTS_MIN: case TK_M_PARENTS_MAX: case TK_M_MAX: case TK_UNSET: - dbg(rules->udev, "unknown type %u\n", type); + log_debug("unknown type %u\n", type); break; } } @@ -427,11 +427,11 @@ static void dump_rules(struct udev_rules *rules) { unsigned int i; - dbg(rules->udev, "dumping %u (%zu bytes) tokens, %u (%zu bytes) strings\n", - rules->token_cur, - rules->token_cur * sizeof(struct token), - rules->buf_count, - rules->buf_cur); + log_debug("dumping %u (%zu bytes) tokens, %u (%zu bytes) strings\n", + rules->token_cur, + rules->token_cur * sizeof(struct token), + rules->buf_count, + rules->buf_cur); for(i = 0; i < rules->token_cur; i++) dump_token(rules, &rules->tokens[i]); } @@ -440,7 +440,7 @@ static inline const char *operation_str(enum operation_type type) { return NULL; static inline const char *token_str(enum token_type type) { return NULL; } static inline void dump_token(struct udev_rules *rules, struct token *token) {} static inline void dump_rules(struct udev_rules *rules) {} -#endif /* ENABLE_DEBUG */ +#endif /* DEBUG */ static int add_new_string(struct udev_rules *rules, const char *str, size_t bytes) { @@ -459,7 +459,6 @@ static int add_new_string(struct udev_rules *rules, const char *str, size_t byte buf = realloc(rules->buf, rules->buf_max + add); if (buf == NULL) return -1; - dbg(rules->udev, "extend buffer from %zu to %zu\n", rules->buf_max, rules->buf_max + add); rules->buf = buf; rules->buf_max += add; } @@ -528,8 +527,6 @@ static int add_string(struct udev_rules *rules, const char *str) nodes = realloc(rules->trie_nodes, (rules->trie_nodes_max + add) * sizeof(struct trie_node)); if (nodes == NULL) return -1; - dbg(rules->udev, "extend trie nodes from %u to %u\n", - rules->trie_nodes_max, rules->trie_nodes_max + add); rules->trie_nodes = nodes; rules->trie_nodes_max += add; } @@ -572,7 +569,6 @@ static int add_token(struct udev_rules *rules, struct token *token) tokens = realloc(rules->tokens, (rules->token_max + add ) * sizeof(struct token)); if (tokens == NULL) return -1; - dbg(rules->udev, "extend tokens from %u to %u\n", rules->token_max, rules->token_max + add); rules->tokens = tokens; rules->token_max += add; } @@ -592,7 +588,6 @@ static uid_t add_uid(struct udev_rules *rules, const char *owner) off = rules->uids[i].name_off; if (strcmp(&rules->buf[off], owner) == 0) { uid = rules->uids[i].uid; - dbg(rules->udev, "return existing %u for '%s'\n", uid, owner); return uid; } } @@ -611,7 +606,6 @@ static uid_t add_uid(struct udev_rules *rules, const char *owner) uids = realloc(rules->uids, (rules->uids_max + add ) * sizeof(struct uid_gid)); if (uids == NULL) return uid; - dbg(rules->udev, "extend uids from %u to %u\n", rules->uids_max, rules->uids_max + add); rules->uids = uids; rules->uids_max += add; } @@ -635,7 +629,6 @@ static gid_t add_gid(struct udev_rules *rules, const char *group) off = rules->gids[i].name_off; if (strcmp(&rules->buf[off], group) == 0) { gid = rules->gids[i].gid; - dbg(rules->udev, "return existing %u for '%s'\n", gid, group); return gid; } } @@ -654,7 +647,6 @@ static gid_t add_gid(struct udev_rules *rules, const char *group) gids = realloc(rules->gids, (rules->gids_max + add ) * sizeof(struct uid_gid)); if (gids == NULL) return gid; - dbg(rules->udev, "extend gids from %u to %u\n", rules->gids_max, rules->gids_max + add); rules->gids = gids; rules->gids_max += add; } @@ -716,21 +708,19 @@ static int import_property_from_string(struct udev_device *dev, char *line) /* unquote */ if (val[0] == '"' || val[0] == '\'') { if (val[len-1] != val[0]) { - info(udev, "inconsistent quoting: '%s', skip\n", line); + log_debug("inconsistent quoting: '%s', skip\n", line); return -1; } val[len-1] = '\0'; val++; } - dbg(udev, "adding '%s'='%s'\n", key, val); - /* handle device, renamed by external tool, returning new path */ if (strcmp(key, "DEVPATH") == 0) { char syspath[UTIL_PATH_SIZE]; - info(udev, "updating devpath from '%s' to '%s'\n", - udev_device_get_devpath(dev), val); + log_debug("updating devpath from '%s' to '%s'\n", + udev_device_get_devpath(dev), val); util_strscpyl(syspath, sizeof(syspath), udev_get_sys_path(udev), val, NULL); udev_device_set_syspath(dev, syspath); } else { @@ -796,7 +786,6 @@ static int import_parent_into_properties(struct udev_device *dev, const char *fi if (dev_parent == NULL) return -1; - dbg(udev, "found parent '%s', get the node name\n", udev_device_get_syspath(dev_parent)); udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(dev_parent)) { const char *key = udev_list_entry_get_name(list_entry); const char *val = udev_list_entry_get_value(list_entry); @@ -804,7 +793,6 @@ static int import_parent_into_properties(struct udev_device *dev, const char *fi if (fnmatch(filter, key, 0) == 0) { struct udev_list_entry *entry; - dbg(udev, "import key '%s=%s'\n", key, val); entry = udev_device_add_property(dev, key, val); /* store in db, skip private keys */ if (key[0] != '.') @@ -832,24 +820,23 @@ static int wait_for_file(struct udev_device *dev, const char *file, int timeout) file = filepath; } - dbg(udev, "will wait %i sec for '%s'\n", timeout, file); while (--loop) { const struct timespec duration = { 0, 1000 * 1000 * 1000 / WAIT_LOOP_PER_SECOND }; /* lookup file */ if (stat(file, &stats) == 0) { - info(udev, "file '%s' appeared after %i loops\n", file, (timeout * WAIT_LOOP_PER_SECOND) - loop-1); + log_debug("file '%s' appeared after %i loops\n", file, (timeout * WAIT_LOOP_PER_SECOND) - loop-1); return 0; } /* make sure, the device did not disappear in the meantime */ if (devicepath[0] != '\0' && stat(devicepath, &stats) != 0) { - info(udev, "device disappeared while waiting for '%s'\n", file); + log_debug("device disappeared while waiting for '%s'\n", file); return -2; } - info(udev, "wait for '%s' for %i mseconds\n", file, 1000 / WAIT_LOOP_PER_SECOND); + log_debug("wait for '%s' for %i mseconds\n", file, 1000 / WAIT_LOOP_PER_SECOND); nanosleep(&duration, NULL); } - info(udev, "waiting for '%s' failed\n", file); + log_debug("waiting for '%s' failed\n", file); return -1; } @@ -972,7 +959,6 @@ static int get_key(struct udev *udev, char **line, char **key, enum operation_ty return -1; temp[0] = '\0'; temp++; - dbg(udev, "%s '%s'-'%s'\n", operation_str(*op), *key, *value); /* move line to next key */ *line = temp; @@ -990,11 +976,10 @@ static char *get_key_attribute(struct udev *udev, char *str) attr++; pos = strchr(attr, '}'); if (pos == NULL) { - err(udev, "missing closing brace for format\n"); + log_error("missing closing brace for format\n"); return NULL; } pos[0] = '\0'; - dbg(udev, "attribute='%s'\n", attr); return attr; } return NULL; @@ -1092,7 +1077,7 @@ static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type, case TK_M_MAX: case TK_END: case TK_UNSET: - err(rule_tmp->rules->udev, "wrong type %u\n", type); + log_error("wrong type %u\n", type); return -1; } @@ -1143,7 +1128,7 @@ static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type, token->key.op = op; rule_tmp->token_cur++; if (rule_tmp->token_cur >= ARRAY_SIZE(rule_tmp->token)) { - err(rule_tmp->rules->udev, "temporary rule array too small\n"); + log_error("temporary rule array too small\n"); return -1; } return 0; @@ -1208,7 +1193,7 @@ static int add_rule(struct udev_rules *rules, char *line, if (strcmp(key, "ACTION") == 0) { if (op > OP_MATCH_MAX) { - err(rules->udev, "invalid ACTION operation\n"); + log_error("invalid ACTION operation\n"); goto invalid; } rule_add_key(&rule_tmp, TK_M_ACTION, op, value, NULL); @@ -1217,7 +1202,7 @@ static int add_rule(struct udev_rules *rules, char *line, if (strcmp(key, "DEVPATH") == 0) { if (op > OP_MATCH_MAX) { - err(rules->udev, "invalid DEVPATH operation\n"); + log_error("invalid DEVPATH operation\n"); goto invalid; } rule_add_key(&rule_tmp, TK_M_DEVPATH, op, value, NULL); @@ -1226,7 +1211,7 @@ static int add_rule(struct udev_rules *rules, char *line, if (strcmp(key, "KERNEL") == 0) { if (op > OP_MATCH_MAX) { - err(rules->udev, "invalid KERNEL operation\n"); + log_error("invalid KERNEL operation\n"); goto invalid; } rule_add_key(&rule_tmp, TK_M_KERNEL, op, value, NULL); @@ -1235,7 +1220,7 @@ static int add_rule(struct udev_rules *rules, char *line, if (strcmp(key, "SUBSYSTEM") == 0) { if (op > OP_MATCH_MAX) { - err(rules->udev, "invalid SUBSYSTEM operation\n"); + log_error("invalid SUBSYSTEM operation\n"); goto invalid; } /* bus, class, subsystem events should all be the same */ @@ -1243,7 +1228,7 @@ static int add_rule(struct udev_rules *rules, char *line, strcmp(value, "bus") == 0 || strcmp(value, "class") == 0) { if (strcmp(value, "bus") == 0 || strcmp(value, "class") == 0) - err(rules->udev, "'%s' must be specified as 'subsystem' \n" + log_error("'%s' must be specified as 'subsystem' \n" "please fix it in %s:%u", value, filename, lineno); rule_add_key(&rule_tmp, TK_M_SUBSYSTEM, op, "subsystem|class|bus", NULL); } else @@ -1253,7 +1238,7 @@ static int add_rule(struct udev_rules *rules, char *line, if (strcmp(key, "DRIVER") == 0) { if (op > OP_MATCH_MAX) { - err(rules->udev, "invalid DRIVER operation\n"); + log_error("invalid DRIVER operation\n"); goto invalid; } rule_add_key(&rule_tmp, TK_M_DRIVER, op, value, NULL); @@ -1263,7 +1248,7 @@ static int add_rule(struct udev_rules *rules, char *line, if (strncmp(key, "ATTR{", sizeof("ATTR{")-1) == 0) { attr = get_key_attribute(rules->udev, key + sizeof("ATTR")-1); if (attr == NULL) { - err(rules->udev, "error parsing ATTR attribute\n"); + log_error("error parsing ATTR attribute\n"); goto invalid; } if (op < OP_MATCH_MAX) { @@ -1276,7 +1261,7 @@ static int add_rule(struct udev_rules *rules, char *line, if (strcmp(key, "KERNELS") == 0) { if (op > OP_MATCH_MAX) { - err(rules->udev, "invalid KERNELS operation\n"); + log_error("invalid KERNELS operation\n"); goto invalid; } rule_add_key(&rule_tmp, TK_M_KERNELS, op, value, NULL); @@ -1285,7 +1270,7 @@ static int add_rule(struct udev_rules *rules, char *line, if (strcmp(key, "SUBSYSTEMS") == 0) { if (op > OP_MATCH_MAX) { - err(rules->udev, "invalid SUBSYSTEMS operation\n"); + log_error("invalid SUBSYSTEMS operation\n"); goto invalid; } rule_add_key(&rule_tmp, TK_M_SUBSYSTEMS, op, value, NULL); @@ -1294,7 +1279,7 @@ static int add_rule(struct udev_rules *rules, char *line, if (strcmp(key, "DRIVERS") == 0) { if (op > OP_MATCH_MAX) { - err(rules->udev, "invalid DRIVERS operation\n"); + log_error("invalid DRIVERS operation\n"); goto invalid; } rule_add_key(&rule_tmp, TK_M_DRIVERS, op, value, NULL); @@ -1303,19 +1288,19 @@ static int add_rule(struct udev_rules *rules, char *line, if (strncmp(key, "ATTRS{", sizeof("ATTRS{")-1) == 0) { if (op > OP_MATCH_MAX) { - err(rules->udev, "invalid ATTRS operation\n"); + log_error("invalid ATTRS operation\n"); goto invalid; } attr = get_key_attribute(rules->udev, key + sizeof("ATTRS")-1); if (attr == NULL) { - err(rules->udev, "error parsing ATTRS attribute\n"); + log_error("error parsing ATTRS attribute\n"); goto invalid; } if (strncmp(attr, "device/", 7) == 0) - err(rules->udev, "the 'device' link may not be available in a future kernel, " + log_error("the 'device' link may not be available in a future kernel, " "please fix it in %s:%u", filename, lineno); else if (strstr(attr, "../") != NULL) - err(rules->udev, "do not reference parent sysfs directories directly, " + log_error("do not reference parent sysfs directories directly, " "it may break with a future kernel, please fix it in %s:%u", filename, lineno); rule_add_key(&rule_tmp, TK_M_ATTRS, op, value, attr); continue; @@ -1323,7 +1308,7 @@ static int add_rule(struct udev_rules *rules, char *line, if (strcmp(key, "TAGS") == 0) { if (op > OP_MATCH_MAX) { - err(rules->udev, "invalid TAGS operation\n"); + log_error("invalid TAGS operation\n"); goto invalid; } rule_add_key(&rule_tmp, TK_M_TAGS, op, value, NULL); @@ -1333,7 +1318,7 @@ static int add_rule(struct udev_rules *rules, char *line, if (strncmp(key, "ENV{", sizeof("ENV{")-1) == 0) { attr = get_key_attribute(rules->udev, key + sizeof("ENV")-1); if (attr == NULL) { - err(rules->udev, "error parsing ENV attribute\n"); + log_error("error parsing ENV attribute\n"); goto invalid; } if (op < OP_MATCH_MAX) { @@ -1357,7 +1342,7 @@ static int add_rule(struct udev_rules *rules, char *line, for (i = 0; i < ARRAY_SIZE(blacklist); i++) if (strcmp(attr, blacklist[i]) == 0) { - err(rules->udev, "invalid ENV attribute, '%s' can not be set %s:%u\n", attr, filename, lineno); + log_error("invalid ENV attribute, '%s' can not be set %s:%u\n", attr, filename, lineno); continue; } if (rule_add_key(&rule_tmp, TK_A_ENV, op, value, attr) != 0) @@ -1381,7 +1366,7 @@ static int add_rule(struct udev_rules *rules, char *line, if (strcmp(key, "RESULT") == 0) { if (op > OP_MATCH_MAX) { - err(rules->udev, "invalid RESULT operation\n"); + log_error("invalid RESULT operation\n"); goto invalid; } rule_add_key(&rule_tmp, TK_M_RESULT, op, value, NULL); @@ -1391,7 +1376,7 @@ static int add_rule(struct udev_rules *rules, char *line, if (strncmp(key, "IMPORT", sizeof("IMPORT")-1) == 0) { attr = get_key_attribute(rules->udev, key + sizeof("IMPORT")-1); if (attr == NULL) { - err(rules->udev, "IMPORT{} type missing, ignoring IMPORT %s:%u\n", filename, lineno); + log_error("IMPORT{} type missing, ignoring IMPORT %s:%u\n", filename, lineno); continue; } if (strstr(attr, "program")) { @@ -1401,33 +1386,27 @@ static int add_rule(struct udev_rules *rules, char *line, cmd = udev_builtin_lookup(value); if (cmd < UDEV_BUILTIN_MAX) { - info(rules->udev, "IMPORT found builtin '%s', replacing %s:%u\n", - value, filename, lineno); + log_debug("IMPORT found builtin '%s', replacing %s:%u\n", + value, filename, lineno); rule_add_key(&rule_tmp, TK_M_IMPORT_BUILTIN, op, value, &cmd); continue; } } - dbg(rules->udev, "IMPORT will be executed\n"); rule_add_key(&rule_tmp, TK_M_IMPORT_PROG, op, value, NULL); } else if (strstr(attr, "builtin")) { enum udev_builtin_cmd cmd = udev_builtin_lookup(value); - dbg(rules->udev, "IMPORT execute builtin\n"); if (cmd < UDEV_BUILTIN_MAX) rule_add_key(&rule_tmp, TK_M_IMPORT_BUILTIN, op, value, &cmd); else - err(rules->udev, "IMPORT{builtin}: '%s' unknown %s:%u\n", value, filename, lineno); + log_error("IMPORT{builtin}: '%s' unknown %s:%u\n", value, filename, lineno); } else if (strstr(attr, "file")) { - dbg(rules->udev, "IMPORT will be included as file\n"); rule_add_key(&rule_tmp, TK_M_IMPORT_FILE, op, value, NULL); } else if (strstr(attr, "db")) { - dbg(rules->udev, "IMPORT will include db values\n"); rule_add_key(&rule_tmp, TK_M_IMPORT_DB, op, value, NULL); } else if (strstr(attr, "cmdline")) { - dbg(rules->udev, "IMPORT will include db values\n"); rule_add_key(&rule_tmp, TK_M_IMPORT_CMDLINE, op, value, NULL); } else if (strstr(attr, "parent")) { - dbg(rules->udev, "IMPORT will include the parent values\n"); rule_add_key(&rule_tmp, TK_M_IMPORT_PARENT, op, value, NULL); } continue; @@ -1437,7 +1416,7 @@ static int add_rule(struct udev_rules *rules, char *line, mode_t mode = 0; if (op > OP_MATCH_MAX) { - err(rules->udev, "invalid TEST operation\n"); + log_error("invalid TEST operation\n"); goto invalid; } attr = get_key_attribute(rules->udev, key + sizeof("TEST")-1); @@ -1452,7 +1431,7 @@ static int add_rule(struct udev_rules *rules, char *line, if (strcmp(key, "RUN") == 0) { if (strncmp(value, "socket:", 7) == 0) - err(rules->udev, "RUN+=\"socket:...\" support will be removed from a future udev release. " + log_error("RUN+=\"socket:...\" support will be removed from a future udev release. " "Please remove it from: %s:%u and use libudev to subscribe to events.\n", filename, lineno); rule_add_key(&rule_tmp, TK_A_RUN, op, value, NULL); continue; @@ -1478,13 +1457,13 @@ static int add_rule(struct udev_rules *rules, char *line, rule_add_key(&rule_tmp, TK_M_NAME, op, value, NULL); } else { if (strcmp(value, "%k") == 0) { - err(rules->udev, "NAME=\"%%k\" is ignored, because it breaks kernel supplied names, " + log_error("NAME=\"%%k\" is ignored, because it breaks kernel supplied names, " "please remove it from %s:%u\n", filename, lineno); continue; } if (value[0] == '\0') { - info(rules->udev, "NAME=\"\" is ignored, because udev will not delete any device nodes, " - "please remove it from %s:%u\n", filename, lineno); + log_debug("NAME=\"\" is ignored, because udev will not delete any device nodes, " + "please remove it from %s:%u\n", filename, lineno); continue; } rule_add_key(&rule_tmp, TK_A_NAME, op, value, NULL); @@ -1563,7 +1542,6 @@ static int add_rule(struct udev_rules *rules, char *line, int prio = atoi(&pos[strlen("link_priority=")]); rule_add_key(&rule_tmp, TK_A_DEVLINK_PRIO, op, NULL, &prio); - dbg(rules->udev, "link priority=%i\n", prio); } pos = strstr(value, "event_timeout="); @@ -1571,7 +1549,6 @@ static int add_rule(struct udev_rules *rules, char *line, int tout = atoi(&pos[strlen("event_timeout=")]); rule_add_key(&rule_tmp, TK_M_EVENT_TIMEOUT, op, NULL, &tout); - dbg(rules->udev, "event timeout=%i\n", tout); } pos = strstr(value, "string_escape="); @@ -1592,14 +1569,12 @@ static int add_rule(struct udev_rules *rules, char *line, const int off = 0; rule_add_key(&rule_tmp, TK_A_INOTIFY_WATCH, op, NULL, &off); - dbg(rules->udev, "inotify watch of device disabled\n"); } else { pos = strstr(value, "watch"); if (pos != NULL) { const int on = 1; rule_add_key(&rule_tmp, TK_A_INOTIFY_WATCH, op, NULL, &on); - dbg(rules->udev, "inotify watch of device requested\n"); } } @@ -1612,7 +1587,7 @@ static int add_rule(struct udev_rules *rules, char *line, continue; } - err(rules->udev, "unknown key '%s' in %s:%u\n", key, filename, lineno); + log_error("unknown key '%s' in %s:%u\n", key, filename, lineno); goto invalid; } @@ -1627,7 +1602,7 @@ static int add_rule(struct udev_rules *rules, char *line, return 0; invalid: - err(rules->udev, "invalid rule '%s:%u'\n", filename, lineno); + log_error("invalid rule '%s:%u'\n", filename, lineno); return -1; } @@ -1639,7 +1614,7 @@ static int parse_file(struct udev_rules *rules, const char *filename, unsigned s int line_nr = 0; unsigned int i; - info(rules->udev, "reading '%s' as rules file\n", filename); + log_debug("reading '%s' as rules file\n", filename); f = fopen(filename, "r"); if (f == NULL) @@ -1676,7 +1651,7 @@ static int parse_file(struct udev_rules *rules, const char *filename, unsigned s } if (len+1 >= sizeof(line)) { - err(rules->udev, "line too long '%s':%u, ignored\n", filename, line_nr); + log_error("line too long '%s':%u, ignored\n", filename, line_nr); continue; } add_rule(rules, key, filename, filename_off, line_nr); @@ -1700,7 +1675,7 @@ static int parse_file(struct udev_rules *rules, const char *filename, unsigned s break; } if (rules->tokens[i].key.rule_goto == 0) - err(rules->udev, "GOTO '%s' has no matching label in: '%s'\n", label, filename); + log_error("GOTO '%s' has no matching label in: '%s'\n", label, filename); } } return 0; @@ -1712,10 +1687,9 @@ static int add_matching_files(struct udev *udev, struct udev_list *file_list, co struct dirent *dent; char filename[UTIL_PATH_SIZE]; - dbg(udev, "open directory '%s'\n", dirname); dir = opendir(dirname); if (dir == NULL) { - info(udev, "unable to open '%s': %m\n", dirname); + log_debug("unable to open '%s': %m\n", dirname); return -1; } @@ -1734,7 +1708,6 @@ static int add_matching_files(struct udev *udev, struct udev_list *file_list, co continue; } util_strscpyl(filename, sizeof(filename), dirname, "/", dent->d_name, NULL); - dbg(udev, "put file '%s' into list\n", filename); /* * the basename is the key, the filename the value * identical basenames from different directories override each other @@ -1780,8 +1753,6 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) /* offset 0 is always '\0' */ rules->buf[0] = '\0'; rules->buf_cur = 1; - dbg(udev, "prealloc %zu bytes tokens (%u * %zu bytes), %zu bytes buffer\n", - rules->token_max * sizeof(struct token), rules->token_max, sizeof(struct token), rules->buf_max); rules->trie_nodes = malloc(PREALLOC_TRIE * sizeof(struct trie_node)); if (rules->trie_nodes == NULL) { @@ -1816,15 +1787,15 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) struct stat st; if (stat(filename, &st) != 0) { - err(udev, "can not find '%s': %m\n", filename); + log_error("can not find '%s': %m\n", filename); continue; } if (S_ISREG(st.st_mode) && st.st_size <= 0) { - info(udev, "ignore empty '%s'\n", filename); + log_debug("ignore empty '%s'\n", filename); continue; } if (S_ISCHR(st.st_mode)) { - info(udev, "ignore masked '%s'\n", filename); + log_debug("ignore masked '%s'\n", filename); continue; } parse_file(rules, filename, filename_off); @@ -1854,11 +1825,11 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) rules->buf_max = rules->buf_cur; } } - info(udev, "rules use %zu bytes tokens (%u * %zu bytes), %zu bytes buffer\n", - rules->token_max * sizeof(struct token), rules->token_max, sizeof(struct token), rules->buf_max); - info(udev, "temporary index used %zu bytes (%u * %zu bytes)\n", - rules->trie_nodes_cur * sizeof(struct trie_node), - rules->trie_nodes_cur, sizeof(struct trie_node)); + log_debug("rules use %zu bytes tokens (%u * %zu bytes), %zu bytes buffer\n", + rules->token_max * sizeof(struct token), rules->token_max, sizeof(struct token), rules->buf_max); + log_debug("temporary index used %zu bytes (%u * %zu bytes)\n", + rules->trie_nodes_cur * sizeof(struct trie_node), + rules->trie_nodes_cur, sizeof(struct trie_node)); /* cleanup trie */ free(rules->trie_nodes); @@ -1946,7 +1917,6 @@ static int match_key(struct udev_rules *rules, struct token *token, const char * pos[0] = '\0'; pos = &pos[1]; } - dbg(rules->udev, "match %s '%s' <-> '%s'\n", token_str(token->type), key_value, val); match = (fnmatch(key_value, val, 0) == 0); if (match) break; @@ -1961,15 +1931,10 @@ static int match_key(struct udev_rules *rules, struct token *token, const char * return -1; } - if (match && (token->key.op == OP_MATCH)) { - dbg(rules->udev, "%s is true (matching value)\n", token_str(token->type)); + if (match && (token->key.op == OP_MATCH)) return 0; - } - if (!match && (token->key.op == OP_NOMATCH)) { - dbg(rules->udev, "%s is true (non-matching value)\n", token_str(token->type)); + if (!match && (token->key.op == OP_NOMATCH)) return 0; - } - dbg(rules->udev, "%s is not true\n", token_str(token->type)); return -1; } @@ -2016,7 +1981,6 @@ static int match_attr(struct udev_rules *rules, struct udev_device *dev, struct } while (len > 0 && isspace(vbuf[--len])) vbuf[len] = '\0'; - dbg(rules->udev, "removed trailing whitespace from '%s'\n", value); } } @@ -2096,10 +2060,8 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event const char *value; value = udev_device_get_property_value(event->dev, key_name); - if (value == NULL) { - dbg(event->udev, "ENV{%s} is not set, treat as empty\n", key_name); + if (value == NULL) value = ""; - } if (match_key(rules, cur, value)) goto nomatch; break; @@ -2157,7 +2119,6 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event for (;;) { struct token *key; - dbg(event->udev, "parent: '%s'\n", udev_device_get_syspath(event->dev_parent)); /* loop over sequence of parent match keys */ for (key = cur; key < next; key++ ) { dump_token(rules, key); @@ -2190,9 +2151,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event default: goto nomatch; } - dbg(event->udev, "parent key matched\n"); } - dbg(event->udev, "all parent keys matched\n"); break; try_parent: @@ -2222,12 +2181,8 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event attr_subst_subdir(filename, sizeof(filename)); match = (stat(filename, &statbuf) == 0); - dbg(event->udev, "'%s' %s", filename, match ? "exists\n" : "does not exist\n"); - if (match && cur->key.mode > 0) { + if (match && cur->key.mode > 0) match = ((statbuf.st_mode & cur->key.mode) > 0); - dbg(event->udev, "'%s' has mode=%#o and %s %#o\n", filename, statbuf.st_mode, - match ? "matches" : "does not match", cur->key.mode); - } if (match && cur->key.op == OP_NOMATCH) goto nomatch; if (!match && cur->key.op == OP_MATCH) @@ -2235,7 +2190,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event break; } case TK_M_EVENT_TIMEOUT: - info(event->udev, "OPTIONS event_timeout=%u\n", cur->key.event_timeout); + log_debug("OPTIONS event_timeout=%u\n", cur->key.event_timeout); event->timeout_usec = cur->key.event_timeout * 1000 * 1000; break; case TK_M_PROGRAM: { @@ -2247,10 +2202,10 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event event->program_result = NULL; udev_event_apply_format(event, &rules->buf[cur->key.value_off], program, sizeof(program)); envp = udev_device_get_properties_envp(event->dev); - info(event->udev, "PROGRAM '%s' %s:%u\n", - program, - &rules->buf[rule->rule.filename_off], - rule->rule.filename_line); + log_debug("PROGRAM '%s' %s:%u\n", + program, + &rules->buf[rule->rule.filename_off], + rule->rule.filename_line); if (udev_event_spawn(event, program, envp, sigmask, result, sizeof(result)) < 0) { if (cur->key.op != OP_NOMATCH) @@ -2262,10 +2217,9 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event if (esc == ESCAPE_UNSET || esc == ESCAPE_REPLACE) { count = util_replace_chars(result, UDEV_ALLOWED_CHARS_INPUT); if (count > 0) - info(event->udev, "%i character(s) replaced\n" , count); + log_debug("%i character(s) replaced\n" , count); } event->program_result = strdup(result); - dbg(event->udev, "storing result '%s'\n", event->program_result); if (cur->key.op == OP_NOMATCH) goto nomatch; } @@ -2284,10 +2238,10 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event char import[UTIL_PATH_SIZE]; udev_event_apply_format(event, &rules->buf[cur->key.value_off], import, sizeof(import)); - info(event->udev, "IMPORT '%s' %s:%u\n", - import, - &rules->buf[rule->rule.filename_off], - rule->rule.filename_line); + log_debug("IMPORT '%s' %s:%u\n", + import, + &rules->buf[rule->rule.filename_off], + rule->rule.filename_line); if (import_program_into_properties(event, import, sigmask) != 0) if (cur->key.op != OP_NOMATCH) @@ -2300,10 +2254,10 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event if (udev_builtin_run_once(cur->key.builtin_cmd)) { /* check if we ran already */ if (event->builtin_run & (1 << cur->key.builtin_cmd)) { - info(event->udev, "IMPORT builtin skip '%s' %s:%u\n", - udev_builtin_name(cur->key.builtin_cmd), - &rules->buf[rule->rule.filename_off], - rule->rule.filename_line); + log_debug("IMPORT builtin skip '%s' %s:%u\n", + udev_builtin_name(cur->key.builtin_cmd), + &rules->buf[rule->rule.filename_off], + rule->rule.filename_line); /* return the result from earlier run */ if (event->builtin_ret & (1 << cur->key.builtin_cmd)) if (cur->key.op != OP_NOMATCH) @@ -2315,15 +2269,15 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event } udev_event_apply_format(event, &rules->buf[cur->key.value_off], command, sizeof(command)); - info(event->udev, "IMPORT builtin '%s' %s:%u\n", - udev_builtin_name(cur->key.builtin_cmd), - &rules->buf[rule->rule.filename_off], - rule->rule.filename_line); + log_debug("IMPORT builtin '%s' %s:%u\n", + udev_builtin_name(cur->key.builtin_cmd), + &rules->buf[rule->rule.filename_off], + rule->rule.filename_line); if (udev_builtin_run(event->dev, cur->key.builtin_cmd, command, false) != 0) { /* remember failure */ - info(rules->udev, "IMPORT builtin '%s' returned non-zero\n", - udev_builtin_name(cur->key.builtin_cmd)); + log_debug("IMPORT builtin '%s' returned non-zero\n", + udev_builtin_name(cur->key.builtin_cmd)); event->builtin_ret |= (1 << cur->key.builtin_cmd); if (cur->key.op != OP_NOMATCH) goto nomatch; @@ -2429,10 +2383,10 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event event->owner_final = true; udev_event_apply_format(event, &rules->buf[cur->key.value_off], owner, sizeof(owner)); event->uid = util_lookup_user(event->udev, owner); - info(event->udev, "OWNER %u %s:%u\n", - event->uid, - &rules->buf[rule->rule.filename_off], - rule->rule.filename_line); + log_debug("OWNER %u %s:%u\n", + event->uid, + &rules->buf[rule->rule.filename_off], + rule->rule.filename_line); break; } case TK_A_GROUP: { @@ -2444,10 +2398,10 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event event->group_final = true; udev_event_apply_format(event, &rules->buf[cur->key.value_off], group, sizeof(group)); event->gid = util_lookup_group(event->udev, group); - info(event->udev, "GROUP %u %s:%u\n", - event->gid, - &rules->buf[rule->rule.filename_off], - rule->rule.filename_line); + log_debug("GROUP %u %s:%u\n", + event->gid, + &rules->buf[rule->rule.filename_off], + rule->rule.filename_line); break; } case TK_A_MODE: { @@ -2460,17 +2414,17 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event udev_event_apply_format(event, &rules->buf[cur->key.value_off], mode_str, sizeof(mode_str)); mode = strtol(mode_str, &endptr, 8); if (endptr[0] != '\0') { - err(event->udev, "ignoring invalid mode '%s'\n", mode_str); + log_error("ignoring invalid mode '%s'\n", mode_str); break; } if (cur->key.op == OP_ASSIGN_FINAL) event->mode_final = true; event->mode_set = true; event->mode = mode; - info(event->udev, "MODE %#o %s:%u\n", - event->mode, - &rules->buf[rule->rule.filename_off], - rule->rule.filename_line); + log_debug("MODE %#o %s:%u\n", + event->mode, + &rules->buf[rule->rule.filename_off], + rule->rule.filename_line); break; } case TK_A_OWNER_ID: @@ -2479,10 +2433,10 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event if (cur->key.op == OP_ASSIGN_FINAL) event->owner_final = true; event->uid = cur->key.uid; - info(event->udev, "OWNER %u %s:%u\n", - event->uid, - &rules->buf[rule->rule.filename_off], - rule->rule.filename_line); + log_debug("OWNER %u %s:%u\n", + event->uid, + &rules->buf[rule->rule.filename_off], + rule->rule.filename_line); break; case TK_A_GROUP_ID: if (event->group_final) @@ -2490,10 +2444,10 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event if (cur->key.op == OP_ASSIGN_FINAL) event->group_final = true; event->gid = cur->key.gid; - info(event->udev, "GROUP %u %s:%u\n", - event->gid, - &rules->buf[rule->rule.filename_off], - rule->rule.filename_line); + log_debug("GROUP %u %s:%u\n", + event->gid, + &rules->buf[rule->rule.filename_off], + rule->rule.filename_line); break; case TK_A_MODE_ID: if (event->mode_final) @@ -2502,10 +2456,10 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event event->mode_final = true; event->mode_set = true; event->mode = cur->key.mode; - info(event->udev, "MODE %#o %s:%u\n", - event->mode, - &rules->buf[rule->rule.filename_off], - rule->rule.filename_line); + log_debug("MODE %#o %s:%u\n", + event->mode, + &rules->buf[rule->rule.filename_off], + rule->rule.filename_line); break; case TK_A_ENV: { const char *name = &rules->buf[cur->key.attr_off]; @@ -2538,7 +2492,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event (*p >= '0' && *p <= '9') || *p == '-' || *p == '_') continue; - err(event->udev, "ignoring invalid tag name '%s'\n", tag); + log_error("ignoring invalid tag name '%s'\n", tag); break; } udev_device_add_tag(event->dev, tag); @@ -2558,13 +2512,13 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event if (esc == ESCAPE_UNSET || esc == ESCAPE_REPLACE) { count = util_replace_chars(name_str, "/"); if (count > 0) - info(event->udev, "%i character(s) replaced\n", count); + log_debug("%i character(s) replaced\n", count); } if (major(udev_device_get_devnum(event->dev))) { size_t devlen = strlen(udev_get_dev_path(event->udev))+1; if (strcmp(name_str, &udev_device_get_devnode(event->dev)[devlen]) != 0) { - err(event->udev, "NAME=\"%s\" ignored, kernel device nodes " + log_error("NAME=\"%s\" ignored, kernel device nodes " "can not be renamed; please fix it in %s:%u\n", name, &rules->buf[rule->rule.filename_off], rule->rule.filename_line); break; @@ -2572,10 +2526,10 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event } free(event->name); event->name = strdup(name_str); - info(event->udev, "NAME '%s' %s:%u\n", - event->name, - &rules->buf[rule->rule.filename_off], - rule->rule.filename_line); + log_debug("NAME '%s' %s:%u\n", + event->name, + &rules->buf[rule->rule.filename_off], + rule->rule.filename_line); break; } case TK_A_DEVLINK: { @@ -2600,16 +2554,15 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event else if (esc == ESCAPE_REPLACE) count = util_replace_chars(temp, "/"); if (count > 0) - info(event->udev, "%i character(s) replaced\n" , count); - dbg(event->udev, "rule applied, added symlink(s) '%s'\n", temp); + log_debug("%i character(s) replaced\n" , count); pos = temp; while (isspace(pos[0])) pos++; next = strchr(pos, ' '); while (next != NULL) { next[0] = '\0'; - info(event->udev, "LINK '%s' %s:%u\n", pos, - &rules->buf[rule->rule.filename_off], rule->rule.filename_line); + log_debug("LINK '%s' %s:%u\n", pos, + &rules->buf[rule->rule.filename_off], rule->rule.filename_line); util_strscpyl(filename, sizeof(filename), udev_get_dev_path(event->udev), "/", pos, NULL); udev_device_add_devlink(event->dev, filename, cur->key.devlink_unique); while (isspace(next[1])) @@ -2618,8 +2571,8 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event next = strchr(pos, ' '); } if (pos[0] != '\0') { - info(event->udev, "LINK '%s' %s:%u\n", pos, - &rules->buf[rule->rule.filename_off], rule->rule.filename_line); + log_debug("LINK '%s' %s:%u\n", pos, + &rules->buf[rule->rule.filename_off], rule->rule.filename_line); util_strscpyl(filename, sizeof(filename), udev_get_dev_path(event->udev), "/", pos, NULL); udev_device_add_devlink(event->dev, filename, cur->key.devlink_unique); } @@ -2636,26 +2589,26 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event attr_subst_subdir(attr, sizeof(attr)); udev_event_apply_format(event, &rules->buf[cur->key.value_off], value, sizeof(value)); - info(event->udev, "ATTR '%s' writing '%s' %s:%u\n", attr, value, - &rules->buf[rule->rule.filename_off], - rule->rule.filename_line); + log_debug("ATTR '%s' writing '%s' %s:%u\n", attr, value, + &rules->buf[rule->rule.filename_off], + rule->rule.filename_line); f = fopen(attr, "w"); if (f != NULL) { if (fprintf(f, "%s", value) <= 0) - err(event->udev, "error writing ATTR{%s}: %m\n", attr); + log_error("error writing ATTR{%s}: %m\n", attr); fclose(f); } else { - err(event->udev, "error opening ATTR{%s} for writing: %m\n", attr); + log_error("error opening ATTR{%s} for writing: %m\n", attr); } break; } case TK_A_RUN: { if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL) udev_list_cleanup(&event->run_list); - info(event->udev, "RUN '%s' %s:%u\n", - &rules->buf[cur->key.value_off], - &rules->buf[rule->rule.filename_off], - rule->rule.filename_line); + log_debug("RUN '%s' %s:%u\n", + &rules->buf[cur->key.value_off], + &rules->buf[rule->rule.filename_off], + rule->rule.filename_line); udev_list_entry_add(&event->run_list, &rules->buf[cur->key.value_off], NULL); break; } @@ -2671,7 +2624,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event case TK_M_PARENTS_MAX: case TK_M_MAX: case TK_UNSET: - err(rules->udev, "wrong type %u\n", cur->type); + log_error("wrong type %u\n", cur->type); goto nomatch; } @@ -2680,8 +2633,6 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event nomatch: /* fast-forward to next rule */ cur = rule + rule->rule.token_count; - dbg(rules->udev, "forward to rule: %u\n", - (unsigned int) (cur - rules->tokens)); } } @@ -2742,12 +2693,12 @@ void udev_rules_apply_static_dev_perms(struct udev_rules *rules) } if (mode != (stats.st_mode & 01777)) { chmod(filename, mode); - info(rules->udev, "chmod '%s' %#o\n", filename, mode); + log_debug("chmod '%s' %#o\n", filename, mode); } if ((uid != 0 && uid != stats.st_uid) || (gid != 0 && gid != stats.st_gid)) { chown(filename, uid, gid); - info(rules->udev, "chown '%s' %u %u\n", filename, uid, gid); + log_debug("chown '%s' %u %u\n", filename, uid, gid); } utimensat(AT_FDCWD, filename, NULL, 0); diff --git a/src/udev/udev-watch.c b/src/udev/udev-watch.c index 228d18fedf..968728eba9 100644 --- a/src/udev/udev-watch.c +++ b/src/udev/udev-watch.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2010 Kay Sievers + * Copyright (C) 2004-2012 Kay Sievers * Copyright (C) 2009 Canonical Ltd. * Copyright (C) 2009 Scott James Remnant * @@ -40,7 +40,7 @@ int udev_watch_init(struct udev *udev) { inotify_fd = inotify_init1(IN_CLOEXEC); if (inotify_fd < 0) - err(udev, "inotify_init failed: %m\n"); + log_error("inotify_init failed: %m\n"); return inotify_fd; } @@ -62,7 +62,7 @@ void udev_watch_restore(struct udev *udev) dir = opendir(oldname); if (dir == NULL) { - err(udev, "unable to open old watches dir '%s', old watches will not be restored: %m", oldname); + log_error("unable to open old watches dir '%s', old watches will not be restored: %m", oldname); return; } @@ -87,7 +87,7 @@ void udev_watch_restore(struct udev *udev) if (dev == NULL) goto unlink; - info(udev, "restoring old watch on '%s'\n", udev_device_get_devnode(dev)); + log_debug("restoring old watch on '%s'\n", udev_device_get_devnode(dev)); udev_watch_begin(udev, dev); udev_device_unref(dev); unlink: @@ -98,7 +98,7 @@ unlink: rmdir(oldname); } else if (errno != ENOENT) { - err(udev, "unable to move watches dir '%s', old watches will not be restored: %m", filename); + log_error("unable to move watches dir '%s', old watches will not be restored: %m", filename); } } @@ -110,10 +110,10 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev) if (inotify_fd < 0) return; - info(udev, "adding watch on '%s'\n", udev_device_get_devnode(dev)); + log_debug("adding watch on '%s'\n", udev_device_get_devnode(dev)); wd = inotify_add_watch(inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE); if (wd < 0) { - err(udev, "inotify_add_watch(%d, %s, %o) failed: %m\n", + log_error("inotify_add_watch(%d, %s, %o) failed: %m\n", inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE); return; } @@ -138,7 +138,7 @@ void udev_watch_end(struct udev *udev, struct udev_device *dev) if (wd < 0) return; - info(udev, "removing watch on '%s'\n", udev_device_get_devnode(dev)); + log_debug("removing watch on '%s'\n", udev_device_get_devnode(dev)); inotify_rm_watch(inotify_fd, wd); snprintf(filename, sizeof(filename), "%s/watch/%d", udev_get_run_path(udev), wd); diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c index ee9b59fea8..20a70cb458 100644 --- a/src/udev/udevadm-info.c +++ b/src/udev/udevadm-info.c @@ -67,7 +67,6 @@ static void print_all_attributes(struct udev_device *device, const char *key) value = udev_device_get_sysattr_value(device, name); if (value == NULL) continue; - dbg(udev, "attr '%s'='%s'\n", name, value); /* skip any values that look like a path */ if (value[0] == '/') @@ -77,10 +76,8 @@ static void print_all_attributes(struct udev_device *device, const char *key) len = strlen(value); while (len > 0 && isprint(value[len-1])) len--; - if (len > 0) { - dbg(udev, "attribute value of '%s' non-printable, skip\n", name); + if (len > 0) continue; - } printf(" %s{%s}==\"%s\"\n", key, name, value); } @@ -332,7 +329,6 @@ static int uinfo(struct udev *udev, int argc, char *argv[]) if (option == -1) break; - dbg(udev, "option '%c'\n", option); switch (option) { case 'n': if (device != NULL) { diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c index 5997dd8e18..6a202f04ca 100644 --- a/src/udev/udevadm-monitor.c +++ b/src/udev/udevadm-monitor.c @@ -162,7 +162,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[]) fd_ep = epoll_create1(EPOLL_CLOEXEC); if (fd_ep < 0) { - err(udev, "error creating epoll fd: %m\n"); + log_error("error creating epoll fd: %m\n"); goto out; } @@ -204,7 +204,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[]) ep_udev.events = EPOLLIN; ep_udev.data.fd = fd_udev; if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_udev, &ep_udev) < 0) { - err(udev, "fail to add fd to epoll: %m\n"); + log_error("fail to add fd to epoll: %m\n"); goto out; } @@ -240,7 +240,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[]) ep_kernel.events = EPOLLIN; ep_kernel.data.fd = fd_kernel; if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_kernel, &ep_kernel) < 0) { - err(udev, "fail to add fd to epoll: %m\n"); + log_error("fail to add fd to epoll: %m\n"); goto out; } diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c index b168defd90..d7fbc9e560 100644 --- a/src/udev/udevadm-settle.c +++ b/src/udev/udevadm-settle.c @@ -57,8 +57,6 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) struct udev_queue *udev_queue = NULL; int rc = EXIT_FAILURE; - dbg(udev, "version %s\n", VERSION); - for (;;) { int option; int seconds; @@ -80,7 +78,6 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) timeout = seconds; else fprintf(stderr, "invalid timeout value\n"); - dbg(udev, "timeout=%i\n", timeout); break; case 'q': quiet = 1; @@ -116,20 +113,20 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) end = udev_queue_get_kernel_seqnum(udev_queue); if (start > end) { - err(udev, "seq-start larger than seq-end, ignoring\n"); + log_error("seq-start larger than seq-end, ignoring\n"); start = 0; end = 0; } if (start > kernel_seq || end > kernel_seq) { - err(udev, "seq-start or seq-end larger than current kernel value, ignoring\n"); + log_error("seq-start or seq-end larger than current kernel value, ignoring\n"); start = 0; end = 0; } - info(udev, "start=%llu end=%llu current=%llu\n", start, end, kernel_seq); + log_debug("start=%llu end=%llu current=%llu\n", start, end, kernel_seq); } else { if (end > 0) { - err(udev, "seq-end needs seq-start parameter, ignoring\n"); + log_error("seq-end needs seq-start parameter, ignoring\n"); end = 0; } } @@ -141,7 +138,7 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) uctrl = udev_ctrl_new(udev); if (uctrl != NULL) { if (udev_ctrl_send_ping(uctrl, timeout) < 0) { - info(udev, "no connection to daemon\n"); + log_debug("no connection to daemon\n"); udev_ctrl_unref(uctrl); rc = EXIT_SUCCESS; goto out; @@ -153,10 +150,10 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) pfd[0].events = POLLIN; pfd[0].fd = inotify_init1(IN_CLOEXEC); if (pfd[0].fd < 0) { - err(udev, "inotify_init failed: %m\n"); + log_error("inotify_init failed: %m\n"); } else { if (inotify_add_watch(pfd[0].fd, udev_get_run_path(udev), IN_MOVED_TO) < 0) { - err(udev, "watching '%s' failed\n", udev_get_run_path(udev)); + log_error("watching '%s' failed\n", udev_get_run_path(udev)); close(pfd[0].fd); pfd[0].fd = -1; } @@ -209,7 +206,7 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) struct udev_list_entry *list_entry; if (!quiet && udev_queue_get_queued_list_entry(udev_queue) != NULL) { - info(udev, "timeout waiting for udev queue\n"); + log_debug("timeout waiting for udev queue\n"); printf("\nudevadm settle - timeout of %i seconds reached, the event queue contains:\n", timeout); udev_list_entry_foreach(list_entry, udev_queue_get_queued_list_entry(udev_queue)) printf(" %s (%s)\n", diff --git a/src/udev/udevadm-test-builtin.c b/src/udev/udevadm-test-builtin.c index 3a49f7ce9c..94bb24f5f8 100644 --- a/src/udev/udevadm-test-builtin.c +++ b/src/udev/udevadm-test-builtin.c @@ -55,8 +55,6 @@ static int adm_builtin(struct udev *udev, int argc, char *argv[]) enum udev_builtin_cmd cmd; int rc = EXIT_SUCCESS; - dbg(udev, "version %s\n", VERSION); - for (;;) { int option; diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c index 6275cff899..f963c1b510 100644 --- a/src/udev/udevadm-test.c +++ b/src/udev/udevadm-test.c @@ -52,7 +52,7 @@ static int adm_test(struct udev *udev, int argc, char *argv[]) {} }; - info(udev, "version %s\n", VERSION); + log_debug("version %s\n", VERSION); for (;;) { int option; @@ -61,7 +61,6 @@ static int adm_test(struct udev *udev, int argc, char *argv[]) if (option == -1) break; - dbg(udev, "option '%c'\n", option); switch (option) { case 'a': action = optarg; @@ -75,7 +74,7 @@ static int adm_test(struct udev *udev, int argc, char *argv[]) resolve_names = -1; } else { fprintf(stderr, "resolve-names must be early, late or never\n"); - err(udev, "resolve-names must be early, late or never\n"); + log_error("resolve-names must be early, late or never\n"); exit(EXIT_FAILURE); } break; @@ -96,7 +95,7 @@ static int adm_test(struct udev *udev, int argc, char *argv[]) goto out; } - printf("This program is for debugging only, it does not run any program,\n" + printf("This program is for debugging only, it does not run any program\n" "specified by a RUN key. It may show incorrect results, because\n" "some values may be different, or not available at a simulation run.\n" "\n"); diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c index 3cce23dfb2..36a2864fa7 100644 --- a/src/udev/udevadm-trigger.c +++ b/src/udev/udevadm-trigger.c @@ -51,12 +51,10 @@ static void exec_list(struct udev_enumerate *udev_enumerate, const char *action) continue; util_strscpyl(filename, sizeof(filename), udev_list_entry_get_name(entry), "/uevent", NULL); fd = open(filename, O_WRONLY); - if (fd < 0) { - dbg(udev, "error on opening %s: %m\n", filename); + if (fd < 0) continue; - } if (write(fd, action, strlen(action)) < 0) - info(udev, "error writing '%s' to '%s': %m\n", action, filename); + log_debug("error writing '%s' to '%s': %m\n", action, filename); close(fd); } } @@ -101,7 +99,6 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) struct udev_enumerate *udev_enumerate; int rc = 0; - dbg(udev, "version %s\n", VERSION); udev_enumerate = udev_enumerate_new(udev); if (udev_enumerate == NULL) { rc = 1; @@ -131,7 +128,7 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) } else if (strcmp(optarg, "subsystems") == 0) { device_type = TYPE_SUBSYSTEMS; } else { - err(udev, "unknown type --type=%s\n", optarg); + log_error("unknown type --type=%s\n", optarg); rc = 2; goto exit; } @@ -175,7 +172,7 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) util_remove_trailing_chars(path, '/'); dev = udev_device_new_from_syspath(udev, path); if (dev == NULL) { - err(udev, "unable to open the device '%s'\n", optarg); + log_error("unable to open the device '%s'\n", optarg); rc = 2; goto exit; } diff --git a/src/udev/udevadm.c b/src/udev/udevadm.c index 224ece0bb7..55b5948aae 100644 --- a/src/udev/udevadm.c +++ b/src/udev/udevadm.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2009 Kay Sievers + * Copyright (C) 2007-2012 Kay Sievers * * 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 @@ -25,23 +25,11 @@ #include "udev.h" -static bool debug; - void udev_main_log(struct udev *udev, int priority, const char *file, int line, const char *fn, const char *format, va_list args) { - if (debug) { - fprintf(stderr, "%s: ", fn); - vfprintf(stderr, format, args); - } else { - va_list args2; - - va_copy(args2, args); - vfprintf(stderr, format, args2); - va_end(args2); - vsyslog(priority, format, args); - } + log_metav(priority, file, line, fn, format, args); } static int adm_version(struct udev *udev, int argc, char *argv[]) @@ -49,12 +37,14 @@ static int adm_version(struct udev *udev, int argc, char *argv[]) printf("%s\n", VERSION); return 0; } + static const struct udevadm_cmd udevadm_version = { .name = "version", .cmd = adm_version, }; static int adm_help(struct udev *udev, int argc, char *argv[]); + static const struct udevadm_cmd udevadm_help = { .name = "help", .cmd = adm_help, @@ -86,12 +76,9 @@ static int adm_help(struct udev *udev, int argc, char *argv[]) static int run_command(struct udev *udev, const struct udevadm_cmd *cmd, int argc, char *argv[]) { - if (cmd->debug) { - debug = true; - if (udev_get_log_priority(udev) < LOG_INFO) - udev_set_log_priority(udev, LOG_INFO); - } - info(udev, "calling: %s\n", cmd->name); + if (cmd->debug) + log_set_max_level(LOG_DEBUG); + log_debug("calling: %s\n", cmd->name); return cmd->cmd(udev, argc, argv); } @@ -112,7 +99,8 @@ int main(int argc, char *argv[]) if (udev == NULL) goto out; - udev_log_init("udevadm"); + log_open(); + log_parse_environment(); udev_set_log_fn(udev, udev_main_log); udev_selinux_init(udev); @@ -125,9 +113,8 @@ int main(int argc, char *argv[]) switch (option) { case 'd': - debug = true; - if (udev_get_log_priority(udev) < LOG_INFO) - udev_set_log_priority(udev, LOG_INFO); + log_set_max_level(LOG_DEBUG); + udev_set_log_priority(udev, LOG_DEBUG); break; case 'h': rc = adm_help(udev, argc, argv); @@ -141,7 +128,7 @@ int main(int argc, char *argv[]) } command = argv[optind]; - info(udev, "runtime dir '%s'\n", udev_get_run_path(udev)); + log_debug("runtime dir '%s'\n", udev_get_run_path(udev)); if (command != NULL) for (i = 0; i < ARRAY_SIZE(udevadm_cmds); i++) { @@ -160,6 +147,6 @@ int main(int argc, char *argv[]) out: udev_selinux_exit(udev); udev_unref(udev); - udev_log_close(); + log_close(); return rc; } diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 694e758777..589a8fe753 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 Kay Sievers + * Copyright (C) 2004-2012 Kay Sievers * Copyright (C) 2004 Chris Friesen * Copyright (C) 2009 Canonical Ltd. * Copyright (C) 2009 Scott James Remnant @@ -53,18 +53,7 @@ void udev_main_log(struct udev *udev, int priority, const char *file, int line, const char *fn, const char *format, va_list args) { - if (debug) { - char buf[1024]; - struct timespec ts; - - vsnprintf(buf, sizeof(buf), format, args); - clock_gettime(CLOCK_MONOTONIC, &ts); - fprintf(stderr, "[%llu.%06u] [%u] %s: %s", - (unsigned long long) ts.tv_sec, (unsigned int) ts.tv_nsec/1000, - (int) getpid(), fn, buf); - } else { - vsyslog(priority, format, args); - } + log_metav(priority, file, line, fn, format, args); } static struct udev_rules *rules; @@ -157,7 +146,7 @@ static void event_queue_delete(struct event *event, bool export) if (export) { udev_queue_export_device_finished(udev_queue_export, event->dev); - info(event->udev, "seq %llu done with %i\n", udev_device_get_seqnum(event->dev), event->exitcode); + log_debug("seq %llu done with %i\n", udev_device_get_seqnum(event->dev), event->exitcode); } udev_device_unref(event->dev); free(event); @@ -182,7 +171,7 @@ static void worker_unref(struct worker *worker) worker->refcount--; if (worker->refcount > 0) return; - info(worker->udev, "worker [%u] cleaned up\n", worker->pid); + log_debug("worker [%u] cleaned up\n", worker->pid); worker_cleanup(worker); } @@ -247,14 +236,14 @@ static void worker_new(struct event *event) sigfillset(&mask); fd_signal = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC); if (fd_signal < 0) { - err(udev, "error creating signalfd %m\n"); + log_error("error creating signalfd %m\n"); rc = 2; goto out; } fd_ep = epoll_create1(EPOLL_CLOEXEC); if (fd_ep < 0) { - err(udev, "error creating epoll fd: %m\n"); + log_error("error creating epoll fd: %m\n"); rc = 3; goto out; } @@ -270,7 +259,7 @@ static void worker_new(struct event *event) if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_signal, &ep_signal) < 0 || epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_monitor, &ep_monitor) < 0) { - err(udev, "fail to add fds to epoll: %m\n"); + log_error("fail to add fds to epoll: %m\n"); rc = 4; goto out; } @@ -283,7 +272,7 @@ static void worker_new(struct event *event) struct worker_message msg; int err; - info(udev, "seq %llu running\n", udev_device_get_seqnum(dev)); + log_debug("seq %llu running\n", udev_device_get_seqnum(dev)); udev_event = udev_event_new(dev); if (udev_event == NULL) { rc = 5; @@ -318,7 +307,7 @@ static void worker_new(struct event *event) msg.pid = getpid(); send(worker_watch[WRITE_END], &msg, sizeof(struct worker_message), 0); - info(udev, "seq %llu processed with %i\n", udev_device_get_seqnum(dev), err); + log_debug("seq %llu processed with %i\n", udev_device_get_seqnum(dev), err); udev_device_unref(dev); dev = NULL; @@ -341,7 +330,7 @@ static void worker_new(struct event *event) if (errno == EINTR) continue; err = -errno; - err(udev, "failed to poll: %m\n"); + log_error("failed to poll: %m\n"); goto out; } @@ -376,14 +365,14 @@ out: udev_builtin_exit(udev); udev_monitor_unref(worker_monitor); udev_unref(udev); - udev_log_close(); + log_close(); exit(rc); } case -1: udev_monitor_unref(worker_monitor); event->state = EVENT_QUEUED; free(worker); - err(udev, "fork of child failed: %m\n"); + log_error("fork of child failed: %m\n"); break; default: /* close monitor, but keep address around */ @@ -396,7 +385,7 @@ out: event->state = EVENT_RUNNING; udev_list_node_append(&worker->node, &worker_list); children++; - info(udev, "seq %llu forked new worker [%u]\n", udev_device_get_seqnum(event->dev), pid); + log_debug("seq %llu forked new worker [%u]\n", udev_device_get_seqnum(event->dev), pid); break; } } @@ -414,7 +403,7 @@ static void event_run(struct event *event) count = udev_monitor_send_device(monitor, worker->monitor, event->dev); if (count < 0) { - err(event->udev, "worker [%u] did not accept message %zi (%m), kill it\n", worker->pid, count); + log_error("worker [%u] did not accept message %zi (%m), kill it\n", worker->pid, count); kill(worker->pid, SIGKILL); worker->state = WORKER_KILLED; continue; @@ -429,7 +418,7 @@ static void event_run(struct event *event) if (children >= children_max) { if (children_max > 1) - info(event->udev, "maximum number (%i) of children reached\n", children); + log_debug("maximum number (%i) of children reached\n", children); return; } @@ -456,7 +445,7 @@ static int event_queue_insert(struct udev_device *dev) event->ifindex = udev_device_get_ifindex(dev); udev_queue_export_device_queued(udev_queue_export, dev); - info(event->udev, "seq %llu queued, '%s' '%s'\n", udev_device_get_seqnum(dev), + log_debug("seq %llu queued, '%s' '%s'\n", udev_device_get_seqnum(dev), udev_device_get_action(dev), udev_device_get_subsystem(dev)); event->state = EVENT_QUEUED; @@ -572,10 +561,8 @@ static void event_queue_start(struct udev *udev) continue; /* do not start event if parent or child event is still running */ - if (is_devpath_busy(event)) { - dbg(udev, "delay seq %llu (%s)\n", event->seqnum, event->devpath); + if (is_devpath_busy(event)) continue; - } event_run(event); } @@ -646,23 +633,24 @@ static struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl) i = udev_ctrl_get_set_log_level(ctrl_msg); if (i >= 0) { - info(udev, "udevd message (SET_LOG_PRIORITY) received, log_priority=%i\n", i); + log_debug("udevd message (SET_LOG_PRIORITY) received, log_priority=%i\n", i); + log_set_max_level(i); udev_set_log_priority(udev, i); worker_kill(udev, 0); } if (udev_ctrl_get_stop_exec_queue(ctrl_msg) > 0) { - info(udev, "udevd message (STOP_EXEC_QUEUE) received\n"); + log_debug("udevd message (STOP_EXEC_QUEUE) received\n"); stop_exec_queue = true; } if (udev_ctrl_get_start_exec_queue(ctrl_msg) > 0) { - info(udev, "udevd message (START_EXEC_QUEUE) received\n"); + log_debug("udevd message (START_EXEC_QUEUE) received\n"); stop_exec_queue = false; } if (udev_ctrl_get_reload(ctrl_msg) > 0) { - info(udev, "udevd message (RELOAD) received\n"); + log_debug("udevd message (RELOAD) received\n"); reload = true; } @@ -679,14 +667,14 @@ static struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl) val[0] = '\0'; val = &val[1]; if (val[0] == '\0') { - info(udev, "udevd message (ENV) received, unset '%s'\n", key); + log_debug("udevd message (ENV) received, unset '%s'\n", key); udev_add_property(udev, key, NULL); } else { - info(udev, "udevd message (ENV) received, set '%s=%s'\n", key, val); + log_debug("udevd message (ENV) received, set '%s=%s'\n", key, val); udev_add_property(udev, key, val); } } else { - err(udev, "wrong key format '%s'\n", key); + log_error("wrong key format '%s'\n", key); } free(key); } @@ -695,15 +683,15 @@ static struct udev_ctrl_connection *handle_ctrl_msg(struct udev_ctrl *uctrl) i = udev_ctrl_get_set_children_max(ctrl_msg); if (i >= 0) { - info(udev, "udevd message (SET_MAX_CHILDREN) received, children_max=%i\n", i); + log_debug("udevd message (SET_MAX_CHILDREN) received, children_max=%i\n", i); children_max = i; } if (udev_ctrl_get_ping(ctrl_msg) > 0) - info(udev, "udevd message (SYNC) received\n"); + log_debug("udevd message (SYNC) received\n"); if (udev_ctrl_get_exit(ctrl_msg) > 0) { - info(udev, "udevd message (EXIT) received\n"); + log_debug("udevd message (EXIT) received\n"); udev_exit = true; /* keep reference to block the client until we exit */ udev_ctrl_connection_ref(ctrl_conn); @@ -725,7 +713,7 @@ static int handle_inotify(struct udev *udev) buf = malloc(nbytes); if (buf == NULL) { - err(udev, "error getting buffer for inotify\n"); + log_error("error getting buffer for inotify\n"); return -1; } @@ -737,17 +725,17 @@ static int handle_inotify(struct udev *udev) ev = (struct inotify_event *)(buf + pos); dev = udev_watch_lookup(udev, ev->wd); if (dev != NULL) { - info(udev, "inotify event: %x for %s\n", ev->mask, udev_device_get_devnode(dev)); + log_debug("inotify event: %x for %s\n", ev->mask, udev_device_get_devnode(dev)); if (ev->mask & IN_CLOSE_WRITE) { char filename[UTIL_PATH_SIZE]; int fd; - info(udev, "device %s closed, synthesising 'change'\n", udev_device_get_devnode(dev)); + log_debug("device %s closed, synthesising 'change'\n", udev_device_get_devnode(dev)); util_strscpyl(filename, sizeof(filename), udev_device_get_syspath(dev), "/uevent", NULL); fd = open(filename, O_WRONLY); if (fd >= 0) { if (write(fd, "change", 6) < 0) - info(udev, "error writing uevent: %m\n"); + log_debug("error writing uevent: %m\n"); close(fd); } } @@ -785,26 +773,26 @@ static void handle_signal(struct udev *udev, int signo) if (worker->pid != pid) continue; - info(udev, "worker [%u] exit\n", pid); + log_debug("worker [%u] exit\n", pid); if (WIFEXITED(status)) { if (WEXITSTATUS(status) != 0) - err(udev, "worker [%u] exit with return code %i\n", pid, WEXITSTATUS(status)); + log_error("worker [%u] exit with return code %i\n", pid, WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { - err(udev, "worker [%u] terminated by signal %i (%s)\n", + log_error("worker [%u] terminated by signal %i (%s)\n", pid, WTERMSIG(status), strsignal(WTERMSIG(status))); } else if (WIFSTOPPED(status)) { - err(udev, "worker [%u] stopped\n", pid); + log_error("worker [%u] stopped\n", pid); } else if (WIFCONTINUED(status)) { - err(udev, "worker [%u] continued\n", pid); + log_error("worker [%u] continued\n", pid); } else { - err(udev, "worker [%u] exit with status 0x%04x\n", pid, status); + log_error("worker [%u] exit with status 0x%04x\n", pid, status); } if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { if (worker->event) { - err(udev, "worker [%u] failed while handling '%s'\n", - pid, worker->event->devpath); + log_error("worker [%u] failed while handling '%s'\n", + pid, worker->event->devpath); worker->event->exitcode = -32; event_queue_delete(worker->event, true); /* drop reference taken for state 'running' */ @@ -879,7 +867,7 @@ static void static_dev_create_from_modules(struct udev *udev) util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev), "/", devname, NULL); util_create_path_selinux(udev, filename); udev_selinux_setfscreatecon(udev, filename, mode); - info(udev, "mknod '%s' %c%u:%u\n", filename, type, maj, min); + log_debug("mknod '%s' %c%u:%u\n", filename, type, maj, min); if (mknod(filename, mode, makedev(maj, min)) < 0 && errno == EEXIST) utimensat(AT_FDCWD, filename, NULL, 0); udev_selinux_resetfscreatecon(udev); @@ -1148,7 +1136,7 @@ static int systemd_fds(struct udev *udev, int *rctrl, int *rnetlink) if (ctrl < 0 || netlink < 0) return -1; - info(udev, "ctrl=%i netlink=%i\n", ctrl, netlink); + log_debug("ctrl=%i netlink=%i\n", ctrl, netlink); *rctrl = ctrl; *rnetlink = netlink; return 0; @@ -1173,7 +1161,7 @@ static bool check_rules_timestamp(struct udev *udev) /* first check */ if (stamp_usec[i] != 0) { - info(udev, "reload - timestamp of '%s' changed\n", p[i]); + log_debug("reload - timestamp of '%s' changed\n", p[i]); changed = true; } @@ -1213,9 +1201,10 @@ int main(int argc, char *argv[]) if (udev == NULL) goto exit; - udev_log_init("udevd"); + log_open(); + log_parse_environment(); udev_set_log_fn(udev, udev_main_log); - info(udev, "version %s\n", VERSION); + log_debug("version %s\n", VERSION); udev_selinux_init(udev); for (;;) { @@ -1249,7 +1238,7 @@ int main(int argc, char *argv[]) resolve_names = -1; } else { fprintf(stderr, "resolve-names must be early, late or never\n"); - err(udev, "resolve-names must be early, late or never\n"); + log_error("resolve-names must be early, late or never\n"); goto exit; } break; @@ -1308,7 +1297,7 @@ int main(int argc, char *argv[]) if (getuid() != 0) { fprintf(stderr, "root privileges required\n"); - err(udev, "root privileges required\n"); + log_error("root privileges required\n"); goto exit; } @@ -1337,7 +1326,7 @@ int main(int argc, char *argv[]) close(fd); } else { fprintf(stderr, "cannot open /dev/null\n"); - err(udev, "cannot open /dev/null\n"); + log_error("cannot open /dev/null\n"); } } @@ -1345,14 +1334,14 @@ int main(int argc, char *argv[]) /* get control and netlink socket from from systemd */ udev_ctrl = udev_ctrl_new_from_fd(udev, fd_ctrl); if (udev_ctrl == NULL) { - err(udev, "error taking over udev control socket"); + log_error("error taking over udev control socket"); rc = 1; goto exit; } monitor = udev_monitor_new_from_netlink_fd(udev, "kernel", fd_netlink); if (monitor == NULL) { - err(udev, "error taking over netlink socket\n"); + log_error("error taking over netlink socket\n"); rc = 3; goto exit; } @@ -1361,7 +1350,7 @@ int main(int argc, char *argv[]) udev_ctrl = udev_ctrl_new(udev); if (udev_ctrl == NULL) { fprintf(stderr, "error initializing udev control socket"); - err(udev, "error initializing udev control socket"); + log_error("error initializing udev control socket"); rc = 1; goto exit; } @@ -1370,7 +1359,7 @@ int main(int argc, char *argv[]) monitor = udev_monitor_new_from_netlink(udev, "kernel"); if (monitor == NULL) { fprintf(stderr, "error initializing netlink socket\n"); - err(udev, "error initializing netlink socket\n"); + log_error("error initializing netlink socket\n"); rc = 3; goto exit; } @@ -1379,14 +1368,14 @@ int main(int argc, char *argv[]) if (udev_monitor_enable_receiving(monitor) < 0) { fprintf(stderr, "error binding netlink socket\n"); - err(udev, "error binding netlink socket\n"); + log_error("error binding netlink socket\n"); rc = 3; goto exit; } if (udev_ctrl_enable_receiving(udev_ctrl) < 0) { fprintf(stderr, "error binding udev control socket\n"); - err(udev, "error binding udev control socket\n"); + log_error("error binding udev control socket\n"); rc = 1; goto exit; } @@ -1396,7 +1385,7 @@ int main(int argc, char *argv[]) /* create queue file before signalling 'ready', to make sure we block 'settle' */ udev_queue_export = udev_queue_export_new(udev); if (udev_queue_export == NULL) { - err(udev, "error creating queue file\n"); + log_error("error creating queue file\n"); goto exit; } @@ -1409,7 +1398,7 @@ int main(int argc, char *argv[]) case 0: break; case -1: - err(udev, "fork of daemon failed: %m\n"); + log_error("fork of daemon failed: %m\n"); rc = 4; goto exit; default: @@ -1424,7 +1413,7 @@ int main(int argc, char *argv[]) /* Fallback to old interface */ fd = open("/proc/self/oom_adj", O_RDWR); if (fd < 0) { - err(udev, "error disabling OOM: %m\n"); + log_error("error disabling OOM: %m\n"); } else { /* OOM_DISABLE == -17 */ write(fd, "-17", 3); @@ -1459,7 +1448,7 @@ int main(int argc, char *argv[]) fd_inotify = udev_watch_init(udev); if (fd_inotify < 0) { fprintf(stderr, "error initializing inotify\n"); - err(udev, "error initializing inotify\n"); + log_error("error initializing inotify\n"); rc = 4; goto exit; } @@ -1471,7 +1460,7 @@ int main(int argc, char *argv[]) fd_signal = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC); if (fd_signal < 0) { fprintf(stderr, "error creating signalfd\n"); - err(udev, "error creating signalfd\n"); + log_error("error creating signalfd\n"); rc = 5; goto exit; } @@ -1479,7 +1468,7 @@ int main(int argc, char *argv[]) /* unnamed socket from workers to the main daemon */ if (socketpair(AF_LOCAL, SOCK_DGRAM|SOCK_CLOEXEC, 0, worker_watch) < 0) { fprintf(stderr, "error creating socketpair\n"); - err(udev, "error creating socketpair\n"); + log_error("error creating socketpair\n"); rc = 6; goto exit; } @@ -1489,7 +1478,7 @@ int main(int argc, char *argv[]) rules = udev_rules_new(udev, resolve_names); if (rules == NULL) { - err(udev, "error reading rules\n"); + log_error("error reading rules\n"); goto exit; } @@ -1515,7 +1504,7 @@ int main(int argc, char *argv[]) fd_ep = epoll_create1(EPOLL_CLOEXEC); if (fd_ep < 0) { - err(udev, "error creating epoll fd: %m\n"); + log_error("error creating epoll fd: %m\n"); goto exit; } if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_ctrl, &ep_ctrl) < 0 || @@ -1523,7 +1512,7 @@ int main(int argc, char *argv[]) epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_signal, &ep_signal) < 0 || epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_netlink, &ep_netlink) < 0 || epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_worker, &ep_worker) < 0) { - err(udev, "fail to add fds to epoll: %m\n"); + log_error("fail to add fds to epoll: %m\n"); goto exit; } @@ -1539,7 +1528,7 @@ int main(int argc, char *argv[]) else children_max = 128; } - info(udev, "set children_max to %u\n", children_max); + log_debug("set children_max to %u\n", children_max); udev_rules_apply_static_dev_perms(rules); @@ -1597,13 +1586,13 @@ int main(int argc, char *argv[]) /* timeout */ if (udev_exit) { - err(udev, "timeout, giving up waiting for workers to finish\n"); + log_error("timeout, giving up waiting for workers to finish\n"); break; } /* kill idle workers */ if (udev_list_node_is_empty(&event_list)) { - info(udev, "cleanup idle workers\n"); + log_debug("cleanup idle workers\n"); worker_kill(udev, 2); } @@ -1615,15 +1604,15 @@ int main(int argc, char *argv[]) continue; if ((now_usec() - worker->event_start_usec) > 30 * 1000 * 1000) { - err(udev, "worker [%u] timeout, kill it\n", worker->pid, + log_error("worker [%u] timeout, kill it\n", worker->pid, worker->event ? worker->event->devpath : ""); kill(worker->pid, SIGKILL); worker->state = WORKER_KILLED; /* drop reference taken for state 'running' */ worker_unref(worker); if (worker->event) { - err(udev, "seq %llu '%s' killed\n", - udev_device_get_seqnum(worker->event->dev), worker->event->devpath); + log_error("seq %llu '%s' killed\n", + udev_device_get_seqnum(worker->event->dev), worker->event->devpath); worker->event->exitcode = -64; event_queue_delete(worker->event, true); worker->event = NULL; @@ -1741,6 +1730,6 @@ exit_daemonize: udev_ctrl_unref(udev_ctrl); udev_selinux_exit(udev); udev_unref(udev); - udev_log_close(); + log_close(); return rc; } -- cgit v1.2.3-54-g00ecf