Diff below makes eject(1) use cd0 as default device like cdio(1) does.

I'm aware this is an arbitrary choice but I see no drawback in having
a default device to eject and this behavior is coherent with cdio(1)'s.

Ok?

Index: mt.c
===================================================================
RCS file: /cvs/src/bin/mt/mt.c,v
retrieving revision 1.35
diff -u -p -r1.35 mt.c
--- mt.c        5 May 2011 19:51:48 -0000       1.35
+++ mt.c        20 May 2012 14:44:56 -0000
@@ -53,6 +53,10 @@
 
 #include "mt.h"
 
+#ifndef DEFAULT_CD_DRIVE
+#  define DEFAULT_CD_DRIVE  "cd0"
+#endif
+
 struct commands {
        char *c_name;
        int c_code;
@@ -148,7 +152,7 @@ main(int argc, char *argv[])
        if (strcmp(progname, "eject") == 0) {
                opts = "t";
                eject = 1;
-               tape = NULL;
+               tape = DEFAULT_CD_DRIVE;
        } else {
                opts = "f:";
                if ((tape = getenv("TAPE")) == NULL)
@@ -180,9 +184,6 @@ main(int argc, char *argv[])
        } else if (argc < 1 || argc > 2)
                usage();
 
-       if (tape == NULL)
-               usage();
-
        if (strchr(tape, ':')) {
 #ifdef RMT
                host = tape;
@@ -315,7 +316,7 @@ void
 usage(void)
 {
        if (eject)
-               (void)fprintf(stderr, "usage: %s [-t] device\n", progname);
+               (void)fprintf(stderr, "usage: %s [-t] [device]\n", progname);
        else
                (void)fprintf(stderr,
                    "usage: %s [-f device] command [count]\n", progname);
Index: mt.1
===================================================================
RCS file: /cvs/src/bin/mt/mt.1,v
retrieving revision 1.28
diff -u -p -r1.28 mt.1
--- mt.1        3 Sep 2010 13:14:55 -0000       1.28
+++ mt.1        20 May 2012 14:24:42 -0000
@@ -44,7 +44,7 @@
 .Op Ar count
 .Nm eject
 .Op Fl t
-.Ar device
+.Op Ar device
 .Sh DESCRIPTION
 The
 .Nm
@@ -74,7 +74,8 @@ with the
 .Cm offline
 command specified.
 .Nm eject
-may also be used to eject other types of removable media.
+may also be used to eject other types of removable media, the default is
+.Pa cd0 .
 .Pp
 The options for
 .Nm
@@ -178,6 +179,8 @@ is not given.
 raw SCSI tape interface
 .It Pa /dev/rmt*
 raw magnetic tape interface
+.It Pa /dev/rcd*
+raw CD drive interface
 .It Pa /usr/src/sys/scsi/scsi_tape.h
 list of SCSI2 density codes
 .El

Reply via email to