Permalink
Browse files

This is a merge *on a branch* of all NetBSD ncr.c changes into the

FreeBSD-current (1.123) ncr.c.  It didn't actually solve my '875
problems; we will decide whether to actually use this work later.

	ross-ncr-fb1-123-base		the branch point
	ross-ncr-fb1-123-merge		the branch
  • Loading branch information...
1 parent bc5d29f commit 0e06f3ea193c8a82fc61bb230cc798d95a498940 ross committed Aug 30, 1998
Showing with 0 additions and 19,544 deletions.
  1. +0 −94 Makefile
  2. +0 −8 bin/Makefile
  3. +0 −8 bin/Makefile.inc
  4. +0 −6 bin/cat/Makefile
  5. +0 −123 bin/cat/cat.1
  6. +0 −278 bin/cat/cat.c
  7. +0 −5 bin/chio/Makefile
  8. +0 −237 bin/chio/chio.1
  9. +0 −770 bin/chio/chio.c
  10. +0 −57 bin/chio/defs.h
  11. +0 −35 bin/chio/pathnames.h
  12. +0 −6 bin/chmod/Makefile
  13. +0 −305 bin/chmod/chmod.1
  14. +0 −227 bin/chmod/chmod.c
  15. +0 −7 bin/cp/Makefile
  16. +0 −213 bin/cp/cp.1
  17. +0 −463 bin/cp/cp.c
  18. +0 −58 bin/cp/extern.h
  19. +0 −305 bin/cp/utils.c
  20. +0 −50 bin/csh/Makefile
  21. +0 −10 bin/csh/USD.doc/Makefile
  22. +0 −1,014 bin/csh/USD.doc/csh.1
  23. +0 −1,307 bin/csh/USD.doc/csh.2
  24. +0 −652 bin/csh/USD.doc/csh.3
  25. +0 −180 bin/csh/USD.doc/csh.4
  26. +0 −97 bin/csh/USD.doc/csh.a
  27. +0 −1,723 bin/csh/USD.doc/csh.g
  28. +0 −36 bin/csh/USD.doc/tabs
  29. +0 −132 bin/csh/alloc.c
  30. +0 −318 bin/csh/char.c
  31. +0 −98 bin/csh/char.h
  32. +0 −167 bin/csh/const.c
  33. +0 −2,182 bin/csh/csh.1
  34. +0 −1,391 bin/csh/csh.c
  35. +0 −552 bin/csh/csh.h
  36. +0 −932 bin/csh/dir.c
  37. +0 −47 bin/csh/dir.h
  38. +0 −986 bin/csh/dol.c
  39. +0 −414 bin/csh/err.c
  40. +0 −773 bin/csh/exec.c
  41. +0 −715 bin/csh/exp.c
  42. +0 −338 bin/csh/extern.h
  43. +0 −697 bin/csh/file.c
  44. +0 −1,528 bin/csh/func.c
