[PATCH] eject: set CD-ROM speed to auto when xargs < 0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



when I execute the following command,
$ ./eject -x -1 -v

I get this output info,
eject: using default device `/dev/sr0'
eject: device name is `/dev/sr0'
eject: /dev/sr0: not mounted
eject: /dev/sr0: is whole-disk device
eject: setting CD-ROM speed to -1X
                               ^^^

Obviously the speed of the CD-ROM cannot be set to a negative number.
Let's auto-correct to auto mode when using negative number as parameter.

With this patch applied, I get this,
eject: using default device `/dev/sr0'
eject: device name is `/dev/sr0'
eject: /dev/sr0: not mounted
eject: /dev/sr0: is whole-disk device
eject: setting CD-ROM speed to auto
                               ^^^

Signed-off-by: Enze Li <lienze@xxxxxxxxxx>
---
 sys-utils/eject.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys-utils/eject.c b/sys-utils/eject.c
index 5cd0beab2..210d5dd66 100644
--- a/sys-utils/eject.c
+++ b/sys-utils/eject.c
@@ -831,9 +831,10 @@ static void set_device_speed(struct eject_control *ctl)
 	if (!ctl->x_option)
 		return;
 
-	if (ctl->x_arg == 0)
+	if (ctl->x_arg <= 0) {
 		verbose(ctl, _("setting CD-ROM speed to auto"));
-	else
+		ctl->x_arg = 0;
+	} else
 		verbose(ctl, _("setting CD-ROM speed to %ldX"), ctl->x_arg);
 
 	open_device(ctl);
-- 
2.35.1




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux