From c4e8acb9d92336aba81c941578485cf81cb49f7c Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 7 Jan 2015 22:33:09 +0000 Subject: eject: add verbosity to cdrom door lock error Signed-off-by: Sami Kerola --- sys-utils/eject.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'sys-utils/eject.c') 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")); -- cgit v1.2.3-55-g7522