]> git.saurik.com Git - apple/file_cmds.git/commitdiff
file_cmds-90.tar.gz v90
authorApple <opensource@apple.com>
Tue, 29 Jun 2004 04:46:53 +0000 (04:46 +0000)
committerApple <opensource@apple.com>
Tue, 29 Jun 2004 04:46:53 +0000 (04:46 +0000)
21 files changed:
chmod/chmod.1
chmod/chmod.c
chown/chown.8
chown/chown.c
cp/cp.c
cp/utils.c
install/Makefile.preamble
install/xinstall.c
ln/Makefile.postamble
ls/Makefile
ls/ls.c
ls/print.c
ls/stat_flags.c [deleted file]
mknod/mknod.8
rm/Makefile.postamble
rm/Makefile.preamble
rm/rm.c
tcopy/tcopy.1
tcopy/tcopy.c
touch/touch.1
touch/touch.c

index 8e5de74b39c6e980436d278b7ceb507afae6bfb5..d0b29171f720a486b9ac0444964cf134174aa952 100644 (file)
@@ -43,7 +43,7 @@
 .Nd change file modes
 .Sh SYNOPSIS
 .Nm
 .Nd change file modes
 .Sh SYNOPSIS
 .Nm
-.Op Fl fhv
+.Op Fl fv
 .Op Fl R Op Fl H | L | P
 .Ar mode
 .Ar
 .Op Fl R Op Fl H | L | P
 .Ar mode
 .Ar
@@ -80,9 +80,6 @@ Do not display a diagnostic message if
 .Nm
 could not modify the mode for
 .Va file .
 .Nm
 could not modify the mode for
 .Va file .
-.It Fl h
-If the file is a symbolic link, change the mode of the link itself
-rather than the file that the link points to.
 .It Fl v
 Cause
 .Nm
 .It Fl v
 Cause
 .Nm
index c38286d1aaa698beab5281e54b05129742967f77..c01c5dd32b3dfb4501880ee72d5f552189ccdd57 100644 (file)
@@ -77,7 +77,11 @@ main(int argc, char *argv[])
        set = NULL;
        omode = 0;
        Hflag = Lflag = Rflag = fflag = hflag = vflag = 0;
        set = NULL;
        omode = 0;
        Hflag = Lflag = Rflag = fflag = hflag = vflag = 0;
+#ifndef __APPLE__
        while ((ch = getopt(argc, argv, "HLPRXfghorstuvwx")) != -1)
        while ((ch = getopt(argc, argv, "HLPRXfghorstuvwx")) != -1)
+#else
+       while ((ch = getopt(argc, argv, "HLPRXfgorstuvwx")) != -1)
+#endif
                switch (ch) {
                case 'H':
                        Hflag = 1;
                switch (ch) {
                case 'H':
                        Hflag = 1;
index 18d467ddd347eb6ac4cf1680799021c3d8c4a31a..9f141bfb66c072d5a59003b0cd2a7bffc0f5cb28 100644 (file)
@@ -40,7 +40,7 @@
 .Nd change file owner and group
 .Sh SYNOPSIS
 .Nm
 .Nd change file owner and group
 .Sh SYNOPSIS
 .Nm
-.Op Fl fhv
+.Op Fl fv
 .Oo
 .Fl R
 .Op Fl H | Fl L | Fl P
 .Oo
 .Fl R
 .Op Fl H | Fl L | Fl P
@@ -48,7 +48,7 @@
 .Ar owner Ns Op : Ns Ar group
 .Ar
 .Nm
 .Ar owner Ns Op : Ns Ar group
 .Ar
 .Nm
-.Op Fl fhv
+.Op Fl fv
 .Oo
 .Fl R
 .Op Fl H | Fl L | Fl P
 .Oo
 .Fl R
 .Op Fl H | Fl L | Fl P
@@ -59,9 +59,6 @@
 The
 .Nm
 utility changes the user ID and/or the group ID of the specified files.
 The
 .Nm
 utility changes the user ID and/or the group ID of the specified files.
-Symbolic links named by arguments are silently left unchanged unless
-.Fl h
-is used.
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
@@ -85,9 +82,6 @@ in the files instead of just the files themselves.
 .It Fl f
 Don't report any failure to change file owner or group, nor modify
 the exit status to reflect such failures.
 .It Fl f
 Don't report any failure to change file owner or group, nor modify
 the exit status to reflect such failures.
-.It Fl h
-If the file is a symbolic link, change the user ID and/or the
-group ID of the link itself.
 .It Fl v
 Cause
 .Nm
 .It Fl v
 Cause
 .Nm
index 464bf230f81965af983c3ad58c52415b0f84f235..03305f55b80087c160aded286ccf0ffb2ced31bc 100644 (file)
@@ -84,7 +84,11 @@ main(int argc, char **argv)
        ischown = (strcmp(cp, "chown") == 0);
 
        Hflag = Lflag = Rflag = fflag = hflag = vflag = 0;
        ischown = (strcmp(cp, "chown") == 0);
 
        Hflag = Lflag = Rflag = fflag = hflag = vflag = 0;
+#ifndef __APPLE__
        while ((ch = getopt(argc, argv, "HLPRfhv")) != -1)
        while ((ch = getopt(argc, argv, "HLPRfhv")) != -1)
+#else
+       while ((ch = getopt(argc, argv, "HLPRfv")) != -1)
+#endif
                switch (ch) {
                case 'H':
                        Hflag = 1;
                switch (ch) {
                case 'H':
                        Hflag = 1;
@@ -103,9 +107,11 @@ main(int argc, char **argv)
                case 'f':
                        fflag = 1;
                        break;
                case 'f':
                        fflag = 1;
                        break;
+#ifndef __APPLE__
                case 'h':
                        hflag = 1;
                case 'h':
                        hflag = 1;
-                       break;
+                       break;
+#endif
                case 'v':
                        vflag = 1;
                        break;
                case 'v':
                        vflag = 1;
                        break;
@@ -283,6 +289,10 @@ usage(void)
                    "       chown [-fhv] [-R [-H | -L | -P]] :group file ...");
        else
                (void)fprintf(stderr, "%s\n",
                    "       chown [-fhv] [-R [-H | -L | -P]] :group file ...");
        else
                (void)fprintf(stderr, "%s\n",
+#ifndef __APPLE__
                    "usage: chgrp [-fhv] [-R [-H | -L | -P]] group file ...");
                    "usage: chgrp [-fhv] [-R [-H | -L | -P]] group file ...");
+#else
+                   "usage: chgrp [-fv] [-R [-H | -L | -P]] group file ...");
+#endif
        exit(1);
 }
        exit(1);
 }
