From 04f7d4f048531b483593ed5b17aad39887f3f650 Mon Sep 17 00:00:00 2001 From: maxim Date: Wed, 8 May 2002 07:32:40 +0000 Subject: Implement 'speed' command: set a maximum read speed. At the moment it works on ATAPI drives only. PR: kern/35512 (a part of) Submitted by: Philipp Mergenthaler Reviewed by: -hackers MFC after: 1 month --- usr.sbin/cdcontrol/cdcontrol.1 | 3 +++ usr.sbin/cdcontrol/cdcontrol.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/usr.sbin/cdcontrol/cdcontrol.1 b/usr.sbin/cdcontrol/cdcontrol.1 index 1a580ae..272fc35 100644 --- a/usr.sbin/cdcontrol/cdcontrol.1 +++ b/usr.sbin/cdcontrol/cdcontrol.1 @@ -155,6 +155,9 @@ Perform the hardware reset of the device. Set minute-second-frame ioctl mode (default). .It Cm set Ar lba Set LBA ioctl mode. +.It Cm speed Ar s +Set the highest speed that the drive should use. The speed is a multiple of +the single speed. This command is currently only supported on ATAPI drives. .It Cm quit Quit the program. .El diff --git a/usr.sbin/cdcontrol/cdcontrol.c b/usr.sbin/cdcontrol/cdcontrol.c index 8bd3f4b..5645039 100644 --- a/usr.sbin/cdcontrol/cdcontrol.c +++ b/usr.sbin/cdcontrol/cdcontrol.c @@ -24,6 +24,7 @@ static const char rcsid[] = #endif /* not lint */ #include +#include #include #include #include @@ -32,6 +33,7 @@ static const char rcsid[] = #include #include #include +#include #include #include #include @@ -73,6 +75,7 @@ static const char rcsid[] = #define CMD_CDID 15 #define CMD_NEXT 16 #define CMD_PREVIOUS 17 +#define CMD_SPEED 18 #define STATUS_AUDIO 0x1 #define STATUS_MEDIA 0x2 #define STATUS_VOLUME 0x4 @@ -105,6 +108,7 @@ struct cmdtab { { CMD_VOLUME, "volume", 1, " | left | right | mute | mono | stereo" }, { CMD_CDID, "cdid", 2, "" }, +{ CMD_SPEED, "speed", 2, "speed" }, { 0, NULL, 0, NULL } }; @@ -277,7 +281,9 @@ int main (int argc, char **argv) int run (int cmd, char *arg) { + long speed; int l, r, rc; + char *ep; switch (cmd) { @@ -425,6 +431,19 @@ int run (int cmd, char *arg) return setvol (l, r); + case CMD_SPEED: + if (fd < 0 && ! open_cd ()) + return (0); + + errno = 0; + speed = strtol(arg, &ep, 10); + if (*ep || ep == arg || speed <= 0 || speed > INT_MAX || + errno != 0) { + warnx("invalid command arguments %s", arg); + return (0); + } + return ioctl(fd, CDRIOCREADSPEED, &speed); + default: case CMD_HELP: help (); -- cgit v1.1