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
This commit is contained in:
parent
b7a3cfaaab
commit
04f7d4f048
@ -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
|
||||
|
@ -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 ();
|
||||
|
Loading…
Reference in New Issue
Block a user