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=54a50756a8d15d0444aca106e24fba9d432c0f09;hp=f90d52ec9c487d5193b0c5efff4c4b00daab232e;hb=62a30b2c490512fe22a4e5faacb1d55763ead1e0;hpb=3e2147858f21943d5f4a781c60f33ac22c6096ed diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c index f90d52ec9..54a50756a 100644 --- a/src/udev/cdrom_id/cdrom_id.c +++ b/src/udev/cdrom_id/cdrom_id.c @@ -1,7 +1,7 @@ /* * cdrom_id - optical drive and media information prober * - * Copyright (C) 2008-2010 Kay Sievers + * Copyright (C) 2008-2010 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 @@ -17,10 +17,6 @@ * along with this program. If not, see . */ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif - #include #include #include @@ -41,20 +37,6 @@ #include "libudev.h" #include "libudev-private.h" -static bool debug; - -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; @@ -125,7 +107,7 @@ static bool is_mounted(const char *device) if (stat(device, &statbuf) < 0) return -ENODEV; - fp = fopen("/proc/self/mountinfo", "r"); + fp = fopen("/proc/self/mountinfo", "re"); if (fp == NULL) return -ENOSYS; while (fscanf(fp, "%*s %*s %i:%i %*[^\n]", &maj, &min) == 2) { @@ -138,13 +120,13 @@ static bool is_mounted(const char *device) return mounted; } -static void info_scsi_cmd_err(struct udev *udev, char *cmd, int err) +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", 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", cmd, SK(err), ASC(err), ASCQ(err)); } struct scsi_cmd { @@ -158,7 +140,7 @@ struct scsi_cmd { static void scsi_cmd_init(struct udev *udev, struct scsi_cmd *cmd) { - memset(cmd, 0x00, sizeof(struct scsi_cmd)); + memzero(cmd, sizeof(struct scsi_cmd)); cmd->cgc.quiet = 1; cmd->cgc.sense = &cmd->_sense.s; cmd->sg_io.interface_id = 'S'; @@ -209,11 +191,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"); err = ioctl(fd, CDROM_LOCKDOOR, lock ? 1 : 0); if (err < 0) - info(udev, "CDROM_LOCKDOOR failed\n"); + log_debug("CDROM_LOCKDOOR failed"); return err; } @@ -241,7 +223,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"); return -1; } @@ -265,7 +247,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"); return -1; } cd_media = 1; @@ -289,11 +271,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"); return -1; } - info(udev, "INQUIRY: [%.8s][%.16s][%.4s]\n", inq + 8, inq + 16, inq + 32); + log_debug("INQUIRY: [%.8s][%.16s][%.4s]", inq + 8, inq + 16, inq + 32); return 0; } @@ -303,105 +285,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 ", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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", 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 ", cur_profile); break; } } @@ -418,77 +400,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", profile); cd_mo = 1; break; case 0x08: - info(udev, "profile 0x%02x cd_rom\n", profile); + log_debug("profile 0x%02x cd_rom", profile); cd_cd_rom = 1; break; case 0x09: - info(udev, "profile 0x%02x cd_r\n", profile); + log_debug("profile 0x%02x cd_r", profile); cd_cd_r = 1; break; case 0x0A: - info(udev, "profile 0x%02x cd_rw\n", profile); + log_debug("profile 0x%02x cd_rw", profile); cd_cd_rw = 1; break; case 0x10: - info(udev, "profile 0x%02x dvd_rom\n", profile); + log_debug("profile 0x%02x dvd_rom", profile); cd_dvd_rom = 1; break; case 0x12: - info(udev, "profile 0x%02x dvd_ram\n", profile); + log_debug("profile 0x%02x dvd_ram", 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", 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", 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", 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", 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", 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", 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", profile); break; case 0x43: cd_bd_re = 1; - info(udev, "profile 0x%02x bd_re\n", profile); + log_debug("profile 0x%02x bd_re", profile); break; case 0x50: cd_hddvd = 1; - info(udev, "profile 0x%02x hddvd\n", profile); + log_debug("profile 0x%02x hddvd", profile); break; case 0x51: cd_hddvd_r = 1; - info(udev, "profile 0x%02x hddvd_r\n", profile); + log_debug("profile 0x%02x hddvd_r", profile); break; case 0x52: cd_hddvd_rw = 1; - info(udev, "profile 0x%02x hddvd_rw\n", profile); + log_debug("profile 0x%02x hddvd_rw", profile); break; default: - info(udev, "profile 0x%02x \n", profile); + log_debug("profile 0x%02x ", profile); break; } } @@ -511,11 +493,13 @@ 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"); cd_media_cd_rom = 1; + cd_media_track_count = 1; + cd_media_track_count_data = 1; return 0; } else { - info(udev, "no current profile, assuming no media\n"); + log_debug("no current profile, assuming no media"); return -1; } }; @@ -524,13 +508,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"); } 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"); } else { cd_media_cd_rom = 1; - info(udev, "profile 0x08 media_cd_rom\n"); + log_debug("profile 0x08 media_cd_rom"); } return 0; } @@ -557,9 +541,9 @@ 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) { - info(udev, "drive is pre-MMC2 and does not support 46h get configuration command\n"); - info(udev, "trying to work around the problem\n"); + 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); } goto out; @@ -567,18 +551,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", 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"); } 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", 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"); len = sizeof(features); } else if (len <= 8) { len = sizeof(features); @@ -598,10 +582,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", 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"); len = sizeof(features); } @@ -613,11 +597,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); - feature_profiles(udev, &features[i]+4, features[i+3]); + log_debug("GET CONFIGURATION: feature 'profiles', with %i entries", features[i+3] / 4); + feature_profiles(udev, &features[i]+4, MIN(features[i+3], len - i - 4)); 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", feature, features[i+3]); break; } } @@ -648,8 +632,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", header[8]); + log_debug("hardware reported media status: %s", media_status[header[2] & 3]); /* exclude plain CDROM, some fake cdroms return 0 for "blank" media here */ if (!cd_media_cd_rom) @@ -666,8 +650,8 @@ static int cd_media_info(struct udev *udev, int fd) * write protected; we need to check the contents if it is blank */ if ((cd_media_dvd_rw_ro || cd_media_dvd_plus_rw || cd_media_dvd_plus_rw_dl || cd_media_dvd_ram) && (header[2] & 3) > 1) { unsigned char buffer[32 * 2048]; - unsigned char result, len; - int block, offset; + unsigned char len; + int offset; if (cd_media_dvd_ram) { /* a write protected dvd-ram may report "complete" status */ @@ -687,7 +671,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"); goto determined; } @@ -704,13 +688,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"); return -1; } switch(format[8] & 3) { case 1: - info(udev, "unformatted DVD-RAM media inserted\n"); + log_debug("unformatted DVD-RAM media inserted"); /* 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 +703,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"); break; case 3: cd_media = 0; //return no media - info(udev, "format capacities returned no media\n"); + log_debug("format capacities returned no media"); return -1; } } @@ -748,22 +732,23 @@ static int cd_media_info(struct udev *udev, int fd) /* if any non-zero data is found in sector 16 (iso and udf) or * eventually 0 (fat32 boot sector, ext2 superblock, etc), disc * is assumed non-blank */ - result = 0; - for (block = 32768; block >= 0 && !result; block -= 32768) { - offset = block; - while (offset < (block + 2048) && !result) { - result = buffer [offset]; - offset++; + for (offset = 32768; offset < (32768 + 2048); offset++) { + if (buffer [offset]) { + log_debug("data in block 16, assuming complete"); + goto determined; } } - if (!result) { - cd_media_state = media_status[0]; - info(udev, "no data in blocks 0 or 16, assuming blank\n"); - } else { - info(udev, "data in blocks 0 or 16, assuming complete\n"); + for (offset = 0; offset < 2048; offset++) { + if (buffer [offset]) { + log_debug("data in block 0, assuming complete"); + goto determined; + } } + + cd_media_state = media_status[0]; + log_debug("no data in blocks 0 or 16, assuming blank"); } determined: @@ -798,7 +783,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", len, header[2], header[3]); if (len > sizeof(toc)) return -1; if (len < 2) @@ -832,7 +817,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", p[2], p[1] & 0x0f, is_data_track ? "data":"audio", block); if (is_data_track) @@ -852,7 +837,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", header[4+2], len); cd_media_session_last_offset = (unsigned long long int)len * 2048; return 0; } @@ -876,13 +861,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; - udev_log_init("cdrom_id"); - udev_set_log_fn(udev, log_fn); - while (1) { int option; @@ -901,17 +886,17 @@ int main(int argc, char *argv[]) eject = true; break; case 'd': - debug = true; - if (udev_get_log_priority(udev) < LOG_INFO) - udev_set_log_priority(udev, LOG_INFO); + log_set_target(LOG_TARGET_CONSOLE); + log_set_max_level(LOG_DEBUG); + log_open(); break; case 'h': printf("Usage: cdrom_id [options] \n" - " --lock-media lock the media (to enable eject request events)\n" - " --unlock-media unlock the media\n" - " --eject-media eject the media\n" - " --debug debug to stderr\n" - " --help print this help text\n\n"); + " -l,--lock-media lock the media (to enable eject request events)\n" + " -u,--unlock-media unlock the media\n" + " -e,--eject-media eject the media\n" + " -d,--debug debug to stderr\n" + " -h,--help print this help text\n\n"); goto exit; default: rc = 1; @@ -921,17 +906,17 @@ int main(int argc, char *argv[]) node = argv[optind]; if (!node) { - err(udev, "no device\n"); + log_error("no device"); fprintf(stderr, "no device\n"); rc = 1; goto exit; } - srand((unsigned int)getpid()); + initialize_srand(); for (cnt = 20; cnt > 0; cnt--) { struct timespec duration; - fd = open(node, O_RDONLY|O_NONBLOCK|(is_mounted(node) ? 0 : O_EXCL)); + fd = open(node, O_RDONLY|O_NONBLOCK|O_CLOEXEC|(is_mounted(node) ? 0 : O_EXCL)); if (fd >= 0 || errno != EBUSY) break; duration.tv_sec = 0; @@ -939,12 +924,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'", node); fprintf(stderr, "unable to open '%s'\n", node); rc = 1; goto exit; } - info(udev, "probing: '%s'\n", node); + log_debug("probing: '%s'", node); /* same data as original cdrom_id */ if (cd_capability_compat(udev, fd) < 0) { @@ -975,19 +960,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)"); media_lock(udev, fd, true); } if (unlock && cd_media) { - info(udev, "PREVENT_ALLOW_MEDIUM_REMOVAL (unlock)\n"); + log_debug("PREVENT_ALLOW_MEDIUM_REMOVAL (unlock)"); media_lock(udev, fd, false); } if (eject) { - info(udev, "PREVENT_ALLOW_MEDIUM_REMOVAL (unlock)\n"); + log_debug("PREVENT_ALLOW_MEDIUM_REMOVAL (unlock)"); media_lock(udev, fd, false); - info(udev, "START_STOP_UNIT (eject)\n"); + log_debug("START_STOP_UNIT (eject)"); media_eject(udev, fd); } @@ -1079,21 +1064,21 @@ work: if (cd_media_state != NULL) printf("ID_CDROM_MEDIA_STATE=%s\n", cd_media_state); if (cd_media_session_next > 0) - printf("ID_CDROM_MEDIA_SESSION_NEXT=%d\n", cd_media_session_next); + printf("ID_CDROM_MEDIA_SESSION_NEXT=%u\n", cd_media_session_next); if (cd_media_session_count > 0) - printf("ID_CDROM_MEDIA_SESSION_COUNT=%d\n", cd_media_session_count); + printf("ID_CDROM_MEDIA_SESSION_COUNT=%u\n", cd_media_session_count); if (cd_media_session_count > 1 && cd_media_session_last_offset > 0) printf("ID_CDROM_MEDIA_SESSION_LAST_OFFSET=%llu\n", cd_media_session_last_offset); if (cd_media_track_count > 0) - printf("ID_CDROM_MEDIA_TRACK_COUNT=%d\n", cd_media_track_count); + printf("ID_CDROM_MEDIA_TRACK_COUNT=%u\n", cd_media_track_count); if (cd_media_track_count_audio > 0) - printf("ID_CDROM_MEDIA_TRACK_COUNT_AUDIO=%d\n", cd_media_track_count_audio); + printf("ID_CDROM_MEDIA_TRACK_COUNT_AUDIO=%u\n", cd_media_track_count_audio); if (cd_media_track_count_data > 0) - printf("ID_CDROM_MEDIA_TRACK_COUNT_DATA=%d\n", cd_media_track_count_data); + printf("ID_CDROM_MEDIA_TRACK_COUNT_DATA=%u\n", cd_media_track_count_data); exit: if (fd >= 0) close(fd); udev_unref(udev); - udev_log_close(); + log_close(); return rc; }