diff --git a/cp/cp.c b/cp/cp.c
index 6272d8eec85f143356ba95f1dcf2a8f747bb5972..43e094b8dbc5df13c655c6099ec4385ddc8dfed5 100644 (file)
--- a/cp/cp.c
+++ b/cp/cp.c
@@ -415,9 +415,8 @@ copy(char *argv[], enum op type, int fts_options)
                        break;
                case S_IFDIR:
                        if (!Rflag && !rflag) {
                        break;
                case S_IFDIR:
                        if (!Rflag && !rflag) {
-                               if (curr->fts_info == FTS_DP)
-                                       warnx("%s is a directory (not copied).",
-                                           curr->fts_path);
+                               warnx("%s is a directory (not copied).",
+                                        curr->fts_path);
                                (void)fts_set(ftsp, curr, FTS_SKIP);
                                badcp = rval = 1;
                                break;
                                (void)fts_set(ftsp, curr, FTS_SKIP);
                                badcp = rval = 1;
                                break;
index b55bbc909103e94bb49f8cb8439280b396fcf0e3..56256f92cd85fc2fd77cf52c3ba4d4835e3ad742 100644 (file)
@@ -90,6 +90,7 @@ copy_file(FTSENT *entp, int dne)
                if (nflag) {
                        if (vflag)
                                printf("%s not overwritten\n", to.p_path);
                if (nflag) {
                        if (vflag)
                                printf("%s not overwritten\n", to.p_path);
+                       close(from_fd);
                        return (0);
                } else if (iflag) {
                        (void)fprintf(stderr, "overwrite %s? %s", 
                        return (0);
                } else if (iflag) {
                        (void)fprintf(stderr, "overwrite %s? %s", 
index 7a86fc278fcc7f23773c82df843fecdd2395bbb3..9e10e90bb6746d84796f702e9cf6b6039454678d 100644 (file)
@@ -1,5 +1 @@
-vpath stat_flags.c ../ls
-
-CFILES += stat_flags.c
-
 include $(CoreOSMakefiles)/ProjectBuilder/Makefile.Preamble.Common
 include $(CoreOSMakefiles)/ProjectBuilder/Makefile.Preamble.Common
index 2cb3e92ddc9aee41944a86219a3806343305012c..a98ca93c0a9b0226b120bb07312063fdf08f39cf 100644 (file)
@@ -85,10 +85,6 @@ int dobackup, docompare, dodir, dopreserve, dostrip, nommap, safecopy, verbose;
 mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
 char *suffix = BACKUP_SUFFIX;
 
 mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
 char *suffix = BACKUP_SUFFIX;
 
-#ifdef __APPLE__
-u_long  string_to_flags __P((char **, u_long *, u_long *));
-#define strtofflags(x,y,z) string_to_flags((x),(y),(z))
-#endif
 void   copy __P((int, char *, int, char *, off_t));
 int    compare __P((int, const char *, size_t, int, const char *, size_t));
 int    create_newfile __P((char *, int, struct stat *));
 void   copy __P((int, char *, int, char *, off_t));
 int    compare __P((int, const char *, size_t, int, const char *, size_t));
 int    create_newfile __P((char *, int, struct stat *));
index 013b558de882142e966c538876f25f5726df1f43..b347e1a0a8420cc8e19447d2bd7aaf6dc25688dd 100644 (file)
@@ -1 +1,7 @@
 include $(CoreOSMakefiles)/ProjectBuilder/Makefile.Postamble.Common
 include $(CoreOSMakefiles)/ProjectBuilder/Makefile.Postamble.Common
+
+after_install::
+       $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/link
+       mkdir -p "$(DSTROOT)/usr/share/man/man1"
+       ln -f "$(DSTROOT)/usr/share/man/man1/ln.1" "$(DSTROOT)/usr/share/man/man1/link.1"
+
index 6793f2bea34b395cb06898c7626598bcbdbf908b..33d8b5a98e692c9a562f625eca97e8c0b8a31b82 100644 (file)
@@ -14,7 +14,7 @@ PROJECT_TYPE = Tool
 
 HFILES = extern.h ls.h
 
 
 HFILES = extern.h ls.h
 
-CFILES = cmp.c ls.c print.c stat_flags.c util.c
+CFILES = cmp.c ls.c print.c util.c
 
 OTHERSRCS = Makefile Makefile.preamble Makefile.postamble ls.1
 
 
 OTHERSRCS = Makefile Makefile.preamble Makefile.postamble ls.1
 
diff --git a/ls/ls.c b/ls/ls.c
index 99f45b27c026298f054a3e588e7e7961c85fc545..92e38b3fdcc87900910f8d71858d9d3fe9731426 100644 (file)
--- a/ls/ls.c
+++ b/ls/ls.c
@@ -630,13 +630,7 @@ display(FTSENT *p, FTSENT *list)
                        warnx("%s: %s",
                            cur->fts_name, strerror(cur->fts_errno));
                        cur->fts_number = NO_PRINT;
                        warnx("%s: %s",
                            cur->fts_name, strerror(cur->fts_errno));
                        cur->fts_number = NO_PRINT;
-#ifndef __APPLE__
-                       /* Don't count this as an error.  This is for
-                        * binary compatibility with Matlab installer script.
-                        * 3252074
-                        */
                        rval = 1;
                        rval = 1;
-#endif
                        continue;
                }
                /*
                        continue;
                }
                /*
index b3dd33954b1968e180cdd865b3cb37d8a75865b4..4962a95dea06f89f3b50f9729983d12f022a881b 100644 (file)
@@ -49,9 +49,7 @@ __RCSID("$FreeBSD: src/bin/ls/print.c,v 1.57 2002/08/29 14:29:09 keramida Exp $"
 #include <errno.h>
 #include <fts.h>
 #include <math.h>
 #include <errno.h>
 #include <fts.h>
 #include <math.h>
-#ifndef __APPLE__
 #include <langinfo.h>
 #include <langinfo.h>
-#endif /* __APPLE__ */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -379,10 +377,8 @@ printtime(time_t ftime)
        const char *format;
        static int d_first = -1;
 
        const char *format;
        static int d_first = -1;
 
-#ifndef __APPLE__
        if (d_first < 0)
                d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
        if (d_first < 0)
                d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
-#endif /* __APPLE__ */
        if (now == 0)
                now = time(NULL);
 
        if (now == 0)
                now = time(NULL);
 
diff --git a/ls/stat_flags.c b/ls/stat_flags.c
deleted file mode 100644 (file)
index e46a3e8..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*     $NetBSD: stat_flags.c,v 1.6 1997/07/20 18:53:12 christos Exp $  */
-
-/*-
- * Copyright (c) 1993
- *     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
-#if 0
-static char sccsid[] = "@(#)stat_flags.c       8.2 (Berkeley) 7/28/94";
-#else
-__RCSID("$NetBSD: stat_flags.c,v 1.6 1997/07/20 18:53:12 christos Exp $");
-#endif
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <stddef.h>
-#include <string.h>
-#include <fts.h>
-
-#include "ls.h"
-#include "extern.h"
-
-#define        SAPPEND(s) {                                                    \
-       if (prefix != NULL)                                             \
-               (void)strcat(string, prefix);                           \
-       (void)strcat(string, s);                                        \
-       prefix = ",";                                                   \
-}
-
-/*
- * flags_to_string --
- *     Convert stat flags to a comma-separated string.  If no flags
- *     are set, return the default string.
- */
-char *
-flags_to_string(flags, def)
-       u_long flags;
-       char *def;
-{
-       static char string[128];
-       char *prefix;
-
-       string[0] = '\0';
-       prefix = NULL;
-       if (flags & UF_APPEND)
-               SAPPEND("uappnd");
-       if (flags & UF_IMMUTABLE)
-               SAPPEND("uchg");
-       if (flags & UF_NODUMP)
-               SAPPEND("nodump");
-       if (flags & UF_OPAQUE)
-               SAPPEND("opaque");
-       if (flags & SF_APPEND)
-               SAPPEND("sappnd");
-       if (flags & SF_ARCHIVED)
-               SAPPEND("arch");
-       if (flags & SF_IMMUTABLE)
-               SAPPEND("schg");
-       return (prefix == NULL && def != NULL ? def : string);
-}
-
-#define        TEST(a, b, f) {                                                 \
-       if (!memcmp(a, b, sizeof(b))) {                                 \
-               if (clear) {                                            \
-                       if (clrp)                                       \
-                               *clrp |= (f);                           \
-               } else if (setp)                                        \
-                       *setp |= (f);                                   \
-               break;                                                  \
-       }                                                               \
-}
-
-/*
- * string_to_flags --
- *     Take string of arguments and return stat flags.  Return 0 on
- *     success, 1 on failure.  On failure, stringp is set to point
- *     to the offending token.
- */
-int
-string_to_flags(stringp, setp, clrp)
-       char **stringp;
-       u_long *setp, *clrp;
-{
-       int clear;
-       char *string, *p;
-
-       clear = 0;
-       if (setp)
-               *setp = 0;
-       if (clrp)
-               *clrp = 0;
-       string = *stringp;
-       while ((p = strsep(&string, "\t ,")) != NULL) {
-               *stringp = p;
-               if (*p == '\0')
-                       continue;
-               if (p[0] == 'n' && p[1] == 'o') {
-                       clear = 1;
-                       p += 2;
-               }
-               switch (p[0]) {
-               case 'a':
-                       TEST(p, "arch", SF_ARCHIVED);
-                       TEST(p, "archived", SF_ARCHIVED);
-                       return (1);
-               case 'd':
-                       clear = !clear;
-                       TEST(p, "dump", UF_NODUMP);
-                       return (1);
-               case 'o':
-                       TEST(p, "opaque", UF_OPAQUE);
-                       return (1);
-               case 's':
-                       TEST(p, "sappnd", SF_APPEND);
-                       TEST(p, "sappend", SF_APPEND);
-                       TEST(p, "schg", SF_IMMUTABLE);
-                       TEST(p, "schange", SF_IMMUTABLE);
-                       TEST(p, "simmutable", SF_IMMUTABLE);
-                       return (1);
-               case 'u':
-                       TEST(p, "uappnd", UF_APPEND);
-                       TEST(p, "uappend", UF_APPEND);
-                       TEST(p, "uchg", UF_IMMUTABLE);
-                       TEST(p, "uchange", UF_IMMUTABLE);
-                       TEST(p, "uimmutable", UF_IMMUTABLE);
-                       /* FALLTHROUGH */
-               default:
-                       return (1);
-               }
-       }
-       return (0);
-}
index 7a1517d865a7f80a4d6e5810f78f4ea14b7e5033..d68dab1f4b17ee24a390dd73a155e207b39a3d79 100644 (file)
 .Ar name
 .Op Cm c | Cm b
 .Ar major minor
 .Ar name
 .Op Cm c | Cm b
 .Ar major minor
-.Nm ""
+.Nm
 .Op Fl F Ar format
 .Ar name
 .Op Cm c | Cm b
 .Ar major unit subunit
 .Op Fl F Ar format
 .Ar name
 .Op Cm c | Cm b
 .Ar major unit subunit
-.Nm ""
+.Nm
 .Ar name
 .Op Cm c | Cm b
 .Ar number
 .Ar name
 .Op Cm c | Cm b
 .Ar number
index 013b558de882142e966c538876f25f5726df1f43..bc9f08f1985c37076619c7654524b26cebb1fdba 100644 (file)
@@ -1 +1,6 @@
 include $(CoreOSMakefiles)/ProjectBuilder/Makefile.Postamble.Common
 include $(CoreOSMakefiles)/ProjectBuilder/Makefile.Postamble.Common
+
+after_install::
+       $(LINKPRODUCT) $(DSTROOT)$(INSTALLDIR)/unlink
+       mkdir -p "$(DSTROOT)/usr/share/man/man1"
+       ln -f "$(DSTROOT)/usr/share/man/man1/rm.1" "$(DSTROOT)/usr/share/man/man1/unlink.1"
index 48df90e1ae895c3775c3b59c1531def4a23ffa63..9e10e90bb6746d84796f702e9cf6b6039454678d 100644 (file)
@@ -1,3 +1 @@
-vpath stat_flags.c ../ls
-CFILES += stat_flags.c
 include $(CoreOSMakefiles)/ProjectBuilder/Makefile.Preamble.Common
 include $(CoreOSMakefiles)/ProjectBuilder/Makefile.Preamble.Common
diff --git a/rm/rm.c b/rm/rm.c
index 63666a9ccd145903cd691ce83a25660a7e8464d8..7997af50cd9d2ce7335c02f6f7d197319bb2dade 100644 (file)
--- a/rm/rm.c
+++ b/rm/rm.c
@@ -70,15 +70,6 @@ void rm_overwrite __P((char *, struct stat *));
 void   rm_tree __P((char **));
 void   usage __P((void));
 
 void   rm_tree __P((char **));
 void   usage __P((void));
 
-#ifdef __APPLE__
-/* We lack fflagstostr(), but ls has a flags_to_string function
- * that does the same thing.  So...  We really use that.
- */
-char * flags_to_string(u_long, char *);
-#define fflagstostr(x) flags_to_string((x), NULL)
-
-#endif
-
 /*
  * rm --
  *     This rm is different from historic rm's, but is expected to match
 /*
  * rm --
  *     This rm is different from historic rm's, but is expected to match
@@ -456,9 +447,7 @@ check(path, name, sp)
                    group_from_gid(sp->st_gid, 0),
                    *flagsp ? flagsp : "", *flagsp ? " " : "", 
                    path);
                    group_from_gid(sp->st_gid, 0),
                    *flagsp ? flagsp : "", *flagsp ? " " : "", 
                    path);
-#ifndef __APPLE__
                free(flagsp);
                free(flagsp);
-#endif
        }
        (void)fflush(stderr);
 
        }
        (void)fflush(stderr);
 
index ed27627c3995e6c100b765d29f7a62a6cc8eff06..880d18b658db5f69649bab30072d4d959ba3ef3e 100644 (file)
@@ -1,5 +1,3 @@
-.\"    $NetBSD: tcopy.1,v 1.5 1997/10/20 00:35:14 lukem Exp $
-.\"
 .\" Copyright (c) 1985, 1990, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
 .\"
 .\" Copyright (c) 1985, 1990, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
 .\"
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)tcopy.1    8.2 (Berkeley) 4/17/94
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)tcopy.1    8.2 (Berkeley) 4/17/94
+.\" $FreeBSD: src/usr.bin/tcopy/tcopy.1,v 1.15 2003/09/05 15:28:09 roam Exp $
 .\"
 .Dd April 17, 1994
 .Dt TCOPY 1
 .\"
 .Dd April 17, 1994
 .Dt TCOPY 1
-.Os BSD 4.3
+.Os
 .Sh NAME
 .Nm tcopy
 .Nd copy and/or verify mag tapes
 .Sh NAME
 .Nm tcopy
 .Nd copy and/or verify mag tapes
 .Oo Ar src Op Ar dest
 .Oc
 .Sh DESCRIPTION
 .Oo Ar src Op Ar dest
 .Oc
 .Sh DESCRIPTION
+The
 .Nm
 .Nm
-is designed to copy magnetic tapes.  The only assumption made
+utility is designed to copy magnetic tapes.  The only assumption made
 about the tape is that there are two tape marks at the end.
 about the tape is that there are two tape marks at the end.
+The
 .Nm
 .Nm
-with only a source tape
-.Pf ( Ar /dev/rst0
+utility with only a source tape
+.Pf ( Ar /dev/sa0
 by default) specified will print
 information about the sizes of records and tape files.  If a destination
 is specified a copy will be made of the source tape.  The blocking on the
 by default) specified will print
 information about the sizes of records and tape files.  If a destination
 is specified a copy will be made of the source tape.  The blocking on the
@@ -71,7 +72,7 @@ Specify a maximum block size,
 .Ar maxblk .
 .It Fl v
 Given the two tapes,
 .Ar maxblk .
 .It Fl v
 Given the two tapes,
-.ar src
+.Ar src
 and
 .Ar dest
 verify that they are identical.
 and
 .Ar dest
 verify that they are identical.
@@ -89,3 +90,26 @@ The
 .Nm
 command appeared in
 .Bx 4.3 .
 .Nm
 command appeared in
 .Bx 4.3 .
+.Sh BUGS
+.Bl -item
+.It
+Writing an image of a tape to a file does not preserve much more than
+the raw data.
+Block size(s) and tape EOF marks are lost which would
+otherwise be preserved in a tape-to-tape copy.
+.It
+EOD is determined by two sequential EOF marks with no data between.
+There are old systems which typically wrote three EOF's between tape
+files.
+The
+.Nm
+utility will erroneously stop copying early in this case.
+.It
+When using the copy/verify option \-c
+.Nm
+does not rewind the tapes prior to start.
+A rewind is performed
+after writing prior to the verification stage.
+If one doesn't start
+at BOT then the comparison may not be of the intended data.
+.El
index 297ad01c7726d0c2bd58a526c9e9b3fcd7a4873c..8f70cbea57318c3fadb964216924bbb9f4aafd6c 100644 (file)
@@ -1,7 +1,5 @@
-/*     $NetBSD: tcopy.c,v 1.8 1998/08/25 20:59:41 ross Exp $   */
-
 /*
 /*
- * Copyright (c) 1985, 1987, 1993, 1995
+ * Copyright (c) 1985, 1987, 1993
  *     The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  *     The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  */
 
 #include <sys/cdefs.h>
  */
 
 #include <sys/cdefs.h>
+
 #ifndef lint
 #ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1985, 1987, 1993\n\
-       The Regents of the University of California.  All rights reserved.\n");
-#endif /* not lint */
+static const char copyright[] =
+"@(#) Copyright (c) 1985, 1987, 1993\n\
+       The Regents of the University of California.  All rights reserved.\n";
+#endif
 
 #ifndef lint
 
 #ifndef lint
-#if 0
-static char sccsid[] = "@(#)tcopy.c    8.3 (Berkeley) 1/23/95";
+static const char sccsid[] = "@(#)tcopy.c      8.2 (Berkeley) 4/17/94";
 #endif
 #endif
-__RCSID("$NetBSD: tcopy.c,v 1.8 1998/08/25 20:59:41 ross Exp $");
-#endif /* not lint */
 
 #include <sys/types.h>
 #include <sys/stat.h>
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -53,9 +50,10 @@ __RCSID("$NetBSD: tcopy.c,v 1.8 1998/08/25 20:59:41 ross Exp $");
 
 #include <err.h>
 #include <errno.h>
 
 #include <err.h>
 #include <errno.h>
-#include <paths.h>
 #include <fcntl.h>
 #include <fcntl.h>
+#include <paths.h>
 #include <signal.h>
 #include <signal.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -65,30 +63,29 @@ __RCSID("$NetBSD: tcopy.c,v 1.8 1998/08/25 20:59:41 ross Exp $");
 #define        NOCOUNT (-2)
 
 int    filen, guesslen, maxblk = MAXREC;
 #define        NOCOUNT (-2)
 
 int    filen, guesslen, maxblk = MAXREC;
-long   lastrec, record;
-off_t  size, tsize;
-FILE   *msg = stdout;
+u_int64_t      lastrec, record, size, tsize;
+FILE   *msg;
 
 
-void   *getspace __P((int));
-void    intr __P((int));
-int     main __P((int, char **));
-void    usage __P((void));
-void    verify __P((int, int, char *));
-void    writeop __P((int, int));
+void   *getspace(int);
+void    intr(int);
+static void     usage(void);
+void    verify(int, int, char *);
+void    writeop(int, int);
+void   rewind_tape(int);
 
 int
 main(argc, argv)
        int argc;
        char *argv[];
 {
 
 int
 main(argc, argv)
        int argc;
        char *argv[];
 {
-       int ch, needeof, nw, inp, outp;
-       ssize_t lastnread, nread;
+       register int lastnread, nread, nw, inp, outp;
        enum {READ, VERIFY, COPY, COPYVERIFY} op = READ;
        sig_t oldsig;
        enum {READ, VERIFY, COPY, COPYVERIFY} op = READ;
        sig_t oldsig;
-       char *buff, *inf;
+       int ch, needeof;
+       char *buff;
+       const char *inf;
 
 
-       outp = 0;
-       inf = NULL;
+       msg = stdout;
        guesslen = 1;
        while ((ch = getopt(argc, argv, "cs:vx")) != -1)
                switch((char)ch) {
        guesslen = 1;
        while ((ch = getopt(argc, argv, "cs:vx")) != -1)
                switch((char)ch) {
@@ -132,16 +129,15 @@ main(argc, argv)
                        op = COPY;
                inf = argv[0];
                if ((outp = open(argv[1], op == VERIFY ? O_RDONLY :
                        op = COPY;
                inf = argv[0];
                if ((outp = open(argv[1], op == VERIFY ? O_RDONLY :
-                   op == COPY ? O_WRONLY : O_RDWR, DEFFILEMODE)) < 0) {
-                       err(3, argv[1]);
-               }
+                   op == COPY ? O_WRONLY : O_RDWR, DEFFILEMODE)) < 0)
+                       err(3, "%s", argv[1]);
                break;
        default:
                usage();
        }
 
        if ((inp = open(inf, O_RDONLY, 0)) < 0)
                break;
        default:
                usage();
        }
 
        if ((inp = open(inf, O_RDONLY, 0)) < 0)
-               err(1, inf);
+               err(1, "%s", inf);
 
        buff = getspace(maxblk);
 
 
        buff = getspace(maxblk);
 
@@ -161,21 +157,20 @@ main(argc, argv)
                                if (nread >= 0)
                                        goto r1;
                        }
                                if (nread >= 0)
                                        goto r1;
                        }
-                       err(1, "read error, file %d, record %ld",
-                           filen, record);
+                       err(1, "read error, file %d, record %qu", filen, record);
                } else if (nread != lastnread) {
                        if (lastnread != 0 && lastnread != NOCOUNT) {
                                if (lastrec == 0 && nread == 0)
                } else if (nread != lastnread) {
                        if (lastnread != 0 && lastnread != NOCOUNT) {
                                if (lastrec == 0 && nread == 0)
-                                       fprintf(msg, "%ld records\n", record);
+                                       fprintf(msg, "%qu records\n", record);
                                else if (record - lastrec > 1)
                                else if (record - lastrec > 1)
-                                       fprintf(msg, "records %ld to %ld\n",
+                                       fprintf(msg, "records %qu to %qu\n",
                                            lastrec, record);
                                else
                                            lastrec, record);
                                else
-                                       fprintf(msg, "record %ld\n", lastrec);
+                                       fprintf(msg, "record %qu\n", lastrec);
                        }
                        if (nread != 0)
                        }
                        if (nread != 0)
-                               fprintf(msg, "file %d: block size %ld: ",
-                                   filen, (long)nread);
+                               fprintf(msg, "file %d: block size %d: ",
+                                   filen, nread);
                        (void) fflush(stdout);
                        lastrec = record;
                }
                        (void) fflush(stdout);
                        lastrec = record;
                }
@@ -188,19 +183,13 @@ r1:               guesslen = 0;
                                }
                                nw = write(outp, buff, nread);
                                if (nw != nread) {
                                }
                                nw = write(outp, buff, nread);
                                if (nw != nread) {
-                                   int error = errno;
-                                   fprintf(stderr,
-                                       "write error, file %d, record %ld: ",
-                                       filen, record);
-                                   if (nw == -1)
-                                       fprintf(stderr,
-                                               ": %s", strerror(error));
-                                   else
-                                       fprintf(stderr,
-                                           "write (%d) != read (%ld)\n",
-                                           nw, (long)nread);
-                                   fprintf(stderr, "copy aborted\n");
-                                   exit(5);
+                                       if (nw == -1) {
+                                       warn("write error, file %d, record %qu", filen, record);
+                                       } else {
+                                       warnx("write error, file %d, record %qu", filen, record);
+                                       warnx("write (%d) != read (%d)", nw, nread);
+                                       }
+                                       errx(5, "copy aborted");
                                }
                        }
                        size += nread;
                                }
                        }
                        size += nread;
