Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/eject Use CDIOCEJECT instead of DIOCEJECT for cdrom ...
details: https://anonhg.NetBSD.org/src/rev/7b3f5e0fe7b7
branches: trunk
changeset: 467531:7b3f5e0fe7b7
user: bouyer <bouyer%NetBSD.org@localhost>
date: Thu Mar 25 16:50:51 1999 +0000
description:
Use CDIOCEJECT instead of DIOCEJECT for cdrom devices (this one allows
opening the tray without media). While I'm there add 'sd' to the
device list (so that I can eject my MO easily).
diffstat:
usr.bin/eject/eject.c | 35 +++++++++++++++++++++--------------
1 files changed, 21 insertions(+), 14 deletions(-)
diffs (101 lines):
diff -r 67e7c10e7657 -r 7b3f5e0fe7b7 usr.bin/eject/eject.c
--- a/usr.bin/eject/eject.c Thu Mar 25 16:46:08 1999 +0000
+++ b/usr.bin/eject/eject.c Thu Mar 25 16:50:51 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: eject.c,v 1.10 1999/02/18 20:02:43 tron Exp $ */
+/* $NetBSD: eject.c,v 1.11 1999/03/25 16:50:51 bouyer Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
#endif /* not lint */
#ifndef lint
-__RCSID("$NetBSD: eject.c,v 1.10 1999/02/18 20:02:43 tron Exp $");
+__RCSID("$NetBSD: eject.c,v 1.11 1999/03/25 16:50:51 bouyer Exp $");
#endif /* not lint */
#include <ctype.h>
@@ -68,6 +68,7 @@
what ioctl to use. */
#define TAPE 0x10
#define DISK 0x20
+#define CDROM 0x40
/* OR one of the above with one of the below: */
#define NOTLOADABLE 0x00
#define LOADABLE 0x01
@@ -76,9 +77,10 @@
{ "diskette", "fd", DISK | NOTLOADABLE },
{ "floppy", "fd", DISK | NOTLOADABLE },
{ "fd", "fd", DISK | NOTLOADABLE },
- { "cdrom", "cd", DISK | LOADABLE },
- { "cd", "cd", DISK | LOADABLE },
- { "mcd", "mcd", DISK | LOADABLE }, /* XXX Is this true? */
+ { "sd", "sd", DISK | NOTLOADABLE },
+ { "cdrom", "cd", CDROM | LOADABLE },
+ { "cd", "cd", CDROM | LOADABLE },
+ { "mcd", "mcd", CDROM | LOADABLE }, /* XXX Is this true? */
{ "tape", "st", TAPE | NOTLOADABLE },
{ "st", "st", TAPE | NOTLOADABLE },
{ "dat", "st", TAPE | NOTLOADABLE },
@@ -94,7 +96,7 @@
} devtypes[] = {
{ "diskette", DISK | NOTLOADABLE },
{ "floppy", DISK | NOTLOADABLE },
- { "cdrom", DISK | LOADABLE },
+ { "cdrom", CDROM | LOADABLE },
{ "disk", DISK | NOTLOADABLE },
{ "tape", TAPE | NOTLOADABLE },
};
@@ -110,7 +112,7 @@
int guess_devtype __P((char *));
char *guess_nickname __P((char *));
void eject_tape __P((char *));
-void eject_disk __P((char *));
+void eject_disk __P((char *, int));
void unmount_dev __P((char *));
int
@@ -192,11 +194,11 @@
if(umount_f)
unmount_dev(devname);
- /* XXX Tapes and disks have different ioctl's: */
+ /* XXX Tapes, cdroms and disks have different ioctl's: */
if((devtype & TYPEMASK) == TAPE)
eject_tape(devname);
else
- eject_disk(devname);
+ eject_disk(devname, devtype & TYPEMASK);
if(verbose_f)
printf("done.\n");
@@ -373,7 +375,7 @@
}
void
-eject_disk(char *name)
+eject_disk(char *name, int type)
{
int fd;
char *dn;
@@ -401,10 +403,15 @@
printf("Ejecting %s...\n", dn);
arg = 0;
- if(ioctl(fd, DIOCLOCK, (char *)&arg) == -1)
- err(1, "ioctl: DIOCLOCK: %s", dn);
- if(ioctl(fd, DIOCEJECT, &arg) == -1)
- err(1, "ioctl: DIOCEJECT: %s", dn);
+ if (type == CDROM) {
+ if(ioctl(fd, CDIOCEJECT, &arg) == -1)
+ err(1, "ioctl: CDIOCEJECT: %s", dn);
+ } else {
+ if(ioctl(fd, DIOCLOCK, (char *)&arg) == -1)
+ err(1, "ioctl: DIOCLOCK: %s", dn);
+ if(ioctl(fd, DIOCEJECT, &arg) == -1)
+ err(1, "ioctl: DIOCEJECT: %s", dn);
+ }
}
close(fd);
Home |
Main Index |
Thread Index |
Old Index