.Nd change file modes
.Sh SYNOPSIS
.Nm
-.Op Fl fhv
+.Op Fl fv
.Op Fl R Op Fl H | L | P
.Ar mode
.Ar
.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
set = NULL;
omode = 0;
Hflag = Lflag = Rflag = fflag = hflag = vflag = 0;
+#ifndef __APPLE__
while ((ch = getopt(argc, argv, "HLPRXfghorstuvwx")) != -1)
+#else
+ while ((ch = getopt(argc, argv, "HLPRXfgorstuvwx")) != -1)
+#endif
switch (ch) {
case 'H':
Hflag = 1;
.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
.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
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
.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
ischown = (strcmp(cp, "chown") == 0);
Hflag = Lflag = Rflag = fflag = hflag = vflag = 0;
+#ifndef __APPLE__
while ((ch = getopt(argc, argv, "HLPRfhv")) != -1)
+#else
+ while ((ch = getopt(argc, argv, "HLPRfv")) != -1)
+#endif
switch (ch) {
case 'H':
Hflag = 1;
case 'f':
fflag = 1;
break;
+#ifndef __APPLE__
case 'h':
hflag = 1;
- break;
+ break;
+#endif
case 'v':
vflag = 1;
break;
" 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 ...");
+#else
+ "usage: chgrp [-fv] [-R [-H | -L | -P]] group file ...");
+#endif
exit(1);
}
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;
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",
-vpath stat_flags.c ../ls
-
-CFILES += stat_flags.c
-
include $(CoreOSMakefiles)/ProjectBuilder/Makefile.Preamble.Common
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 *));
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"
+
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
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;
-#endif
continue;
}
/*
#include <errno.h>
#include <fts.h>
#include <math.h>
-#ifndef __APPLE__
#include <langinfo.h>
-#endif /* __APPLE__ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const char *format;
static int d_first = -1;
-#ifndef __APPLE__
if (d_first < 0)
d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
-#endif /* __APPLE__ */
if (now == 0)
now = time(NULL);
+++ /dev/null
-/* $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);
-}
.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
-.Nm ""
+.Nm
.Ar name
.Op Cm c | Cm b
.Ar number
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"
-vpath stat_flags.c ../ls
-CFILES += stat_flags.c
include $(CoreOSMakefiles)/ProjectBuilder/Makefile.Preamble.Common
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
group_from_gid(sp->st_gid, 0),
*flagsp ? flagsp : "", *flagsp ? " " : "",
path);
-#ifndef __APPLE__
free(flagsp);
-#endif
}
(void)fflush(stderr);
-.\" $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.
.\"
.\" 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
-.Os BSD 4.3
+.Os
.Sh NAME
.Nm tcopy
.Nd copy and/or verify mag tapes
.Oo Ar src Op Ar dest
.Oc
.Sh DESCRIPTION
+The
.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.
+The
.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
.Ar maxblk .
.It Fl v
Given the two tapes,
-.ar src
+.Ar src
and
.Ar dest
verify that they are identical.
.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
-/* $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
*/
#include <sys/cdefs.h>
+
#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
-#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
-__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 <err.h>
#include <errno.h>
-#include <paths.h>
#include <fcntl.h>
+#include <paths.h>
#include <signal.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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 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;
- 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) {
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)
- err(1, inf);
+ err(1, "%s", inf);
buff = getspace(maxblk);
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)
- fprintf(msg, "%ld records\n", record);
+ fprintf(msg, "%qu records\n", record);
else if (record - lastrec > 1)
- fprintf(msg, "records %ld to %ld\n",
+ fprintf(msg, "records %qu to %qu\n",
lastrec, record);
else
- fprintf(msg, "record %ld\n", lastrec);
+ fprintf(msg, "record %qu\n", lastrec);
}
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;
}
}
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;
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;
}
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) {
- writeop(outp, MTREW);
- writeop(inp, MTREW);
+ rewind_tape(outp);
+ rewind_tape(inp);
verify(inp, outp, buff);
}
}
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;
}
if (!inn) {
if (eot++) {
- fprintf(msg, "%s: tapes are identical.\n",
- "tcopy");
+ fprintf(msg, "tcopy: tapes are identical.\n");
return;
}
} else {
- if (memcmp(inb, outb, inn)) {
+ if (bcmp(inb, outb, inn)) {
fprintf(msg,
- "%s: tapes have different data.\n",
- "tcopy");
+ "tcopy: tapes have different data.\n");
break;
}
eot = 0;
void
intr(signo)
- int signo;
+ int signo __unused;
{
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
- 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);
}
if ((bp = malloc((size_t)blk)) == NULL)
errx(11, "no memory");
-
return (bp);
}
err(6, "tape op");
}
-void
+static void
usage()
{
-
- fprintf(stderr, "usage: tcopy [-cvx] [-s maxblk] src [dest]\n");
+ fprintf(stderr, "usage: tcopy [-cvx] [-s maxblk] [src [dest]]\n");
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);
+}
.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
.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
if (gettimeofday(&tv[0], NULL))
err(1, "gettimeofday");
+#ifndef __APPLE__
while ((ch = getopt(argc, argv, "acfhmr:t:")) != -1)
+#else
+ while ((ch = getopt(argc, argv, "acfmr:t:")) != -1)
+#endif
switch(ch) {
case 'a':
aflag = 1;
void
usage(void)
{
+#ifndef __APPLE__
(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);
}