@@ -211,8 +200,8 @@ r1:         guesslen = 0;
                                break;
                        }
                        fprintf(msg,
                                break;
                        }
                        fprintf(msg,
-                           "file %d: eof after %ld records: %qd bytes\n",
-                           filen, record, (long long)size);
+                           "file %d: eof after %qu records: %qu bytes\n",
+                           filen, record, size);
                        needeof = 1;
                        filen++;
                        tsize += size;
                        needeof = 1;
                        filen++;
                        tsize += size;
@@ -221,14 +210,14 @@ r1:               guesslen = 0;
                }
                lastnread = nread;
        }
                }
                lastnread = nread;
        }
-       fprintf(msg, "total length: %qd bytes\n", (long long)tsize);
+       fprintf(msg, "total length: %qu bytes\n", tsize);
        (void)signal(SIGINT, oldsig);
        if (op == COPY || op == COPYVERIFY) {
                writeop(outp, MTWEOF);
                writeop(outp, MTWEOF);
                if (op == COPYVERIFY) {
        (void)signal(SIGINT, oldsig);
        if (op == COPY || op == COPYVERIFY) {
                writeop(outp, MTWEOF);
                writeop(outp, MTWEOF);
                if (op == COPYVERIFY) {
-                       writeop(outp, MTREW);
-                       writeop(inp, MTREW);
+                       rewind_tape(outp);
+                       rewind_tape(inp);
                        verify(inp, outp, buff);
                }
        }
                        verify(inp, outp, buff);
                }
        }
