Subject: bin/13087: loadcd -> eject -l [cd]
To: None <gnats-bugs@gnats.netbsd.org>
From: John Franklin <franklin@deathmitten.netbsd.org>
List: netbsd-bugs
Date: 06/02/2001 15:21:10
>Number:         13087
>Category:       bin
>Synopsis:       loadcd -> eject -l [cd]
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Jun 02 12:20:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     John Franklin
>Release:        <NetBSD-current source date>netbsd-current 2 June 01
>Organization:
	
>Environment:
	
System: NetBSD deathmitten 1.5T NetBSD 1.5T (DEATHMITTEN) #1: Sun Mar 25 22:33:19 EST 2001 franklin@deathmitten:/usr/src/sys/arch/i386/compile/DEATHMITTEN i386
Architecture: i386
Machine: i386
>Description:
	
eject -l cd feels counterintuitive.  Wouldn't it be nice to have a program
loadcd that loaded a cd, defaulting to cd0?  I admit, it's trivial, but
so is the patch.
>How-To-Repeat:
	
>Fix:
	
Apply the attached patch to eject:


--- Makefile	1995/10/22 16:48:52	1.2
+++ Makefile	2001/06/02 19:13:08
@@ -2,5 +2,7 @@
 
 PROG=	eject
 SRCS=	eject.c
+LINKS=	${BINDIR}/eject ${BINDIR}/loadcd
+MLINKS=	eject.1 loadcd.1
 
 .include <bsd.prog.mk>
--- eject.1	2001/02/27 19:05:56	1.8
+++ eject.1	2001/06/02 19:13:08
@@ -38,7 +38,8 @@
 .Dt EJECT 1
 .Os
 .Sh NAME
-.Nm eject
+.Nm eject ,
+.Nm loadcd
 .Nd eject a floppy disk, cdrom or tape
 .Sh SYNOPSIS
 .Nm
@@ -62,6 +63,12 @@
 If the medium contains a filesystem that is currently mounted,
 .Nm
 will attempt to unmount the filesystem before ejecting.
+.Pp
+.Nm loadcd
+is equivalent to
+.Nm
+.Fl l
+.Li cd.
 .Pp
 The following options are available:
 .Bl -tag -width xxx
Index: eject.c
--- eject.c	2001/01/21 09:55:40	1.13
+++ eject.c	2001/06/02 19:13:08
@@ -128,7 +128,12 @@
     int devtype = -1;
     int n, i;
     char *devname = NULL;
+    const char *progname = getprogname();
 
+    if(strcmp(progname, "loadcd")==0) {
+	load_f = 1;
+    }
+
     while((ch = getopt(argc, argv, "d:flnt:v")) != -1) {
 	switch(ch) {
 	case 'd':
@@ -174,13 +179,16 @@
 
     if(devname == NULL) {
 	if(argc == 0) {
-	    usage();
-	    /* NOTREACHED */
+	    if(strcmp(progname, "loadcd")==0) {
+	        devname = "cd";
+	    } else {
+		usage();
+		/* NOTREACHED */
+	    }
 	} else
 	    devname = argv[0];
     }
 
-
     if(devtype == -1) {
 	devtype = guess_devtype(devname);
     }
@@ -214,7 +222,8 @@
 void
 usage(void)
 {
-    errx(1, "Usage: eject [-n][-f][-v][-l][-t type][-d] device | nickname");
+    errx(1, "Usage: %s [-n][-f][-v][-l][-t type][-d] device | nickname",
+	getprogname());
 }
 
 int
>Release-Note:
>Audit-Trail:
>Unformatted: