From aad783a64f985f1e27c7ffc6e2d3f671323716a9 Mon Sep 17 00:00:00 2001 From: Apple Date: Thu, 20 Apr 2017 19:47:46 +0000 Subject: [PATCH] file_cmds-272.tar.gz --- cp/cp.1 | 2 + cp/cp.c | 10 +++- cp/extern.h | 1 + cp/utils.c | 31 +++++++++-- dd/install_symlink.sh | 2 +- file_cmds.xcodeproj/project.pbxproj | 4 ++ gzip/futimens.c | 100 ++++++++++++++++++++++++++++++++++++ gzip/gzip.1 | 32 ++++++------ gzip/gzip.c | 50 +++++++++++------- gzip/zmore | 23 +++++---- gzip/zmore.1 | 30 ++++++++--- gzip/zuncompress.c | 2 +- mtree/commoncrypto.c | 2 +- rm/rm.c | 6 ++- 14 files changed, 234 insertions(+), 61 deletions(-) create mode 100644 gzip/futimens.c diff --git a/cp/cp.1 b/cp/cp.1 index 6f5507d..8c346c7 100644 --- a/cp/cp.1 +++ b/cp/cp.1 @@ -192,6 +192,8 @@ Cause to be verbose, showing files as they are copied. .It Fl X Do not copy Extended Attributes (EAs) or resource forks. +.It Fl c +copy files using clonefile(2) .El .Pp For each destination file that already exists, its contents are diff --git a/cp/cp.c b/cp/cp.c index 7af6bbc..c856fd9 100644 --- a/cp/cp.c +++ b/cp/cp.c @@ -95,6 +95,7 @@ int fflag, iflag, nflag, pflag, vflag; int Xflag; #endif /* __APPLE__ */ static int Rflag, rflag; + int cflag = 0; volatile sig_atomic_t info; enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE }; @@ -111,8 +112,11 @@ main(int argc, char *argv[]) char *target; Hflag = Lflag = Pflag = 0; - while ((ch = getopt(argc, argv, "HLPRXafinprv")) != -1) + while ((ch = getopt(argc, argv, "cHLPRXafinprv")) != -1) switch (ch) { + case 'c': + cflag = 1; + break; case 'H': Hflag = 1; Lflag = Pflag = 0; @@ -174,6 +178,10 @@ main(int argc, char *argv[]) if (argc < 2) usage(); + if (cflag && Xflag) { + errx(1, "the -c and -X options may not be specified together"); + } + fts_options = FTS_NOCHDIR | FTS_PHYSICAL; if (rflag) { if (Rflag) diff --git a/cp/extern.h b/cp/extern.h index 10a5211..c0ca0bc 100644 --- a/cp/extern.h +++ b/cp/extern.h @@ -41,6 +41,7 @@ extern int fflag, iflag, nflag, pflag, vflag; #ifdef __APPLE__ extern int Xflag; #endif /* __APPLE__ */ +extern int cflag; extern volatile sig_atomic_t info; __BEGIN_DECLS diff --git a/cp/utils.c b/cp/utils.c index a2d031d..afc525a 100644 --- a/cp/utils.c +++ b/cp/utils.c @@ -59,6 +59,8 @@ __FBSDID("$FreeBSD: src/bin/cp/utils.c,v 1.46 2005/09/05 04:36:08 csjp Exp $"); #include #include #include +#include +#include #else #define COMPAT_MODE(a,b) (1) #endif /* __APPLE__ */ @@ -118,6 +120,15 @@ copy_file(const FTSENT *entp, int dne) } } + if (cflag) { + (void)unlink(to.p_path); + int error = clonefile(entp->fts_path, to.p_path, 0); + if (error) + warn("%s: clonefile failed", to.p_path); + (void)close(from_fd); + return error == 0 ? 0 : 1; + } + if (COMPAT_MODE("bin/cp", "unix2003")) { /* first try to overwrite existing destination file name */ to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0); @@ -140,9 +151,19 @@ copy_file(const FTSENT *entp, int dne) /* overwrite existing destination file name */ to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0); } - } else + } else { + + if (cflag) { + int error = clonefile(entp->fts_path, to.p_path, 0); + if (error) + warn("%s: clonefile failed", to.p_path); + (void)close(from_fd); + return error == 0 ? 0 : 1; + } + to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT, fs->st_mode & ~(S_ISUID | S_ISGID)); + } if (to_fd == -1) { warn("%s", to.p_path); @@ -497,13 +518,13 @@ usage(void) if (COMPAT_MODE("bin/cp", "unix2003")) { (void)fprintf(stderr, "%s\n%s\n", -"usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file", -" cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... " +"usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file target_file", +" cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file ... " "target_directory"); } else { (void)fprintf(stderr, "%s\n%s\n", -"usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-apvX] source_file target_file", -" cp [-R [-H | -L | -P]] [-f | -i | -n] [-apvX] source_file ... " +"usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-apvXc] source_file target_file", +" cp [-R [-H | -L | -P]] [-f | -i | -n] [-apvXc] source_file ... " "target_directory"); } exit(EX_USAGE); diff --git a/dd/install_symlink.sh b/dd/install_symlink.sh index 4b8cd15..7e8665f 100644 --- a/dd/install_symlink.sh +++ b/dd/install_symlink.sh @@ -3,7 +3,7 @@ set -e set -x case "$PLATFORM_NAME" in -iphoneos|appletvos|watchos) +iphoneos|appletvos|watchos|bridgeos) ln -hfs /usr/local/bin/dd "$DSTROOT"/bin/dd ;; macosx) diff --git a/file_cmds.xcodeproj/project.pbxproj b/file_cmds.xcodeproj/project.pbxproj index eddbd0a..be7b451 100644 --- a/file_cmds.xcodeproj/project.pbxproj +++ b/file_cmds.xcodeproj/project.pbxproj @@ -185,6 +185,7 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 3E59B9311D4A767600D3128C /* futimens.c in Sources */ = {isa = PBXBuildFile; fileRef = 3E59B9301D4A767600D3128C /* futimens.c */; }; FC8A8A2814B6486E001B97AD /* chflags.c in Sources */ = {isa = PBXBuildFile; fileRef = FCB1BDCC14B6460C0070FACB /* chflags.c */; }; FC8A8BE414B6494B001B97AD /* chflags.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = FCB1BDCB14B6460C0070FACB /* chflags.1 */; }; FC8A8BE514B64958001B97AD /* chmod.c in Sources */ = {isa = PBXBuildFile; fileRef = FCB1BDD014B6460C0070FACB /* chmod.c */; }; @@ -1144,6 +1145,7 @@ /* Begin PBXFileReference section */ 0773099A1A3A4DFE00E9B4EA /* dd.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = dd.entitlements; sourceTree = ""; }; + 3E59B9301D4A767600D3128C /* futimens.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = futimens.c; sourceTree = ""; }; FC8A8B1214B648D7001B97AD /* chmod */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = chmod; sourceTree = BUILT_PRODUCTS_DIR; }; FC8A8B1A14B648E0001B97AD /* chown */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = chown; sourceTree = BUILT_PRODUCTS_DIR; }; FC8A8B2214B648E3001B97AD /* cksum */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = cksum; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1955,6 +1957,7 @@ FDAD947F1808BB3A00B4D5A0 /* gzip */ = { isa = PBXGroup; children = ( + 3E59B9301D4A767600D3128C /* futimens.c */, FDAD94801808BB3A00B4D5A0 /* gzexe */, FDAD94811808BB3A00B4D5A0 /* gzexe.1 */, FDAD94821808BB3A00B4D5A0 /* gzip.1 */, @@ -2899,6 +2902,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 3E59B9311D4A767600D3128C /* futimens.c in Sources */, FDAD949F1808BBB900B4D5A0 /* gzip.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/gzip/futimens.c b/gzip/futimens.c new file mode 100644 index 0000000..08345c3 --- /dev/null +++ b/gzip/futimens.c @@ -0,0 +1,100 @@ +/*- + * Copyright (c) 2015 Jilles Tjoelker + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include + +#ifndef UTIME_NOW +#define UTIME_NOW -1 +#endif + +#ifndef UTIME_OMIT +#define UTIME_OMIT -2 +#endif +int futimens(int fd, const struct timespec times[2]); + +int +futimens(int fd, const struct timespec times[2]) +{ + struct timeval now, tv[2], *tvp; + struct stat sb; + + if (times == NULL || (times[0].tv_nsec == UTIME_NOW && + times[1].tv_nsec == UTIME_NOW)) + tvp = NULL; + else if (times[0].tv_nsec == UTIME_OMIT && + times[1].tv_nsec == UTIME_OMIT) + return (0); + else { + if ((times[0].tv_nsec < 0 || times[0].tv_nsec > 999999999) && + times[0].tv_nsec != UTIME_NOW && + times[0].tv_nsec != UTIME_OMIT) { + errno = EINVAL; + return (-1); + } + if ((times[1].tv_nsec < 0 || times[1].tv_nsec > 999999999) && + times[1].tv_nsec != UTIME_NOW && + times[1].tv_nsec != UTIME_OMIT) { + errno = EINVAL; + return (-1); + } + tv[0].tv_sec = times[0].tv_sec; + tv[0].tv_usec = times[0].tv_nsec / 1000; + tv[1].tv_sec = times[1].tv_sec; + tv[1].tv_usec = times[1].tv_nsec / 1000; + tvp = tv; + if (times[0].tv_nsec == UTIME_OMIT || + times[1].tv_nsec == UTIME_OMIT) { + if (fstat(fd, &sb) == -1) + return (-1); + if (times[0].tv_nsec == UTIME_OMIT) { + tv[0].tv_sec = sb.st_atimespec.tv_sec; + tv[0].tv_usec = sb.st_atimespec.tv_nsec / 1000; + } + if (times[1].tv_nsec == UTIME_OMIT) { + tv[1].tv_sec = sb.st_mtimespec.tv_sec; + tv[1].tv_usec = sb.st_mtimespec.tv_nsec / 1000; + } + } + if (times[0].tv_nsec == UTIME_NOW || + times[1].tv_nsec == UTIME_NOW) { + if (gettimeofday(&now, NULL) == -1) + return (-1); + if (times[0].tv_nsec == UTIME_NOW) + tv[0] = now; + if (times[1].tv_nsec == UTIME_NOW) + tv[1] = now; + } + } + return (futimes(fd, tvp)); +} diff --git a/gzip/gzip.1 b/gzip/gzip.1 index 0157563..98e0ea2 100644 --- a/gzip/gzip.1 +++ b/gzip/gzip.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: gzip.1,v 1.21 2011/06/19 02:22:36 christos Exp $ +.\" $NetBSD: gzip.1,v 1.26 2015/10/27 07:36:18 mrg Exp $ .\" .\" Copyright (c) 1997, 2003, 2004 Matthew R. Green .\" All rights reserved. @@ -24,8 +24,8 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/usr.bin/gzip/gzip.1,v 1.11 2011/10/10 06:37:32 delphij Exp $ -.Dd October 9, 2011 +.\" $FreeBSD: head/usr.bin/gzip/gzip.1 290073 2015-10-27 21:26:05Z delphij $ +.Dd October 26, 2015 .Dt GZIP 1 .Os .Sh NAME @@ -101,17 +101,14 @@ then both the and .Fl d options are enabled. -When invoked as -.Nm zcat , -.Dq .Z -will be appended to all filenames that do not have that suffix. .Pp This version of .Nm is also capable of decompressing files compressed using -.Xr compress 1 +.Xr compress 1 , +.Xr bzip2 1 , or -.Xr bzip2 1 . +.Xr xz 1 . .Sh OPTIONS The following options are available: .Bl -tag -width XXrXXXrecursiveX @@ -139,7 +136,7 @@ option, allowing non-compressed data to pass through unchanged. .It Fl h , -help This option prints a usage summary and exits. .It Fl k , -keep -Keep (don't delete) input files during compression +Keep (do not delete) input files during compression or decompression. .It Fl L , -license This option prints @@ -186,13 +183,18 @@ is set, it is parsed as a white-space separated list of options handled before any options on the command line. Options on the command line will override anything in .Ev GZIP . +.Sh EXIT STATUS +The +.Nm +utility exits 0 on success, +1 on errors, +and 2 if a warning occurs. .Sh SEE ALSO .Xr bzip2 1 , .Xr compress 1 , .Xr xz 1 , .Xr fts 3 , -.Xr zlib 3 , -.Xr compat 5 +.Xr zlib 3 .Sh HISTORY The .Nm @@ -219,12 +221,12 @@ and first appeared in This implementation of .Nm was written by -.An Matthew R. Green Aq mrg@eterna.com.au +.An Matthew R. Green Aq Mt mrg@eterna.com.au with unpack support written by -.An Xin LI Aq delphij@FreeBSD.org . +.An Xin LI Aq Mt delphij@FreeBSD.org . .Sh BUGS According to RFC 1952, the recorded file size is stored in a 32-bit -integer, therefore, it can not represent files larger than 4GB. +integer, therefore, it cannot represent files larger than 4GB. This limitation also applies to .Fl l option of diff --git a/gzip/gzip.c b/gzip/gzip.c index e25262c..3d27266 100644 --- a/gzip/gzip.c +++ b/gzip/gzip.c @@ -1,4 +1,4 @@ -/* $NetBSD: gzip.c,v 1.105 2011/08/30 23:06:00 joerg Exp $ */ +/* $NetBSD: gzip.c,v 1.109 2015/10/27 07:36:18 mrg Exp $ */ /*- * Copyright (c) 1997, 1998, 2003, 2004, 2006 Matthew R. Green @@ -31,7 +31,7 @@ #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1997, 1998, 2003, 2004, 2006\ Matthew R. Green. All rights reserved."); -__FBSDID("$FreeBSD: src/usr.bin/gzip/gzip.c,v 1.25 2011/10/10 06:37:32 delphij Exp $"); +__FBSDID("$FreeBSD: head/usr.bin/gzip/gzip.c 290073 2015-10-27 21:26:05Z delphij $"); #endif /* not lint */ /* @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD: src/usr.bin/gzip/gzip.c,v 1.25 2011/10/10 06:37:32 delphij E #include #include #include +int futimens(int fd, const struct timespec times[2]); #endif /* __APPLE__ */ /* what type of file are we dealing with */ @@ -167,7 +168,7 @@ static suffixes_t suffixes[] = { #ifdef __APPLE__ static const char gzip_version[] = "Apple gzip " GZIP_APPLE_VERSION; #else -static const char gzip_version[] = "FreeBSD gzip 20111009"; +static const char gzip_version[] = "FreeBSD gzip 20150413"; #endif #ifndef SMALL @@ -831,6 +832,7 @@ gz_uncompress(int in, int out, char *pre, size_t prelen, off_t *gsizep, if (in_tot > 0) { maybe_warnx("%s: trailing garbage " "ignored", filename); + exit_value = 2; goto stop; } maybe_warnx("input not gziped (MAGIC0)"); @@ -1091,7 +1093,7 @@ out2: static void copymodes(int fd, const struct stat *sbp, const char *file) { - struct timeval times[2]; + struct timespec times[2]; struct stat sb; /* @@ -1120,14 +1122,14 @@ copymodes(int fd, const struct stat *sbp, const char *file) maybe_warn("couldn't fchmod: %s", file); #ifdef __APPLE__ - TIMESPEC_TO_TIMEVAL(×[0], &sb.st_atimespec); - TIMESPEC_TO_TIMEVAL(×[1], &sb.st_mtimespec); + times[0] = sb.st_atimespec; + times[1] = sb.st_mtimespec; #else - TIMESPEC_TO_TIMEVAL(×[0], &sb.st_atim); - TIMESPEC_TO_TIMEVAL(×[1], &sb.st_mtim); + times[0] = sb.st_atim; + times[1] = sb.st_mtim; #endif - if (futimes(fd, times) < 0) - maybe_warn("couldn't utimes: %s", file); + if (futimens(fd, times) < 0) + maybe_warn("couldn't futimens: %s", file); /* only try flags if they exist already */ if (sb.st_flags != 0 && fchflags(fd, sb.st_flags) < 0) @@ -1412,7 +1414,7 @@ file_uncompress(char *file, char *outfile, size_t outsize) #ifndef SMALL ssize_t rv; time_t timestamp = 0; - unsigned char name[PATH_MAX + 1]; + char name[PATH_MAX + 1]; #endif /* gather the old name info */ @@ -1467,21 +1469,33 @@ file_uncompress(char *file, char *outfile, size_t outsize) timestamp = ts[3] << 24 | ts[2] << 16 | ts[1] << 8 | ts[0]; if (header1[3] & ORIG_NAME) { - rbytes = pread(fd, name, sizeof name, GZIP_ORIGNAME); + rbytes = pread(fd, name, sizeof(name) - 1, GZIP_ORIGNAME); if (rbytes < 0) { maybe_warn("can't read %s", file); goto lose; } - if (name[0] != 0) { + if (name[0] != '\0') { + char *dp, *nf; + + /* Make sure that name is NUL-terminated */ + name[rbytes] = '\0'; + + /* strip saved directory name */ + nf = strrchr(name, '/'); + if (nf == NULL) + nf = name; + else + nf++; + /* preserve original directory name */ - char *dp = strrchr(file, '/'); + dp = strrchr(file, '/'); if (dp == NULL) dp = file; else dp++; snprintf(outfile, outsize, "%.*s%.*s", (int) (dp - file), - file, (int) rbytes, name); + file, (int) rbytes, nf); } } } @@ -1827,7 +1841,7 @@ handle_stdout(void) return; } #endif - /* If stdin is a file use it's mtime, otherwise use current time */ + /* If stdin is a file use its mtime, otherwise use current time */ ret = fstat(STDIN_FILENO, &sb); #ifndef SMALL @@ -2188,9 +2202,9 @@ display_license(void) { #ifdef __APPLE__ - fprintf(stderr, "%s (based on FreeBSD gzip 20111009)\n", gzip_version); + fprintf(stderr, "%s (based on FreeBSD gzip 20150113)\n", gzip_version); #else - fprintf(stderr, "%s (based on NetBSD gzip 20111009)\n", gzip_version); + fprintf(stderr, "%s (based on NetBSD gzip 20150113)\n", gzip_version); #endif fprintf(stderr, "%s\n", gzip_copyright); exit(0); diff --git a/gzip/zmore b/gzip/zmore index 6b55c77..dbdbd3f 100644 --- a/gzip/zmore +++ b/gzip/zmore @@ -1,7 +1,8 @@ #!/bin/sh - # -# $NetBSD: zmore,v 1.3 2004/03/29 09:59:42 wiz Exp $ -# $OpenBSD: zmore,v 1.4 2003/07/29 07:42:45 otto Exp $ +# $NetBSD: zmore,v 1.5 2013/12/06 13:33:15 pettai Exp $ +# +# $OpenBSD: zmore,v 1.6 2008/08/20 09:22:02 mpf Exp $ # #- # Copyright (c) 2003 Todd C. Miller @@ -22,13 +23,7 @@ # Agency (DARPA) and Air Force Research Laboratory, Air Force # Materiel Command, USAF, under agreement number F39502-99-1-0512. # -# $FreeBSD: src/usr.bin/gzip/zmore,v 1.1 2007/01/26 10:19:07 delphij Exp $ - -if [ "$0" = "zless" ]; then -zpager="less" -else -zpager="more" -fi +# $FreeBSD: head/usr.bin/gzip/zmore 273507 2014-10-23 01:22:29Z delphij $ # Pull out any command line flags so we can pass them to more/less flags= @@ -48,15 +43,21 @@ while test $# -ne 0; do esac done +if [ `basename $0` = "zless" ] ; then + pager=${PAGER-less} +else + pager=${PAGER-more} +fi + # No files means read from stdin if [ $# -eq 0 ]; then - gzip -cdfq 2>&1 | ${PAGER-${zpager}} $flags + gzip -cdfq 2>&1 | $pager $flags exit 0 fi oterm=`stty -g 2>/dev/null` while test $# -ne 0; do - gzip -cdfq "$1" 2>&1 | ${PAGER-${zpager}} $flags + gzip -cdfq "$1" 2>&1 | $pager $flags prev="$1" shift if tty -s && test -n "$oterm" -a $# -gt 0; then diff --git a/gzip/zmore.1 b/gzip/zmore.1 index 19e7a03..4723f22 100644 --- a/gzip/zmore.1 +++ b/gzip/zmore.1 @@ -1,5 +1,5 @@ -.\" $NetBSD: zmore.1,v 1.3 2003/12/28 12:47:52 wiz Exp $ -.\" $OpenBSD: zmore.1,v 1.3 2003/06/23 21:00:48 deraadt Exp $ +.\" $NetBSD: zmore.1,v 1.4 2013/11/12 21:58:37 pettai Exp $ +.\" $OpenBSD: zmore.1,v 1.10 2009/08/16 09:41:08 sobrado Exp $ .\" .\" Copyright (c) 2003 Todd C. Miller .\" @@ -19,17 +19,21 @@ .\" Agency (DARPA) and Air Force Research Laboratory, Air Force .\" Materiel Command, USAF, under agreement number F39502-99-1-0512. .\" -.\" $FreeBSD: src/usr.bin/gzip/zmore.1,v 1.3 2012/06/05 03:14:39 eadler Exp $ -.Dd February 6, 2011 +.\" $FreeBSD: head/usr.bin/gzip/zmore.1 273507 2014-10-23 01:22:29Z delphij $ +.Dd October 22, 2014 .Dt ZMORE 1 .Os .Sh NAME -.Nm zmore +.Nm zmore , +.Nm zless .Nd view compressed files .Sh SYNOPSIS .Nm zmore .Op Ar flags -.Op Ar file ... +.Op Ar +.Nm zless +.Op Ar flags +.Op Ar .Sh DESCRIPTION .Nm is a filter that allows the viewing of files compressed with Lempel-Ziv @@ -51,6 +55,14 @@ that are specified are passed to the user's preferred .Pa /usr/bin/more by default). .Pp +.Nm zless +is equivalent to +.Nm zmore +but uses +.Xr less 1 +as a pager instead of +.Xr more 1 . +.Pp When multiple files are specified, .Nm will pause at the end of each file and present the following prompt to the user: @@ -86,7 +98,11 @@ style compression since there is no suffix on which to make a decision. Program used to display files. If unset, .Pa /usr/bin/more -is used. +is used +.Pq Nm zmore +or +.Pa /usr/bin/less +.Pq Nm zless . .El .Sh SEE ALSO .Xr compress 1 , diff --git a/gzip/zuncompress.c b/gzip/zuncompress.c index 454f05b..06df597 100644 --- a/gzip/zuncompress.c +++ b/gzip/zuncompress.c @@ -145,7 +145,7 @@ zuncompress(FILE *in, FILE *out, char *pre, size_t prelen, else compressed_pre = NULL; - while ((bin = fread(buf, 1, sizeof(buf), in)) != 0) { + while ((bin = fread(buf, 1, BUFSIZE, in)) != 0) { if (tflag == 0 && (off_t)fwrite(buf, 1, bin, out) != bin) { free(buf); return -1; diff --git a/mtree/commoncrypto.c b/mtree/commoncrypto.c index 88efada..f755631 100644 --- a/mtree/commoncrypto.c +++ b/mtree/commoncrypto.c @@ -143,7 +143,7 @@ char *SHA256_Path_XATTRs(char *path, char *buf) bzero(xattrBuf, xattrBufLen); result = getxattr(path, name, xattrBuf, xattrBufLen, 0, options); if (result < 0) - err(1, "SHA256_Path_XATTRs: getxattr"); + err(1, "SHA256_Path_XATTRs getxattr of \"%s\" at path \"%s\" failed with error", name, path ); digest = SHA256_Data(xattrBuf, xattrBufLen, buf); if (!digest) diff --git a/rm/rm.c b/rm/rm.c index ec13b2a..9022802 100644 --- a/rm/rm.c +++ b/rm/rm.c @@ -534,7 +534,11 @@ checkdot(argv) char truncated[len]; if ((p = strrchr(*t, '/')) != NULL) { - if (p[1] == '\0') { // trailing / -- treat as if not present + if (p[1] == '\0') { // one or more trailing / -- treat as if not present + for (; (p > *t) && (p[-1] == '/');) { + len--; + p--; + } strlcpy(truncated, *t, len); p = strrchr(truncated, '/'); if (p) { -- 2.7.4