@@ -237,11 +226,11 @@ r1:               guesslen = 0;
 
 void
 verify(inp, outp, outb)
 
 void
 verify(inp, outp, outb)
-       int inp, outp;
-       char *outb;
+       register int inp, outp;
+       register char *outb;
 {
 {
-       int eot, inmaxblk, inn, outmaxblk, outn;
-       char *inb;
+       register int eot, inmaxblk, inn, outmaxblk, outn;
+       register char *inb;
 
        inb = getspace(maxblk);
        inmaxblk = outmaxblk = maxblk;
 
        inb = getspace(maxblk);
        inmaxblk = outmaxblk = maxblk;
@@ -274,15 +263,13 @@ r2:               if (inn != outn) {
                }
                if (!inn) {
                        if (eot++) {
                }
                if (!inn) {
                        if (eot++) {
-                               fprintf(msg, "%s: tapes are identical.\n",
-                                       "tcopy");
+                               fprintf(msg, "tcopy: tapes are identical.\n");
                                return;
                        }
                } else {
                                return;
                        }
                } else {
-                       if (memcmp(inb, outb, inn)) {
+                       if (bcmp(inb, outb, inn)) {
                                fprintf(msg,
                                fprintf(msg,
-                                   "%s: tapes have different data.\n",
-                                       "tcopy");
+                                   "tcopy: tapes have different data.\n");
                                break;
                        }
                        eot = 0;
                                break;
                        }
                        eot = 0;
@@ -293,16 +280,16 @@ r2:               if (inn != outn) {
 
 void
 intr(signo)
 
 void
 intr(signo)
-       int signo;
+       int signo __unused;
 {
        if (record) {
                if (record - lastrec > 1)
 {
        if (record) {
                if (record - lastrec > 1)
-                       fprintf(msg, "records %ld to %ld\n", lastrec, record);
+                       fprintf(msg, "records %qu to %qu\n", lastrec, record);
                else
                else
-                       fprintf(msg, "record %ld\n", lastrec);
+                       fprintf(msg, "record %qu\n", lastrec);
        }
        }
-       fprintf(msg, "interrupt at file %d: record %ld\n", filen, record);
-       fprintf(msg, "total length: %qd bytes\n", (long long)(tsize + size));
+       fprintf(msg, "interrupt at file %d: record %qu\n", filen, record);
+       fprintf(msg, "total length: %ju bytes\n", (uintmax_t)(tsize + size));
        exit(1);
 }
 
        exit(1);
 }
 
@@ -314,7 +301,6 @@ getspace(blk)
 
        if ((bp = malloc((size_t)blk)) == NULL)
                errx(11, "no memory");
 
        if ((bp = malloc((size_t)blk)) == NULL)
                errx(11, "no memory");
-
        return (bp);
 }
 
        return (bp);
 }
 
@@ -330,10 +316,28 @@ writeop(fd, type)
                err(6, "tape op");
 }
 
                err(6, "tape op");
 }
 
