From 1043231f84aacdc04fcc06f3b5463e94f524c1e7 Mon Sep 17 00:00:00 2001 From: eivind Date: Mon, 17 Nov 2003 14:02:04 +0000 Subject: * Auto-detect what device to use if none is specified * Replace references to mcd0 with acd0 (doc only) * Remove references to the "c" partition (doc only - code was already fixed) --- usr.sbin/cdcontrol/cdcontrol.1 | 25 +++++++++++++++++++------ usr.sbin/cdcontrol/cdcontrol.c | 26 ++++++++++++++------------ 2 files changed, 33 insertions(+), 18 deletions(-) (limited to 'usr.sbin/cdcontrol') diff --git a/usr.sbin/cdcontrol/cdcontrol.1 b/usr.sbin/cdcontrol/cdcontrol.1 index a7adfb4..dcf297d 100644 --- a/usr.sbin/cdcontrol/cdcontrol.1 +++ b/usr.sbin/cdcontrol/cdcontrol.1 @@ -19,7 +19,7 @@ The device is a name such as .Pa cd0 or -.Pa mcd0 . +.Pa acd0 . .Pp If no .Ar command @@ -37,15 +37,28 @@ Verbose mode. Print as much information as possible. .It Fl f Ar device Specify a device, such as -.Pa /dev/cd0c +.Pa /dev/cd0 or -.Pa mcd0 . +.Pa acd0 . Both absolute path and relative to .Pa /dev filename are possible. -Suffix -.Pa c -is added to the device name if needed. +The +.Fl f +option overrides +.Ev CDROM . +If neither +.Ev CDROM +nor the +.Fl f +option is specified, +.Nm +tries opening first +.Pa /dev/cdrom , +then +.Pa /dev/cd0 , +and finally +.Pa /dev/acd0 . .El .Pp The available commands are listed below. diff --git a/usr.sbin/cdcontrol/cdcontrol.c b/usr.sbin/cdcontrol/cdcontrol.c index 77230b0..5dd5bd7 100644 --- a/usr.sbin/cdcontrol/cdcontrol.c +++ b/usr.sbin/cdcontrol/cdcontrol.c @@ -48,8 +48,8 @@ __FBSDID("$FreeBSD$"); #define ASTS_ERROR 0x14 /* Audio play operation stopped due to error */ #define ASTS_VOID 0x15 /* No current audio status to return */ -#ifndef DEFAULT_CD_DRIVE -# define DEFAULT_CD_DRIVE "/dev/cd0" +#ifdef DEFAULT_CD_DRIVE +# error "Setting DEFAULT_CD_DRIVE is no longer supported" #endif #define CMD_DEBUG 1 @@ -226,11 +226,6 @@ int main (int argc, char **argv) if (! cdname) cdname = use_cdrom_instead("CDPLAY"); - if (! cdname) { - cdname = DEFAULT_CD_DRIVE; - warnx("no CD device name specified, defaulting to %s", cdname); - } - if (argc > 0) { char buf[80], *p; int len; @@ -1237,14 +1232,21 @@ int open_cd () if (fd > -1) return (1); - if (*cdname == '/') { - snprintf (devbuf, MAXPATHLEN, "%s", cdname); + if (cdname) { + if (*cdname == '/') { + snprintf (devbuf, MAXPATHLEN, "%s", cdname); + } else { + snprintf (devbuf, MAXPATHLEN, "%s%s", _PATH_DEV, cdname); + } + fd = open (devbuf, O_RDONLY); } else { - snprintf (devbuf, MAXPATHLEN, "%s%s", _PATH_DEV, cdname); + fd = open("/dev/cdrom", O_RDONLY); + if (fd < 0 && errno == ENOENT) + fd = open("/dev/cd0", O_RDONLY); + if (fd < 0 && errno == ENOENT) + fd = open("/dev/acd0", O_RDONLY); } - fd = open (devbuf, O_RDONLY); - if (fd < 0) { if (errno == ENXIO) { /* ENXIO has an overloaded meaning here. -- cgit v1.1