summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaxim <maxim@FreeBSD.org>2002-05-08 07:32:40 +0000
committermaxim <maxim@FreeBSD.org>2002-05-08 07:32:40 +0000
commit04f7d4f048531b483593ed5b17aad39887f3f650 (patch)
treed3af82e04bf575eb6e5c8aa60e66fde6fa4e3756
parentb7a3cfaaab3fd0bf3a27c08457ba479c92532130 (diff)
downloadFreeBSD-src-04f7d4f048531b483593ed5b17aad39887f3f650.zip
FreeBSD-src-04f7d4f048531b483593ed5b17aad39887f3f650.tar.gz
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 <philipp.mergenthaler@stud.uni-karlsruhe.de> Reviewed by: -hackers MFC after: 1 month
-rw-r--r--usr.sbin/cdcontrol/cdcontrol.13
-rw-r--r--usr.sbin/cdcontrol/cdcontrol.c19
2 files changed, 22 insertions, 0 deletions
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 <sys/cdio.h>
+#include <sys/cdrio.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/param.h>
@@ -32,6 +33,7 @@ static const char rcsid[] =
#include <err.h>
#include <errno.h>
#include <histedit.h>
+#include <limits.h>
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
@@ -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,
"<l> <r> | 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 ();
OpenPOWER on IntegriCloud