diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-12-24 09:06:50 +0100 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2021-01-08 15:08:38 +0100 |
commit | 138dd9545abf4772803b2df9f1d8bd6cee0a2263 (patch) | |
tree | 81a76ae3cc77386861fbc60d93cc3248ba6f16f2 | |
parent | udev/cdrom: introduce scsi_cmd_run_and_log() (diff) | |
download | systemd-138dd9545abf4772803b2df9f1d8bd6cee0a2263.tar.xz systemd-138dd9545abf4772803b2df9f1d8bd6cee0a2263.zip |
udev/cdrom: make media_lock() return negative errno
-rw-r--r-- | src/udev/cdrom_id/cdrom_id.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c index 186a0a25a1..3419e6ef05 100644 --- a/src/udev/cdrom_id/cdrom_id.c +++ b/src/udev/cdrom_id/cdrom_id.c @@ -212,18 +212,14 @@ static int scsi_cmd_run_and_log(struct scsi_cmd *cmd, int fd, unsigned char *buf } static int media_lock(int fd, bool lock) { - int err; - /* disable the kernel's lock logic */ - err = ioctl(fd, CDROM_CLEAR_OPTIONS, CDO_LOCK); - if (err < 0) - log_debug("CDROM_CLEAR_OPTIONS, CDO_LOCK failed"); + if (ioctl(fd, CDROM_CLEAR_OPTIONS, CDO_LOCK) < 0) + log_debug_errno(errno, "Failed to issue ioctl(CDROM_CLEAR_OPTIONS, CDO_LOCK), ignoring: %m"); - err = ioctl(fd, CDROM_LOCKDOOR, lock ? 1 : 0); - if (err < 0) - log_debug("CDROM_LOCKDOOR failed"); + if (ioctl(fd, CDROM_LOCKDOOR, lock ? 1 : 0) < 0) + return log_debug_errno(errno, "Failed to issue ioctl(CDROM_LOCKDOOR): %m"); - return err; + return 0; } static int media_eject(int fd) { |