X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fudev%2Fcdrom_id%2Fcdrom_id.c;h=48ceb657e071a025386970f1e2e637ade11e36f6;hp=93467c2d35b0b95734570536dd8cb996f9ed8e85;hb=25e773eeb4f853804e1bf0dbd9a184f23e9b2a97;hpb=c8a202b7d47f9d6bba3100a208abdadfc383499e diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c index 93467c2d3..48ceb657e 100644 --- a/src/udev/cdrom_id/cdrom_id.c +++ b/src/udev/cdrom_id/cdrom_id.c @@ -37,21 +37,6 @@ #include "libudev.h" #include "libudev-private.h" -static bool debug; - -_printf_(6,0) -static void log_fn(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 { - vsyslog(priority, format, args); - } -} - /* device info */ static unsigned int cd_cd_rom; static unsigned int cd_cd_r; @@ -556,7 +541,7 @@ static int cd_profiles(struct udev *udev, int fd) if ((err != 0)) { 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) { + if (SK(err) == 0x5 && (ASC(err) == 0x20 || ASC(err) == 0x24)) { log_debug("drive is pre-MMC2 and does not support 46h get configuration command"); log_debug("trying to work around the problem"); ret = cd_profiles_old_mmc(udev, fd); @@ -613,7 +598,7 @@ static int cd_profiles(struct udev *udev, int fd) switch (feature) { case 0x00: log_debug("GET CONFIGURATION: feature 'profiles', with %i entries", features[i+3] / 4); - feature_profiles(udev, &features[i]+4, features[i+3]); + feature_profiles(udev, &features[i]+4, MIN(features[i+3], len - i - 4)); break; default: log_debug("GET CONFIGURATION: feature 0x%04x , with 0x%02x bytes", feature, features[i+3]); @@ -875,13 +860,13 @@ int main(int argc, char *argv[]) int cnt; int rc = 0; + log_parse_environment(); + log_open(); + udev = udev_new(); if (udev == NULL) goto exit; - log_open(); - udev_set_log_fn(udev, log_fn); - while (1) { int option; @@ -900,9 +885,9 @@ int main(int argc, char *argv[]) eject = true; break; case 'd': - debug = true; + log_set_target(LOG_TARGET_CONSOLE); log_set_max_level(LOG_DEBUG); - udev_set_log_priority(udev, LOG_DEBUG); + log_open(); break; case 'h': printf("Usage: cdrom_id [options] \n" @@ -926,7 +911,7 @@ int main(int argc, char *argv[]) goto exit; } - srand((unsigned int)getpid()); + initialize_srand(); for (cnt = 20; cnt > 0; cnt--) { struct timespec duration;