-void
+static void
 usage()
 {
 usage()
 {
-
-       fprintf(stderr, "usage: tcopy [-cvx] [-s maxblk] src [dest]\n");
+       fprintf(stderr, "usage: tcopy [-cvx] [-s maxblk] [src [dest]]\n");
        exit(1);
 }
        exit(1);
 }
+
+void
+rewind_tape(int fd)
+{
+       struct stat sp;
+
+       if(fstat(fd, &sp))
+               errx(12, "fstat in rewind");
+
+       /*
+        * don't want to do tape ioctl on regular files:
+        */
+       if( S_ISREG(sp.st_mode) ) {
+               if( lseek(fd, 0, SEEK_SET) == -1 )
+                       errx(13, "lseek");
+       } else
+               /*  assume its a tape   */
+               writeop(fd, MTREW);
+}
index e15f9a6ad09f46a0693b7ebe0d78060913cd6b2a..cf6d8633b2338a1e0f69afc1dfe8f9e9e22c66fc 100644 (file)
@@ -43,7 +43,7 @@
 .Nd change file access and modification times
 .Sh SYNOPSIS
 .Nm
 .Nd change file access and modification times
 .Sh SYNOPSIS
 .Nm
-.Op Fl acfhm
+.Op Fl acfm
 .Op Fl r Ar file
 .Op Fl t Ar [[CC]YY]MMDDhhmm[.SS]
 .Ar
 .Op Fl r Ar file
 .Op Fl t Ar [[CC]YY]MMDDhhmm[.SS]
 .Ar