Sorry, we could not display the entire diff because too many files (23,664) changed.
View
94 Makefile
@@ -1,94 +0,0 @@
-# $NetBSD: Makefile,v 1.63 1998/08/16 17:25:30 tv Exp $
-
-.include <bsd.own.mk> # for configuration variables.
-
-HAVE_GCC28!= ${CXX} --version | egrep "^(2\.8|egcs)" ; echo
-
-# NOTE THAT etc *DOES NOT* BELONG IN THE LIST BELOW
-
-SUBDIR+= lib include bin libexec sbin usr.bin usr.sbin share sys
-
-.if exists(games)
-SUBDIR+= games
-.endif
-
-SUBDIR+= gnu
-# This is needed for libstdc++ and gen-params.
-includes-gnu: includes-include includes-sys
-
-.if exists(domestic) && !defined(EXPORTABLE_SYSTEM)
-SUBDIR+= domestic
-.endif
-
-.if exists(regress)
-.ifmake !(install)
-SUBDIR+= regress
-.endif
-
-regression-tests:
- @echo Running regression tests...
- @(cd ${.CURDIR}/regress && ${MAKE} regress)
-.endif
-
-beforeinstall:
-.ifmake build
- @echo -n "Build started at: "
- @date
-.endif
-.ifndef DESTDIR
- (cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
-.else
- (cd ${.CURDIR}/etc && ${MAKE} distrib-dirs)
-.endif
-
-afterinstall:
-.ifndef NOMAN
- (cd ${.CURDIR}/share/man && ${MAKE} makedb)
-.endif
-
-build: beforeinstall
- (cd ${.CURDIR}/share/mk && ${MAKE} install)
- (cd ${.CURDIR}/share/tmac && ${MAKE} && ${MAKE} install)
-.if !defined(UPDATE)
- ${MAKE} cleandir
-.endif
- ${MAKE} includes
- (cd ${.CURDIR}/lib/csu && \
- ${MAKE} depend && NOMAN= ${MAKE} && NOMAN= ${MAKE} install)
- (cd ${.CURDIR}/lib && \
- ${MAKE} depend && NOMAN= ${MAKE} && NOMAN= ${MAKE} install)
- (cd ${.CURDIR}/gnu/lib && \
- ${MAKE} depend && NOMAN= ${MAKE} && NOMAN= ${MAKE} install)
-.if defined(USE_EGCS)
-# (cd ${.CURDIR}/gnu/usr.bin/egcs/libgcc && \
-# ${MAKE} depend && NOMAN= ${MAKE} && NOMAN= ${MAKE} install)
-.else
-.if (${MACHINE_ARCH} != "alpha") && \
- (${MACHINE_ARCH} != "powerpc")
- (cd ${.CURDIR}/gnu/usr.bin/gcc/libgcc && \
- ${MAKE} depend && NOMAN= ${MAKE} && NOMAN= ${MAKE} install)
-.endif
-.endif
-.if exists(domestic) && !defined(EXPORTABLE_SYSTEM)
-# libtelnet depends on libdes and libkrb. libkrb depends on
-# libcom_err.
-.if exists(domestic/lib/libdes)
- (cd ${.CURDIR}/domestic/lib/libdes && \
- ${MAKE} depend && NOMAN= ${MAKE} && NOMAN= ${MAKE} install)
-.endif
-.if exists(domestic/lib/libcom_err)
- (cd ${.CURDIR}/domestic/lib/libcom_err && \
- ${MAKE} depend && NOMAN= ${MAKE} && NOMAN= ${MAKE} install)
-.endif
-.if exists(domestic/lib/libkrb)
- (cd ${.CURDIR}/domestic/lib/libkrb && \
- ${MAKE} depend && NOMAN= ${MAKE} && NOMAN= ${MAKE} install)
-.endif
- (cd ${.CURDIR}/domestic/lib && \
- ${MAKE} depend && NOMAN= ${MAKE} && NOMAN= ${MAKE} install)
-.endif
- ${MAKE} depend && ${MAKE} && ${MAKE} install
- @echo -n "Build finished at: "
- @date
-
-.include <bsd.subdir.mk>
View
8 bin/Makefile
@@ -1,8 +0,0 @@
-# $NetBSD: Makefile,v 1.16 1997/05/29 21:06:11 veego Exp $
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-
-SUBDIR= cat chio chmod cp csh date dd df domainname echo ed expr hostname \
- kill ksh ln ls mkdir mt mv pax ps pwd rcp rcmd rm rmdir sh \
- sleep stty sync test
-
-.include <bsd.subdir.mk>
View
8 bin/Makefile.inc
@@ -1,8 +0,0 @@
-# $NetBSD: Makefile.inc,v 1.10 1998/03/02 22:03:11 cgd Exp $
-# @(#)Makefile.inc 8.1 (Berkeley) 5/31/93
-
-.include <bsd.own.mk> # for LDSTATIC def'n
-
-WARNS?= 1
-BINDIR?= /bin
-LDSTATIC?= -static
View
6 bin/cat/Makefile
@@ -1,6 +0,0 @@
-# $NetBSD: Makefile,v 1.8 1997/07/20 22:36:26 christos Exp $
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-
-PROG= cat
-
-.include <bsd.prog.mk>
View
123 bin/cat/cat.1
@@ -1,123 +0,0 @@
-.\" $NetBSD: cat.1,v 1.14 1998/04/28 06:00:51 fair Exp $
-.\"
-.\" Copyright (c) 1989, 1990, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" the Institute of Electrical and Electronics Engineers, Inc.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)cat.1 8.3 (Berkeley) 5/2/95
-.\"
-.Dd May 2, 1995
-.Dt CAT 1
-.Os BSD 3
-.Sh NAME
-.Nm cat
-.Nd concatenate and print files
-.Sh SYNOPSIS
-.Nm
-.Op Fl benstuv
-.Op Fl
-.Op Ar
-.Sh DESCRIPTION
-The
-.Nm
-utility reads files sequentially, writing them to the standard output.
-The
-.Ar file
-operands are processed in command line order.
-A single dash represents the standard input.
-.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl b
-Implies the
-.Fl n
-option but doesn't number blank lines.
-.It Fl e
-Implies the
-.Fl v
-option, and displays a dollar sign
-.Pq Ql \&$
-at the end of each line
-as well.
-.It Fl n
-Number the output lines, starting at 1.
-.It Fl s
-Squeeze multiple adjacent empty lines, causing the output to be
-single spaced.
-.It Fl t
-Implies the
-.Fl v
-option, and displays tab characters as
-.Ql ^I
-as well.
-.It Fl u
-The
-.Fl u
-option guarantees that the output is unbuffered.
-.It Fl v
-Displays non-printing characters so they are visible.
-Control characters print as
-.Ql ^X
-for control-X; the delete
-character (octal 0177) prints as
-.Ql ^?
-Non-ascii characters (with the high bit set) are printed as
-.Ql M-
-(for meta) followed by the character for the low 7 bits.
-.El
-.Pp
-The
-.Nm
-utility exits 0 on success, and >0 if an error occurs.
-.Sh BUGS
-Because of the shell language mechanism used to perform output
-redirection, the command
-.Dq Li cat file1 file2 > file1
-will cause the original data in file1 to be destroyed!
-.Sh SEE ALSO
-.Xr head 1 ,
-.Xr more 1 ,
-.Xr pr 1 ,
-.Xr tail 1 ,
-.Xr vis 1
-.Rs
-.%A Rob Pike
-.%T "UNIX Style, or cat -v Considered Harmful"
-.%J "USENIX Summer Conference Proceedings"
-.%D 1983
-.Re
-.Sh HISTORY
-A
-.Nm
-utility appeared in
-.At v6 .
View
278 bin/cat/cat.c
@@ -1,278 +0,0 @@
-/* $NetBSD: cat.c,v 1.18 1998/07/28 05:31:22 mycroft Exp $ */
-
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Kevin Fall.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#ifndef lint
-__COPYRIGHT(
-"@(#) Copyright (c) 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n");
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
-#else
-__RCSID("$NetBSD: cat.c,v 1.18 1998/07/28 05:31:22 mycroft Exp $");
-#endif
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-
-#include <locale.h>
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-int bflag, eflag, nflag, sflag, tflag, vflag;
-int rval;
-char *filename;
-
-int main __P((int, char *[]));
-void cook_args __P((char *argv[]));
-void cook_buf __P((FILE *));
-void raw_args __P((char *argv[]));
-void raw_cat __P((int));
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- extern int optind;
- int ch;
-
- (void)setlocale(LC_ALL, "");
-
- while ((ch = getopt(argc, argv, "benstuv")) != -1)
- switch (ch) {
- case 'b':
- bflag = nflag = 1; /* -b implies -n */
- break;
- case 'e':
- eflag = vflag = 1; /* -e implies -v */
- break;
- case 'n':
- nflag = 1;
- break;
- case 's':
- sflag = 1;
- break;
- case 't':
- tflag = vflag = 1; /* -t implies -v */
- break;
- case 'u':
- setbuf(stdout, (char *)NULL);
- break;
- case 'v':
- vflag = 1;
- break;
- default:
- case '?':
- (void)fprintf(stderr,
- "usage: cat [-benstuv] [-] [file ...]\n");
- exit(1);
- /* NOTREACHED */
- }
- argv += optind;
-
- if (bflag || eflag || nflag || sflag || tflag || vflag)
- cook_args(argv);
- else
- raw_args(argv);
- if (fclose(stdout))
- err(1, "stdout");
- exit(rval);
- /* NOTREACHED */
-}
-
-void
-cook_args(argv)
- char **argv;
-{
- FILE *fp;
-
- fp = stdin;
- filename = "stdin";
- do {
- if (*argv) {
- if (!strcmp(*argv, "-"))
- fp = stdin;
- else if ((fp = fopen(*argv, "r")) == NULL) {
- warn("%s", *argv);
- rval = 1;
- ++argv;
- continue;
- }
- filename = *argv++;
- }
- cook_buf(fp);
- if (fp != stdin)
- (void)fclose(fp);
- } while (*argv);
-}
-
-void
-cook_buf(fp)
- FILE *fp;
-{
- int ch, gobble, line, prev;
-
- line = gobble = 0;
- for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) {
- if (prev == '\n') {
- if (ch == '\n') {
- if (sflag) {
- if (!gobble && putchar(ch) == EOF)
- break;
- gobble = 1;
- continue;
- }
- if (nflag) {
- if (!bflag) {
- (void)fprintf(stdout,
- "%6d\t", ++line);
- if (ferror(stdout))
- break;
- } else if (eflag) {
- (void)fprintf(stdout,
- "%6s\t", "");
- if (ferror(stdout))
- break;
- }
- }
- } else if (nflag) {
- (void)fprintf(stdout, "%6d\t", ++line);
- if (ferror(stdout))
- break;
- }
- }
- gobble = 0;
- if (ch == '\n') {
- if (eflag)
- if (putchar('$') == EOF)
- break;
- } else if (ch == '\t') {
- if (tflag) {
- if (putchar('^') == EOF || putchar('I') == EOF)
- break;
- continue;
- }
- } else if (vflag) {
- if (!isascii(ch)) {
- if (putchar('M') == EOF || putchar('-') == EOF)
- break;
- ch = toascii(ch);
- }
- if (iscntrl(ch)) {
- if (putchar('^') == EOF ||
- putchar(ch == '\177' ? '?' :
- ch | 0100) == EOF)
- break;
- continue;
- }
- }
- if (putchar(ch) == EOF)
- break;
- }
- if (ferror(fp)) {
- warn("%s", filename);
- rval = 1;
- clearerr(fp);
- }
- if (ferror(stdout))
- err(1, "stdout");
-}
-
-void
-raw_args(argv)
- char **argv;
-{
- int fd;
-
- fd = fileno(stdin);
- filename = "stdin";
- do {
- if (*argv) {
- if (!strcmp(*argv, "-"))
- fd = fileno(stdin);
- else if ((fd = open(*argv, O_RDONLY, 0)) < 0) {
- warn("%s", *argv);
- rval = 1;
- ++argv;
- continue;
- }
- filename = *argv++;
- }
- raw_cat(fd);
- if (fd != fileno(stdin))
- (void)close(fd);
- } while (*argv);
-}
-
-void
-raw_cat(rfd)
- int rfd;
-{
- int nr, nw, off, wfd;
- static int bsize;
- static char *buf;
- struct stat sbuf;
-
- wfd = fileno(stdout);
- if (buf == NULL) {
- if (fstat(wfd, &sbuf))
- err(1, "%s", filename);
- bsize = MAX(sbuf.st_blksize, 1024);
- if ((buf = malloc((u_int)bsize)) == NULL)
- err(1, "cannot allocate buffer");
- }
- while ((nr = read(rfd, buf, (u_int)bsize)) > 0)
- for (off = 0; nr; nr -= nw, off += nw)
- if ((nw = write(wfd, buf + off, (u_int)nr)) < 0)
- err(1, "stdout");
- if (nr < 0) {
- warn("%s", filename);
- rval = 1;
- }
-}
View
5 bin/chio/Makefile
@@ -1,5 +0,0 @@
-# $NetBSD: Makefile,v 1.4 1997/07/20 22:36:31 christos Exp $
-
-PROG= chio
-
-.include <bsd.prog.mk>
View
237 bin/chio/chio.1
@@ -1,237 +0,0 @@
-.\" $NetBSD: chio.1,v 1.6 1998/07/13 12:06:18 hpeyerl Exp $
-.\"
-.\" Copyright (c) 1996, 1998 Jason R. Thorpe <thorpej@and.com>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgements:
-.\" This product includes software developed by Jason R. Thorpe
-.\" for And Communications, http://www.and.com/
-.\" 4. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.Dd July 11, 1998
-.Dt CHIO 1
-.Os NetBSD
-.Sh NAME
-.Nm chio
-.Nd medium changer control utility
-.Sh SYNOPSIS
-.Nm
-.Op Fl f Ar changer
-.Ar command
-.Ar arg1
-.Ar arg2
-.Oo
-.Ar arg3 Oo ...
-.Oc
-.Oc
-.Sh DESCRIPTION
-.Nm
-is used to control the operation of medium changers, such as those found
-in tape and optical disk jukeboxes.
-.Pp
-The options are as follows:
-.Bl -tag -width indent
-.It Fl f Ar changer
-Use the device
-.Pa changer
-rather than the default device
-.Pa /dev/ch0 .
-.El
-.Pp
-The default changer may be overridden by setting the environment variable
-.Ev CHANGER
-to the desired changer device.
-.Pp
-A medium changer apparatus is made up of
-.Pa elements .
-There are four element types:
-.Pa picker
-(medium transport),
-.Pa slot
-(storage),
-.Pa portal
-(import/export), and
-.Pa drive
-(data transfer). In this command description, the shorthand
-.Ic ET
-will be used to represent an element type, and
-.Ic EU
-will be used to represent an element unit. For example, to represent
-the first robotic arm in the changer, the ET would be
-.Dq picker
-and the EU would be
-.Dq 0 .
-.Pp
-.Sh SUPPORTED COMMANDS
-.Nm
-.Ic move
-.Ar <from ET> <from EU> <to ET> <to EU>
-.Op Ar inv
-.Pp
-Moves the media unit from
-.Pa <from ET/EU>
-to
-.Pa <to ET/EU> .
-If the optional modifier
-.Pa inv
-is specified, the media unit will be inverted before insertion.
-.Pp
-.Nm
-.Ic exchange
-.Ar <src ET> <src EU> <dst1 ET> <dst1 EU>
-.Op Ar <dst2 ET> <dst2 ET>
-.Op Ar inv1
-.Op Ar inv2
-.Pp
-Performs a media unit exchange operation. The media unit in
-.Pa <src ET/EU>
-is moved to
-.Pa <dst1 ET/EU>
-and the media unit previously in
-.Pa <dst1 ET/EU>
-is moved to
-.Pa <dst2 ET/EU> .
-In the case of a simple exchange,
-.Pa <dst2 ET/EU>
-is omitted and the values
-.Pa <src ET/EU>
-are used in their place.
-The optional modifiers
-.Pa inv1
-and
-.Pa inv2
-specify whether the media units are to be inverted before insertion into
-.Pa <dst1 ET/EU>
-and
-.Pa <dst2 ET/EU>
-respectively.
-.Pp
-Note that not all medium changers support the
-.Ic exchange
-operation; The changer must have multiple free pickers or emulate
-multiple free pickers with transient storage.
-.Pp
-.Nm
-.Ic position
-.Ar <to ET> <to EU>
-.Op Ar inv
-.Pp
-Position the picker in front of the element described by
-.Pa <to ET/EU> .
-If the optional modifier
-.Pa inv
-is specified, the media unit will be inverted before insertion.
-.Pp
-Note that not all changers behave as expected when issued this command.
-.Pp
-.Nm
-.Ic params
-.Pp
-Report the number of slots, drives, pickers, and portals in the changer,
-and which picker unit the changer is currently configured to use.
-.Pp
-.Nm
-.Ic getpicker
-.Pp
-Report which picker unit the changer is currently configured to use.
-.Pp
-.Nm
-.Ic setpicker
-.Ar <unit>
-.Pp
-Configure the changer to use picker
-.Pa <unit> .
-.Pp
-.Nm
-.Ic status
-.Op Ar <type>
-.Pp
-Report the status of all elements in the changer. If
-.Pa <type>
-is specified, report the status of all elements of type
-.Pa <type> .
-.Pp
-The status bits are defined as follows:
-.Bl -tag -width indent
-.It Nm FULL
-Element contains a media unit.
-.It Nm IMPEXP
-Media was deposited into element by an outside human operator.
-.It Nm EXCEPT
-Element is in an abnormal state.
-.It Nm ACCESS
-Media in this element is accessible by a picker.
-.It Nm EXENAB
-Element supports passing media (exporting) to an outside human operator.
-.It Nm INENAB
-Element supports receiving media (importing) from an outside human operator.
-.El
-.Pp
-.Nm
-.Ic ielem
-.Pp
-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
-Moves the media in slot 3 (fourth slot) to drive 0 (first drive).
-.Pp
-.Dl chio setpicker 2
-.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
-.Xr mt 1 ,
-.Xr mount 8
-.Sh AUTHOR
-The
-.Nm
-program and SCSI changer driver were written by Jason R. Thorpe
-<thorpej@and.com> for And Communications, http://www.and.com/
View
770 bin/chio/chio.c
@@ -1,770 +0,0 @@
-/* $NetBSD: chio.c,v 1.10 1998/07/28 05:31:22 mycroft Exp $ */
-
-/*
- * Copyright (c) 1996, 1998 Jason R. Thorpe <thorpej@and.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgements:
- * This product includes software developed by Jason R. Thorpe
- * for And Communications, http://www.and.com/
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-/*
- * Additional Copyright (c) 1997, by Matthew Jacob, for NASA/Ames Research Ctr.
- */
-
-#include <sys/cdefs.h>
-#ifndef lint
-__COPYRIGHT(
- "@(#) Copyright (c) 1996, 1998 Jason R. Thorpe. All rights reserved.");
-__RCSID("$NetBSD: chio.c,v 1.10 1998/07/28 05:31:22 mycroft 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>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "defs.h"
-#include "pathnames.h"
-
-extern char *__progname; /* from crt0.o */
-
-int main __P((int, char *[]));
-static void usage __P((void));
-static void cleanup __P((void));
-static int parse_element_type __P((char *));
-static int parse_element_unit __P((char *));
-static int parse_special __P((char *));
-static int is_special __P((char *));
-static const char *bits_to_string __P((int, const char *));
-
-static int do_move __P((char *, int, char **));
-static int do_exchange __P((char *, int, char **));
-static int do_position __P((char *, int, char **));
-static int do_params __P((char *, int, char **));
-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[] = {
- { "picker", CHET_MT },
- { "slot", CHET_ST },
- { "portal", CHET_IE },
- { "drive", CHET_DT },
- { NULL, 0 },
-};
-
-/* Valid commands. */
-const struct changer_command commands[] = {
- { "move", do_move },
- { "exchange", do_exchange },
- { "position", do_position },
- { "params", do_params },
- { "getpicker", do_getpicker },
- { "setpicker", do_setpicker },
- { "status", do_status },
- { "ielem", do_ielem },
- { "cdlu", do_cdlu },
- { NULL, 0 },
-};
-
-/* Valid special words. */
-const struct special_word specials[] = {
- { "inv", SW_INVERT },
- { "inv1", SW_INVERT1 },
- { "inv2", SW_INVERT2 },
- { NULL, 0 },
-};
-
-static int changer_fd;
-static const char *changer_name;
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- int ch, i;
-
- while ((ch = getopt(argc, argv, "f:")) != -1) {
- switch (ch) {
- case 'f':
- changer_name = optarg;
- break;
-
- default:
- usage();
- }
- }
- argc -= optind;
- argv += optind;
-
- if (argc == 0)
- usage();
-
- /* Get the default changer if not already specified. */
- if (changer_name == NULL)
- if ((changer_name = getenv(CHANGER_ENV_VAR)) == NULL)
- changer_name = _PATH_CH;
-
- /* Open the changer device. */
- if ((changer_fd = open(changer_name, O_RDWR, 0600)) == -1)
- err(1, "%s: open", changer_name);
-
- /* Register cleanup function. */
- if (atexit(cleanup))
- err(1, "can't register cleanup function");
-
- /* Find the specified command. */
- for (i = 0; commands[i].cc_name != NULL; ++i)
- if (strcmp(*argv, commands[i].cc_name) == 0)
- break;
- if (commands[i].cc_name == NULL)
- errx(1, "unknown command: %s", *argv);
-
- /* Skip over the command name and call handler. */
- ++argv; --argc;
- exit ((*commands[i].cc_handler)(commands[i].cc_name, argc, argv));
- /* NOTREACHED */
-}
-
-static int
-do_move(cname, argc, argv)
- char *cname;
- int argc;
- char **argv;
-{
- struct changer_move cmd;
- int val;
-
- /*
- * On a move command, we expect the following:
- *
- * <from ET> <from EU> <to ET> <to EU> [inv]
- *
- * where ET == element type and EU == element unit.
- */
- if (argc < 4) {
- warnx("%s: too few arguments", cname);
- goto usage;
- } else if (argc > 5) {
- warnx("%s: too many arguments", cname);
- goto usage;
- }
- (void) memset(&cmd, 0, sizeof(cmd));
-
- /* <from ET> */
- cmd.cm_fromtype = parse_element_type(*argv);
- ++argv; --argc;
-
- /* <from EU> */
- cmd.cm_fromunit = parse_element_unit(*argv);
- ++argv; --argc;
-
- /* <to ET> */
- cmd.cm_totype = parse_element_type(*argv);
- ++argv; --argc;
-
- /* <to EU> */
- cmd.cm_tounit = parse_element_unit(*argv);
- ++argv; --argc;
-
- /* Deal with optional command modifier. */
- if (argc) {
- val = parse_special(*argv);
- switch (val) {
- case SW_INVERT:
- cmd.cm_flags |= CM_INVERT;
- break;
-
- default:
- errx(1, "%s: inappropriate modifier `%s'",
- cname, *argv);
- /* NOTREACHED */
- }
- }
-
- /* Send command to changer. */
- if (ioctl(changer_fd, CHIOMOVE, &cmd))
- err(1, "%s: CHIOMOVE", changer_name);
-
- return (0);
-
- usage:
- (void) fprintf(stderr, "usage: %s %s "
- "<from ET> <from EU> <to ET> <to EU> [inv]\n", __progname, cname);
- return (1);
-}
-
-static int
-do_exchange(cname, argc, argv)
- char *cname;
- int argc;
- char **argv;
-{
- struct changer_exchange cmd;
- int val;
-
- /*
- * On an exchange command, we expect the following:
- *
- * <src ET> <src EU> <dst1 ET> <dst1 EU> [<dst2 ET> <dst2 EU>] [inv1] [inv2]
- *
- * where ET == element type and EU == element unit.
- */
- if (argc < 4) {
- warnx("%s: too few arguments", cname);
- goto usage;
- } else if (argc > 8) {
- warnx("%s: too many arguments", cname);
- goto usage;
- }
- (void) memset(&cmd, 0, sizeof(cmd));
-
- /* <src ET> */
- cmd.ce_srctype = parse_element_type(*argv);
- ++argv; --argc;
-
- /* <src EU> */
- cmd.ce_srcunit = parse_element_unit(*argv);
- ++argv; --argc;
-
- /* <dst1 ET> */
- cmd.ce_fdsttype = parse_element_type(*argv);
- ++argv; --argc;
-
- /* <dst1 EU> */
- cmd.ce_fdstunit = parse_element_unit(*argv);
- ++argv; --argc;
-
- /*
- * If the next token is a special word or there are no more
- * arguments, then this is a case of simple exchange.
- * dst2 == src.
- */
- if ((argc == 0) || is_special(*argv)) {
- cmd.ce_sdsttype = cmd.ce_srctype;
- cmd.ce_sdstunit = cmd.ce_srcunit;
- goto do_special;
- }
-
- /* <dst2 ET> */
- cmd.ce_sdsttype = parse_element_type(*argv);
- ++argv; --argc;
-
- /* <dst2 EU> */
- cmd.ce_sdstunit = parse_element_unit(*argv);
- ++argv; --argc;
-
- do_special:
- /* Deal with optional command modifiers. */
- while (argc) {
- val = parse_special(*argv);
- ++argv; --argc;
- switch (val) {
- case SW_INVERT1:
- cmd.ce_flags |= CE_INVERT1;
- break;
-
- case SW_INVERT2:
- cmd.ce_flags |= CE_INVERT2;
- break;
-
- default:
- errx(1, "%s: inappropriate modifier `%s'",
- cname, *argv);
- /* NOTREACHED */
- }
- }
-
- /* Send command to changer. */
- if (ioctl(changer_fd, CHIOEXCHANGE, &cmd))
- err(1, "%s: CHIOEXCHANGE", changer_name);
-
- return (0);
-
- usage:
- (void) fprintf(stderr,
- "usage: %s %s <src ET> <src EU> <dst1 ET> <dst1 EU>\n"
- " [<dst2 ET> <dst2 EU>] [inv1] [inv2]\n",
- __progname, cname);
- return (1);
-}
-
-static int
-do_position(cname, argc, argv)
- char *cname;
- int argc;
- char **argv;
-{
- struct changer_position cmd;
- int val;
-
- /*
- * On a position command, we expect the following:
- *
- * <to ET> <to EU> [inv]
- *
- * where ET == element type and EU == element unit.
- */
- if (argc < 2) {
- warnx("%s: too few arguments", cname);
- goto usage;
- } else if (argc > 3) {
- warnx("%s: too many arguments", cname);
- goto usage;
- }
- (void) memset(&cmd, 0, sizeof(cmd));
-
- /* <to ET> */
- cmd.cp_type = parse_element_type(*argv);
- ++argv; --argc;
-
- /* <to EU> */
- cmd.cp_unit = parse_element_unit(*argv);
- ++argv; --argc;
-
- /* Deal with optional command modifier. */
- if (argc) {
- val = parse_special(*argv);
- switch (val) {
- case SW_INVERT:
- cmd.cp_flags |= CP_INVERT;
- break;
-
- default:
- errx(1, "%s: inappropriate modifier `%s'",
- cname, *argv);
- /* NOTREACHED */
- }
- }
-
- /* Send command to changer. */
- if (ioctl(changer_fd, CHIOPOSITION, &cmd))
- err(1, "%s: CHIOPOSITION", changer_name);
-
- return (0);
-
- usage:
- (void) fprintf(stderr, "usage: %s %s <to ET> <to EU> [inv]\n",
- __progname, cname);
- return (1);
-}
-
-/* ARGSUSED */
-static int
-do_params(cname, argc, argv)
- char *cname;
- int argc;
- char **argv;
-{
- struct changer_params data;
-
- /* No arguments to this command. */
- if (argc) {
- warnx("%s: no arguements expected", cname);
- goto usage;
- }
-
- /* Get params from changer and display them. */
- (void) memset(&data, 0, sizeof(data));
- if (ioctl(changer_fd, CHIOGPARAMS, &data))
- err(1, "%s: CHIOGPARAMS", changer_name);
-
- (void) printf("%s: %d slot%s, %d drive%s, %d picker%s",
- changer_name,
- data.cp_nslots, (data.cp_nslots > 1) ? "s" : "",
- data.cp_ndrives, (data.cp_ndrives > 1) ? "s" : "",
- data.cp_npickers, (data.cp_npickers > 1) ? "s" : "");
- if (data.cp_nportals)
- (void) printf(", %d portal%s", data.cp_nportals,
- (data.cp_nportals > 1) ? "s" : "");
- (void) printf("\n%s: current picker: %d\n", changer_name,
- data.cp_curpicker);
-
- return (0);
-
- usage:
- (void) fprintf(stderr, "usage: %s %s\n", __progname, cname);
- return (1);
-}
-
-/* ARGSUSED */
-static int
-do_getpicker(cname, argc, argv)
- char *cname;
- int argc;
- char **argv;
-{
- int picker;
-
- /* No arguments to this command. */
- if (argc) {
- warnx("%s: no arguments expected", cname);
- goto usage;
- }
-
- /* Get current picker from changer and display it. */
- if (ioctl(changer_fd, CHIOGPICKER, &picker))
- err(1, "%s: CHIOGPICKER", changer_name);
-
- (void) printf("%s: current picker: %d\n", changer_name, picker);
-
- return (0);
-
- usage:
- (void) fprintf(stderr, "usage: %s %s\n", __progname, cname);
- return (1);
-}
-
-static int
-do_setpicker(cname, argc, argv)
- char *cname;
- int argc;
- char **argv;
-{
- int picker;
-
- if (argc < 1) {
- warnx("%s: too few arguments", cname);
- goto usage;
- } else if (argc > 1) {
- warnx("%s: too many arguments", cname);
- goto usage;
- }
-
- picker = parse_element_unit(*argv);
-
- /* Set the changer picker. */
- if (ioctl(changer_fd, CHIOSPICKER, &picker))
- err(1, "%s: CHIOSPICKER", changer_name);
-
- return (0);
-
- usage:
- (void) fprintf(stderr, "usage: %s %s <picker>\n", __progname, cname);
- return (1);
-}
-
-static int
-do_status(cname, argc, argv)
- char *cname;
- int argc;
- char **argv;
-{
- struct changer_element_status cmd;
- struct changer_params data;
- u_int8_t *statusp;
- int i, chet, schet, echet;
- size_t count;
- char *description;
-
- /*
- * On a status command, we expect the following:
- *
- * [<ET>]
- *
- * where ET == element type.
- *
- * If we get no arguments, we get the status of all
- * known element types.
- */
- if (argc > 1) {
- warnx("%s: too many arguments", cname);
- goto usage;
- }
-
- /*
- * Get params from changer. Specifically, we need the element
- * counts.
- */
- (void) memset(&data, 0, sizeof(data));
- if (ioctl(changer_fd, CHIOGPARAMS, &data))
- err(1, "%s: CHIOGPARAMS", changer_name);
-
- if (argc)
- schet = echet = parse_element_type(*argv);
- else {
- schet = CHET_MT;
- echet = CHET_DT;
- }
-
- for (chet = schet; chet <= echet; ++chet) {
- switch (chet) {
- case CHET_MT:
- count = data.cp_npickers;
- description = "picker";
- break;
-
- case CHET_ST:
- count = data.cp_nslots;
- description = "slot";
- break;
-
- case CHET_IE:
- count = data.cp_nportals;
- description = "portal";
- break;
-
- case CHET_DT:
- count = data.cp_ndrives;
- description = "drive";
- break;
-
- default:
- /* To appease gcc -Wuninitialized. */
- count = 0;
- description = NULL;
- }
-
- if (count == 0) {
- if (argc == 0)
- continue;
- else {
- (void) printf("%s: no %s elements\n",
- changer_name, description);
- return (0);
- }
- }
-
- /* Allocate storage for the status bytes. */
- if ((statusp = (u_int8_t *)malloc(count)) == NULL)
- errx(1, "can't allocate status storage");
-
- (void) memset(statusp, 0, count);
- (void) memset(&cmd, 0, sizeof(cmd));
-
- cmd.ces_type = chet;
- cmd.ces_data = statusp;
-
- if (ioctl(changer_fd, CHIOGSTATUS, &cmd)) {
- free(statusp);
- err(1, "%s: CHIOGSTATUS", changer_name);
- }
-
- /* Dump the status for each element of this type. */
- for (i = 0; i < count; ++i) {
- (void) printf("%s %d: %s\n", description, i,
- bits_to_string(statusp[i], CESTATUS_BITS));
- }
-
- free(statusp);
- }
-
- return (0);
-
- usage:
- (void) fprintf(stderr, "usage: %s %s [<element type>]\n", __progname,
- cname);
- return (1);
-}
-
-/* ARGSUSED */
-static int
-do_ielem(cname, argc, argv)
- char *cname;
- int argc;
- char **argv;
-{
- if (ioctl(changer_fd, CHIOIELEM, NULL))
- err(1, "%s: CHIOIELEM", changer_name);
-
- 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:
- (void) fprintf(stderr, "usage: %s %s load|unload <slot>\n",
- __progname, cname);
- (void) fprintf(stderr, " %s %s abort\n", __progname, cname);
- return (1);
-}
-
-static int
-parse_element_type(cp)
- char *cp;
-{
- int i;
-
- for (i = 0; elements[i].et_name != NULL; ++i)
- if (strcmp(elements[i].et_name, cp) == 0)
- return (elements[i].et_type);
-
- errx(1, "invalid element type `%s'", cp);
- /* NOTREACHED */
-}
-
-static int
-parse_element_unit(cp)
- char *cp;
-{
- int i;
- char *p;
-
- i = (int)strtol(cp, &p, 10);
- if ((i < 0) || (*p != '\0'))
- errx(1, "invalid unit number `%s'", cp);
-
- return (i);
-}
-
-static int
-parse_special(cp)
- char *cp;
-{
- int val;
-
- val = is_special(cp);
- if (val)
- return (val);
-
- errx(1, "invalid modifier `%s'", cp);
- /* NOTREACHED */
-}
-
-static int
-is_special(cp)
- char *cp;
-{
- int i;
-
- for (i = 0; specials[i].sw_name != NULL; ++i)
- if (strcmp(specials[i].sw_name, cp) == 0)
- return (specials[i].sw_value);
-
- return (0);
-}
-
-static const char *
-bits_to_string(v, cp)
- int v;
- const char *cp;
-{
- const char *np;
- char f, *bp;
- int first;
- static char buf[128];
-
- bp = buf;
- *bp++ = '<';
- for (first = 1; (f = *cp++) != 0; cp = np) {
- for (np = cp; *np >= ' ';)
- np++;
- if ((v & (1 << (f - 1))) == 0)
- continue;
- if (first)
- first = 0;
- else
- *bp++ = ',';
- (void) memcpy(bp, cp, np - cp);
- bp += np - cp;
- }
- *bp++ = '>';
- *bp = '\0';
-
- return (buf);
-}
-
-static void
-cleanup()
-{
- /* Simple enough... */
- (void)close(changer_fd);
-}
-
-static void
-usage()
-{
-
- (void) fprintf(stderr, "usage: %s command arg1 arg2 ...\n", __progname);
- (void) fprintf(stderr, "Examples:\n");
- (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);
- /* NOTREACHED */
-}
View
57 bin/chio/defs.h
@@ -1,57 +0,0 @@
-/* $NetBSD: defs.h,v 1.1.1.1 1996/04/03 00:34:38 thorpej Exp $ */
-
-/*
- * Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgements:
- * This product includes software developed by Jason R. Thorpe
- * for And Communications, http://www.and.com/
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-struct element_type {
- char *et_name; /* name; i.e. "picker, "slot", etc. */
- int et_type; /* type number */
-};
-
-struct changer_command {
- char *cc_name; /* command name */
- /* command handler */
- int (*cc_handler) __P((char *, int, char **));
-};
-
-struct special_word {
- char *sw_name; /* special word */
- int sw_value; /* token value */
-};
-
-/* sw_value */
-#define SW_INVERT 1 /* set "invert media" flag */
-#define SW_INVERT1 2 /* set "invert media 1" flag */
-#define SW_INVERT2 3 /* set "invert media 2" flag */
-
-/* Environment variable to check for default changer. */
-#define CHANGER_ENV_VAR "CHANGER"
View
35 bin/chio/pathnames.h
@@ -1,35 +0,0 @@
-/* $NetBSD: pathnames.h,v 1.1.1.1 1996/04/03 00:34:38 thorpej Exp $ */
-
-/*
- * Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgements:
- * This product includes software developed by Jason R. Thorpe
- * for And Communications, http://www.and.com/
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#define _PATH_CH "/dev/ch0"
View
6 bin/chmod/Makefile
@@ -1,6 +0,0 @@
-# $NetBSD: Makefile,v 1.8 1997/07/20 22:36:34 christos Exp $
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-
-PROG= chmod
-
-.include <bsd.prog.mk>
View
305 bin/chmod/chmod.1
@@ -1,305 +0,0 @@
-.\" $NetBSD: chmod.1,v 1.11 1997/10/20 08:51:10 enami Exp $
-.\"
-.\" Copyright (c) 1989, 1990, 1993, 1994
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" the Institute of Electrical and Electronics Engineers, Inc.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)chmod.1 8.4 (Berkeley) 3/31/94
-.\"
-.Dd March 31, 1994
-.Dt CHMOD 1
-.Os
-.Sh NAME
-.Nm chmod
-.Nd change file modes
-.Sh SYNOPSIS
-.Nm
-.Oo
-.Fl R
-.Op Fl H | Fl L | Fl P
-.Oc
-.Op Fl h
-.Ar mode
-.Ar file ...
-.Sh DESCRIPTION
-The
-.Nm
-utility modifies the file mode bits of the listed files
-as specified by the
-.Ar mode
-operand.
-.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl H
-If the
-.Fl R
-option is specified, symbolic links on the command line are followed.
-(Symbolic links encountered in the tree traversal are not followed.)
-.It Fl L
-If the
-.Fl R
-option is specified, all symbolic links are followed.
-.It Fl P
-If the
-.Fl R
-option is specified, no symbolic links are followed.
-.It Fl R
-Change the modes of the file hierarchies rooted in the files
-instead of just the files themselves.
-.It Fl h
-If
-.Ar file
-is symbolic link, the mode of the link is changed.
-.El
-.Pp
-If the option
-.Fl h
-is not given, unless the
-.Fl H
-or
-.Fl L
-option is set,
-.Nm
-on a symbolic link always succeeds and has no effect.
-The
-.Fl H ,
-.Fl L
-and
-.Fl P
-options are ignored unless the
-.Fl R
-option is specified.
-In addition, these options override each other and the
-command's actions are determined by the last one specified.
-.Pp
-Only the owner of a file or the super-user is permitted to change
-the mode of a file.
-.Pp
-The
-.Nm
-utility exits 0 on success, and >0 if an error occurs.
-.Sh MODES
-Modes may be absolute or symbolic.
-An absolute mode is an octal number constructed by
-.Ar or-ing
-the following values:
-.Pp
-.Bl -tag -width 6n -compact -offset indent
-.It Li 4000
-set-user-ID-on-execution
-.It Li 2000
-set-group-ID-on-execution
-.It Li 1000
-sticky bit, see
-.Xr chmod 2
-.It Li 0400
-read by owner
-.It Li 0200
-write by owner
-.It Li 0100
-execute (or search for directories) by owner
-.It Li 0070
-read, write, execute/search by group
-.It Li 0007
-read, write, execute/search by others
-.El
-.Pp
-The read, write, and execute/search values for group and others
-are encoded as described for owner.
-.Pp
-The symbolic mode is described by the following grammar:
-.Bd -literal -offset indent
-mode ::= clause [, clause ...]
-clause ::= [who ...] [action ...] last_action
-action ::= op [perm ...]
-last_action ::= op [perm ...]
-who ::= a | u | g | o
-op ::= + | \- | =
-perm ::= r | s | t | w | x | X | u | g | o
-.Ed
-.Pp
-The
-.Ar who
-symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
-of the mode bits, respectively.
-The
-.Ar who
-symbol ``a'' is equivalent to ``ugo''.
-.Pp
-.ne 1i
-The
-.Ar perm
-symbols represent the portions of the mode bits as follows:
-.Pp
-.Bl -tag -width Ds -compact -offset indent
-.It r
-The read bits.
-.It s
-The set-user-ID-on-execution and set-group-ID-on-execution bits.
-.It t
-The sticky bit.
-.It w
-The write bits.
-.It x
-The execute/search bits.
-.It X
-The execute/search bits if the file is a directory or any of the
-execute/search bits are set in the original (unmodified) mode.
-Operations with the
-.Ar perm
-symbol ``X'' are only meaningful in conjunction with the
-.Ar op
-symbol ``+'', and are ignored in all other cases.
-.It u
-The user permission bits in the mode of the original file.
-.It g
-The group permission bits in the mode of the original file.
-.It o
-The other permission bits in the mode of the original file.
-.El
-.Pp
-The
-.Ar op
-symbols represent the operation performed, as follows:
-.Bl -tag -width 4n
-.It +
-If no value is supplied for
-.Ar perm ,
-the ``+'' operation has no effect.
-If no value is supplied for
-.Ar who ,
-each permission bit specified in
-.Ar perm ,
-for which the corresponding bit in the file mode creation mask
-is clear, is set.
-Otherwise, the mode bits represented by the specified
-.Ar who
-and
-.Ar perm
-values are set.
-.It \&\-
-If no value is supplied for
-.Ar perm ,
-the ``\-'' operation has no effect.
-If no value is supplied for
-.Ar who ,
-each permission bit specified in
-.Ar perm ,
-for which the corresponding bit in the file mode creation mask
-is clear, is cleared.
-Otherwise, the mode bits represented by the specified
-.Ar who
-and
-.Ar perm
-values are cleared.
-.It =
-The mode bits specified by the
-.Ar who
-value are cleared, or, if no who value is specified, the owner, group
-and other mode bits are cleared.
-Then, if no value is supplied for
-.Ar who ,
-each permission bit specified in
-.Ar perm ,
-for which the corresponding bit in the file mode creation mask
-is clear, is set.
-Otherwise, the mode bits represented by the specified
-.Ar who
-and
-.Ar perm
-values are set.
-.El
-.Pp
-Each
-.Ar clause
-specifies one or more operations to be performed on the mode
-bits, and each operation is applied to the mode bits in the
-order specified.
-.Pp
-Operations upon the other permissions only (specified by the symbol
-``o'' by itself), in combination with the
-.Ar perm
-symbols ``s'' or ``t'', are ignored.
-.Sh EXAMPLES
-.Bl -tag -width "u=rwx,go=u-w" -compact
-.It Li 644
-make a file readable by anyone and writable by the owner only.
-.Pp
-.It Li go-w
-deny write permission to group and others.
-.Pp
-.It Li =rw,+X
-set the read and write permissions to the usual defaults, but
-retain any execute permissions that are currently set.
-.Pp
-.It Li +X
-make a directory or file searchable/executable by everyone if it is
-already searchable/executable by anyone.
-.Pp
-.It Li 755
-.It Li u=rwx,go=rx
-.It Li u=rwx,go=u-w
-make a file readable/executable by everyone and writable by the owner only.
-.Pp
-.It Li go=
-clear all mode bits for group and others.
-.Pp
-.It Li g=u-w
-set the group bits equal to the user bits, but clear the group write bit.
-.El
-.Sh BUGS
-There's no
-.Ar perm
-option for the naughty bits.
-.Sh SEE ALSO
-.Xr install 1 ,
-.Xr chmod 2 ,
-.Xr stat 2 ,
-.Xr umask 2 ,
-.Xr fts 3 ,
-.Xr setmode 3 ,
-.Xr symlink 7 ,
-.Xr chown 8
-.Sh STANDARDS
-The
-.Nm
-utility is expected to be
-.St -p1003.2
-compatible with the exception of the
-.Ar perm
-symbols
-.Dq t
-and
-.Dq X
-which are not included in that standard.
View
227 bin/chmod/chmod.c
@@ -1,227 +0,0 @@
-/* $NetBSD: chmod.c,v 1.20 1998/07/28 05:31:22 mycroft Exp $ */
-
-/*
- * Copyright (c) 1989, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#ifndef lint
-__COPYRIGHT(
-"@(#) Copyright (c) 1989, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n");
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)chmod.c 8.8 (Berkeley) 4/1/94";
-#else
-__RCSID("$NetBSD: chmod.c,v 1.20 1998/07/28 05:31:22 mycroft Exp $");
-#endif
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <err.h>
-#include <errno.h>
-#include <fts.h>
-#include <locale.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <limits.h>
-
-int main __P((int, char *[]));
-void usage __P((void));
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- FTS *ftsp;
- FTSENT *p;
- mode_t *set;
- long val;
- int oct, omode;
- int Hflag, Lflag, Rflag, ch, fflag, fts_options, hflag, rval;
- char *ep, *mode;
- int (*change_mode) __P((const char *, mode_t));
-
- set = NULL; /* XXX gcc -Wuninitialized */
- omode = 0; /* XXX gcc -Wuninitialized */
-
- (void)setlocale(LC_ALL, "");
-
- Hflag = Lflag = Rflag = fflag = hflag = 0;
- while ((ch = getopt(argc, argv, "HLPRXfghorstuwx")) != -1)
- switch (ch) {
- case 'H':
- Hflag = 1;
- Lflag = 0;
- break;
- case 'L':
- Lflag = 1;
- Hflag = 0;
- break;
- case 'P':
- Hflag = Lflag = 0;
- break;
- case 'R':
- Rflag = 1;
- break;
- case 'f': /* XXX: undocumented. */
- fflag = 1;
- break;
- case 'h':
- /*
- * In System V (and probably POSIX.2) the -h option
- * causes chmod to change the mode of the symbolic
- * link. 4.4BSD's symbolic links didn't have modes,
- * so it was an undocumented noop. In NetBSD 1.3,
- * lchmod(2) is introduced and this option does real
- * work.
- */
- hflag = 1;
- break;
- /*
- * XXX
- * "-[rwx]" are valid mode commands. If they are the entire
- * argument, getopt has moved past them, so decrement optind.
- * Regardless, we're done argument processing.
- */
- case 'g': case 'o': case 'r': case 's':
- case 't': case 'u': case 'w': case 'X': case 'x':
- if (argv[optind - 1][0] == '-' &&
- argv[optind - 1][1] == ch &&
- argv[optind - 1][2] == '\0')
- --optind;
- goto done;
- case '?':
- default:
- usage();
- }
-done: argv += optind;
- argc -= optind;
-
- if (argc < 2)
- usage();
-
- fts_options = FTS_PHYSICAL;
- if (Rflag) {
- if (hflag)
- errx(1,
- "the -R and -h options may not be specified together.");
- if (Hflag)
- fts_options |= FTS_COMFOLLOW;
- if (Lflag) {
- fts_options &= ~FTS_PHYSICAL;
- fts_options |= FTS_LOGICAL;
- }
- }
- if (hflag)
- change_mode = lchmod;
- else
- change_mode = chmod;
-
- mode = *argv;
- if (*mode >= '0' && *mode <= '7') {
- errno = 0;
- val = strtol(mode, &ep, 8);
- if (val > INT_MAX || val < 0)
- errno = ERANGE;
- if (errno)
- err(1, "invalid file mode: %s", mode);
- if (*ep)
- errx(1, "invalid file mode: %s", mode);
- omode = val;
- oct = 1;
- } else {
- if ((set = setmode(mode)) == NULL)
- errx(1, "invalid file mode: %s", mode);
- oct = 0;
- }
-
- if ((ftsp = fts_open(++argv, fts_options, 0)) == NULL)
- err(1, argv[0]);
- for (rval = 0; (p = fts_read(ftsp)) != NULL;) {
- switch (p->fts_info) {
- case FTS_D:
- if (!Rflag)
- (void)fts_set(ftsp, p, FTS_SKIP);
- break;
- case FTS_DNR: /* Warn, chmod, continue. */
- warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
- rval = 1;
- break;
- case FTS_DP: /* Already changed at FTS_D. */
- continue;
- case FTS_ERR: /* Warn, continue. */
- case FTS_NS:
- warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
- rval = 1;
- continue;
- case FTS_SL: /* Ignore. */
- case FTS_SLNONE:
- /*
- * The only symlinks that end up here are ones that
- * don't point to anything and ones that we found
- * doing a physical walk.
- */
- if (!hflag)
- continue;
- /* else */
- /* FALLTHROUGH */
- default:
- break;
- }
- if ((*change_mode)(p->fts_accpath, oct ? omode :
- getmode(set, p->fts_statp->st_mode)) && !fflag) {
- warn("%s", p->fts_path);
- rval = 1;
- }
- }
- if (errno)
- err(1, "fts_read");
- exit(rval);
- /* NOTREACHED */
-}
-
-void
-usage()
-{
- (void)fprintf(stderr,
- "usage: chmod [-R [-H | -L | -P]] [-h] mode file ...\n");
- exit(1);
- /* NOTREACHED */
-}
View
7 bin/cp/Makefile
@@ -1,7 +0,0 @@
-# $NetBSD: Makefile,v 1.9 1997/07/20 22:36:37 christos Exp $
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-
-PROG= cp
-SRCS= cp.c utils.c
-
-.include <bsd.prog.mk>
View
213 bin/cp/cp.1
@@ -1,213 +0,0 @@
-.\" $NetBSD: cp.1,v 1.12 1997/10/11 02:14:42 enami Exp $
-.\"
-.\" Copyright (c) 1989, 1990, 1993, 1994
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" the Institute of Electrical and Electronics Engineers, Inc.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)cp.1 8.3 (Berkeley) 4/18/94
-.\"
-.Dd April 18, 1994
-.Dt CP 1
-.Os BSD 4
-.Sh NAME
-.Nm cp
-.Nd copy files
-.Sh SYNOPSIS
-.Nm
-.Oo
-.Fl R
-.Op Fl H | Fl L | Fl P
-.Oc
-.Op Fl fip
-.Ar source_file target_file
-.Nm ""
-.Oo
-.Fl R
-.Op Fl H | Fl L | Fl P
-.Oc
-.Op Fl fip
-.Ar source_file ... target_directory
-.Sh DESCRIPTION
-In the first synopsis form, the
-.Nm
-utility copies the contents of the
-.Ar source_file
-to the
-.Ar target_file .
-In the second synopsis form,
-the contents of each named
-.Ar source_file
-is copied to the destination
-.Ar target_directory .
-The names of the files themselves are not changed.
-If
-.Nm
-detects an attempt to copy a file to itself, the copy will fail.
-.Pp
-The following options are available:
-.Bl -tag -width flag
-.It Fl H
-If the
-.Fl R
-option is specified, symbolic links on the command line are followed.
-(Symbolic links encountered in the tree traversal are not followed.)
-.It Fl L
-If the
-.Fl R
-option is specified, all symbolic links are followed.
-.It Fl P
-If the
-.Fl R
-option is specified, no symbolic links are followed.
-.It Fl R
-If
-.Ar source_file
-designates a directory,
-.Nm
-copies the directory and the entire subtree connected at that point.
-This option also causes symbolic links to be copied, rather than
-indirected through, and for
-.Nm
-to create special files rather than copying them as normal files.
-Created directories have the same mode as the corresponding source
-directory, unmodified by the process' umask.
-.It Fl f
-For each existing destination pathname, remove it and
-create a new file, without prompting for confirmation
-regardless of its permissions.
-(The
-.Fl i
-option is ignored if the
-.Fl f
-option is specified.)
-.It Fl i
-Causes
-.Nm
-to write a prompt to the standard error output before copying a file
-that would overwrite an existing file.
-If the response from the standard input begins with the character
-.Sq Li y ,
-the file copy is attempted.
-.It Fl p
-Causes
-.Nm
-to preserve in the copy as many of the modification time, access time,
-file flags, file mode, user ID, and group ID as allowed by permissions.
-.Pp
-If the user ID and group ID cannot be preserved, no error message
-is displayed and the exit value is not altered.
-.Pp
-If the source file has its set user ID bit on and the user ID cannot
-be preserved, the set user ID bit is not preserved
-in the copy's permissions.
-If the source file has its set group ID bit on and the group ID cannot
-be preserved, the set group ID bit is not preserved
-in the copy's permissions.
-If the source file has both its set user ID and set group ID bits on,
-and either the user ID or group ID cannot be preserved, neither
-the set user ID or set group ID bits are preserved in the copy's
-permissions.
-.El
-.Pp
-For each destination file that already exists, its contents are
-overwritten if permissions allow, but its mode, user ID, and group
-ID are unchanged.
-.Pp
-In the second synopsis form,
-.Ar target_directory
-must exist unless there is only one named
-.Ar source_file
-which is a directory and the
-.Fl R
-flag is specified.
-.Pp
-If the destination file does not exist, the mode of the source file is
-used as modified by the file mode creation mask
-.Pf ( Ic umask ,
-see
-.Xr csh 1 ) .
-If the source file has its set user ID bit on, that bit is removed
-unless both the source file and the destination file are owned by the
-same user.
-If the source file has its set group ID bit on, that bit is removed
-unless both the source file and the destination file are in the same
-group and the user is a member of that group.
-If both the set user ID and set group ID bits are set, all of the above
-conditions must be fulfilled or both bits are removed.
-.Pp
-Appropriate permissions are required for file creation or overwriting.
-.Pp
-Symbolic links are always followed unless the
-.Fl R
-flag is set, in which case symbolic links are not followed, by default.
-The
-.Fl H
-or
-.Fl L
-flags (in conjunction with the
-.Fl R
-flag) cause symbolic links to be followed as described above.
-The
-.Fl H ,
-.Fl L
-and
-.Fl P
-options are ignored unless the
-.Fl R
-option is specified.
-In addition, these options override each other and the
-command's actions are determined by the last one specified.
-.Pp
-.Nm
-exits 0 on success, >0 if an error occurred.
-.Sh COMPATIBILITY
-Historic versions of the
-.Nm
-utility had a
-.Fl r
-option.
-This implementation supports that option, however, its use is strongly
-discouraged, as it does not correctly copy special files, symbolic links
-or fifo's.
-.Sh SEE ALSO
-.Xr mv 1 ,
-.Xr rcp 1 ,
-.Xr umask 2 ,
-.Xr fts 3 ,
-.Xr symlink 7
-.Sh STANDARDS
-The
-.Nm
-utility is expected to be
-.St -p1003.2
-compatible.
View
463 bin/cp/cp.c
@@ -1,463 +0,0 @@
-/* $NetBSD: cp.c,v 1.24 1998/08/19 01:29:11 thorpej Exp $ */
-
-/*
- * Copyright (c) 1988, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * David Hitz of Auspex Systems Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#ifndef lint
-__COPYRIGHT(
-"@(#) Copyright (c) 1988, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n");
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)cp.c 8.5 (Berkeley) 4/29/95";
-#else
-__RCSID("$NetBSD: cp.c,v 1.24 1998/08/19 01:29:11 thorpej Exp $");
-#endif
-#endif /* not lint */
-
-/*
- * Cp copies source files to target files.
- *
- * The global PATH_T structure "to" always contains the path to the
- * current target file. Since fts(3) does not change directories,
- * this path can be either absolute or dot-relative.