userland interface to ATA CD changer devices by Jason Thorpe.

This commit is contained in:
hpeyerl 1998-07-13 12:06:18 +00:00
parent 76735d1493
commit b64bbed230
2 changed files with 89 additions and 7 deletions

View File

@ -1,6 +1,6 @@
.\" $NetBSD: chio.1,v 1.5 1998/05/22 18:27:50 msaitoh Exp $
.\" $NetBSD: chio.1,v 1.6 1998/07/13 12:06:18 hpeyerl Exp $
.\"
.\" Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
.\" Copyright (c) 1996, 1998 Jason R. Thorpe <thorpej@and.com>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@ -30,7 +30,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd April 2, 1996
.Dd July 11, 1998
.Dt CHIO 1
.Os NetBSD
.Sh NAME
@ -195,6 +195,23 @@ Element supports receiving media (importing) from an outside human operator.
Perform an \fBINITIALIZE ELEMENT STATUS\fR
operation on the changer.
.Pp
.Nm
.Ic cdlu
.Ar <sub-command>
.Ar <slot>
.Pp
This command is provided for controlling CD-ROM changer mechanisms which
cannot use the standard changer control interface. ATAPI CD-ROM changers
fall into this category. There are 3 sub-commands:
.Bl -tag -width indent
.It Nm load
Loads the media from the specified slot into the CD-ROM drive.
.It Nm unload
Unloads the media from the CD-ROM drive and returns it to the specified slot.
.It Nm abort
Aborts any pending load or unload operation.
.El
.Pp
.Sh EXAMPLES
.Dl chio move slot 3 drive 0
.Pp
@ -204,6 +221,10 @@ Moves the media in slot 3 (fourth slot) to drive 0 (first drive).
.Pp
Configures the changer to use picker 2 (third picker) for operations.
.Pp
.Dl chio -f /dev/cd0a cdlu load 1
.Pp
Loads the media from slot (second slot) into the CD-ROM drive.
.Pp
.Sh FILES
/dev/ch0 - default changer device
.Sh SEE ALSO

View File

@ -1,7 +1,7 @@
/* $NetBSD: chio.c,v 1.6 1998/01/04 23:53:58 thorpej Exp $ */
/* $NetBSD: chio.c,v 1.7 1998/07/13 12:06:18 hpeyerl Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
* Copyright (c) 1996, 1998 Jason R. Thorpe <thorpej@and.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -37,13 +37,15 @@
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1996 Jason R. Thorpe. All rights reserved.");
__RCSID("$NetBSD: chio.c,v 1.6 1998/01/04 23:53:58 thorpej Exp $");
__COPYRIGHT(
"@(#) Copyright (c) 1996, 1998 Jason R. Thorpe. All rights reserved.");
__RCSID("$NetBSD: chio.c,v 1.7 1998/07/13 12:06:18 hpeyerl Exp $");
#endif
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/chio.h>
#include <sys/cdio.h> /* for ATAPI CD changer; too bad it uses a lame API */
#include <err.h>
#include <errno.h>
#include <fcntl.h>
@ -75,6 +77,7 @@ static int do_getpicker __P((char *, int, char **));
static int do_setpicker __P((char *, int, char **));
static int do_status __P((char *, int, char **));
static int do_ielem __P((char *, int, char **));
static int do_cdlu __P((char *, int, char **));
/* Valid changer element types. */
const struct element_type elements[] = {
@ -95,6 +98,7 @@ const struct changer_command commands[] = {
{ "setpicker", do_setpicker },
{ "status", do_status },
{ "ielem", do_ielem },
{ "cdlu", do_cdlu },
{ NULL, 0 },
};
@ -602,6 +606,62 @@ do_ielem(cname, argc, argv)
return (0);
}
static int
do_cdlu(cname, argc, argv)
char *cname;
int argc;
char **argv;
{
struct ioc_load_unload cmd;
int i;
static const struct special_word cdlu_subcmds[] = {
{ "load", CD_LU_LOAD },
{ "unload", CD_LU_UNLOAD },
{ "abort", CD_LU_ABORT },
{ NULL, 0 },
};
/*
* This command is a little different, since we are mostly dealing
* with ATAPI CD changers, which have a lame API (since ATAPI doesn't
* have LUNs).
*
* We have 3 sub-commands: "load", "unload", and "abort". The
* first two take a slot number. The latter does not.
*/
if (argc < 1 || argc > 2)
goto usage;
for (i = 0; cdlu_subcmds[i].sw_name != NULL; i++) {
if (strcmp(argv[0], cdlu_subcmds[i].sw_name) == 0) {
cmd.options = cdlu_subcmds[i].sw_value;
break;
}
}
if (cdlu_subcmds[i].sw_name == NULL)
goto usage;
if (strcmp(argv[0], "abort") == 0)
cmd.slot = 0;
else
cmd.slot = parse_element_unit(argv[1]);
/*
* XXX Should maybe do something different with the device
* XXX handling for cdlu; think about this some more.
*/
if (ioctl(changer_fd, CDIOCLOADUNLOAD, &cmd))
err(1, "%s: CDIOCLOADUNLOAD", changer_name);
return (0);
usage:
fprintf(stderr, "usage: %s %s load|unload <slot>\n",
__progname, cname);
fprintf(stderr, " %s %s abort\n", __progname, cname);
return (1);
}
static int
parse_element_type(cp)
@ -700,5 +760,6 @@ usage()
(void) fprintf(stderr, "\tchio -f /dev/ch0 move slot 1 drive 0\n");
(void) fprintf(stderr, "\tchio ielem\n");
(void) fprintf(stderr, "\tchio -f /dev/ch1 status\n");
(void) fprintf(stderr, "\tchio -f /dev/cd0a cdlu load 1\n");
exit(1);
}