summaryrefslogtreecommitdiffstats
path: root/sys-utils/eject.c
diff options
context:
space:
mode:
authorSami Kerola2015-01-07 23:33:09 +0100
committerSami Kerola2015-01-07 23:33:09 +0100
commitc4e8acb9d92336aba81c941578485cf81cb49f7c (patch)
tree21e0e1eb4867dc83ebfabfa696491de14f00b550 /sys-utils/eject.c
parentlibblkid: assume strtoull() is available (diff)
downloadkernel-qcow2-util-linux-c4e8acb9d92336aba81c941578485cf81cb49f7c.tar.gz
kernel-qcow2-util-linux-c4e8acb9d92336aba81c941578485cf81cb49f7c.tar.xz
kernel-qcow2-util-linux-c4e8acb9d92336aba81c941578485cf81cb49f7c.zip
eject: add verbosity to cdrom door lock error
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/eject.c')
-rw-r--r--sys-utils/eject.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/sys-utils/eject.c b/sys-utils/eject.c
index 2114780a3..4f7d6e651 100644
--- a/sys-utils/eject.c
+++ b/sys-utils/eject.c
@@ -335,20 +335,23 @@ static void auto_eject(const struct eject_control *ctl)
}
/*
- * Stops CDROM from opening on manual eject pressing the button.
+ * Stops CDROM from opening on manual eject button press.
* This can be useful when you carry your laptop
* in your bag while it's on and no CD inserted in it's drive.
* Implemented as found in Documentation/ioctl/cdrom.txt
- *
- * TODO: Maybe we should check this also:
- * EDRIVE_CANT_DO_THIS Door lock function not supported.
- * EBUSY Attempt to unlock when multiple users
- * have the drive open and not CAP_SYS_ADMIN
*/
static void manual_eject(const struct eject_control *ctl)
{
- if (ioctl(ctl->fd, CDROM_LOCKDOOR, ctl->i_arg) < 0)
- err(EXIT_FAILURE, _("CD-ROM lock door command failed"));
+ if (ioctl(ctl->fd, CDROM_LOCKDOOR, ctl->i_arg) < 0) {
+ switch (errno) {
+ case EDRIVE_CANT_DO_THIS:
+ errx(EXIT_FAILURE, _("CD-ROM door lock is not supported"));
+ case EBUSY:
+ errx(EXIT_FAILURE, _("other users have the drive open and not CAP_SYS_ADMIN"));
+ default:
+ err(EXIT_FAILURE, _("CD-ROM lock door command failed"));
+ }
+ }
if (ctl->i_arg)
info(_("CD-Drive may NOT be ejected with device button"));