Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Apr 2002 15:10:39 +0400 (MSD)
From:      Maxim Konovalov <maxim@macomnet.ru>
To:        hackers@freebsd.org
Subject:   cdcontrol(1) speed command
Message-ID:  <20020405145853.O45449-100000@news1.macomnet.ru>

next in thread | raw e-mail | index | archive | help

Hello,

Here is a patch for cdcontrol(1) to allow set maximum CD drive speed.
It comes from kern/35512. Are there any comments/objections?

Index: cdcontrol.1
===================================================================
RCS file: /home/ncvs/src/usr.sbin/cdcontrol/cdcontrol.1,v
retrieving revision 1.32
diff -u -r1.32 cdcontrol.1
--- cdcontrol.1	15 Jul 2001 08:01:46 -0000	1.32
+++ cdcontrol.1	27 Mar 2002 10:57:34 -0000
@@ -154,6 +154,9 @@
 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. This command is currently
+only supported on ATAPI drives.
 .It Cm quit
 Quit the program.
 .El
Index: cdcontrol.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/cdcontrol/cdcontrol.c,v
retrieving revision 1.37
diff -u -r1.37 cdcontrol.c
--- cdcontrol.c	18 Feb 2002 20:35:27 -0000	1.37
+++ cdcontrol.c	27 Mar 2002 10:58:12 -0000
@@ -24,6 +24,7 @@
 #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 @@
 #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 @@
 #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 @@
 { 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 run (int cmd, char *arg)
 {
+	long speed;
 	int l, r, rc;
+	char *ep;

 	switch (cmd) {

@@ -424,6 +430,19 @@
 		}

 		return setvol (l, r);
+
+	case CMD_SPEED:
+		if (fd < 0 && ! open_cd ())
+			return (0);
+
+		errno = 0;
+		speed = strtol(arg, &ep, 0);
+		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:

%%%

-- 
Maxim Konovalov, MAcomnet, Internet-Intranet Dept., system engineer
phone: +7 (095) 796-9079, mailto:maxim@macomnet.ru




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020405145853.O45449-100000>