@@ -70,14 +70,6 @@ No error messages are displayed and the exit value is not affected.
 .It Fl f
 Attempt to force the update, even if the file permissions do not
 currently permit it.
 .It Fl f
 Attempt to force the update, even if the file permissions do not
 currently permit it.
-.It Fl h
-If the file is a symbolic link, change the times of the link
-itself rather than the file that the link points to.
-Note that
-.Fl h
-implies
-.Fl c
-and thus will not create any new files.
 .It Fl m
 Change the modification time of the file.
 The access time of the file is not changed unless the
 .It Fl m
 Change the modification time of the file.
 The access time of the file is not changed unless the
index 5436285c4bd73cb4fac4682c5532338ccdf9e3e5..77ca8e9922bb8fba938714f71b273db1c6a684f0 100644 (file)
@@ -80,7 +80,11 @@ main(int argc, char *argv[])
        if (gettimeofday(&tv[0], NULL))
                err(1, "gettimeofday");
 
        if (gettimeofday(&tv[0], NULL))
                err(1, "gettimeofday");
 
+#ifndef __APPLE__
        while ((ch = getopt(argc, argv, "acfhmr:t:")) != -1)
        while ((ch = getopt(argc, argv, "acfhmr:t:")) != -1)
+#else
+       while ((ch = getopt(argc, argv, "acfmr:t:")) != -1)
+#endif
                switch(ch) {
                case 'a':
                        aflag = 1;
                switch(ch) {
                case 'a':
                        aflag = 1;
@@ -350,6 +354,10 @@ err:                       rval = 1;
 void
 usage(void)
 {
 void
 usage(void)
 {
+#ifndef __APPLE__
        (void)fprintf(stderr, "usage: touch [-acfhm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file ...\n");
        (void)fprintf(stderr, "usage: touch [-acfhm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file ...\n");
+#else
+       (void)fprintf(stderr, "usage: touch [-acfm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file ...\n");
+#endif
        exit(1);
 }
        exit(1);
 }