.\" Copyright (c) 2003-2007 Tim Kientzle
+.\" Copyright (c) 2017 Martin Matuska
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\"
.\" $FreeBSD$
.\"
-.Dd September 16, 2014
+.Dd February 23, 2017
.Dt TAR 1
.Os
.Sh NAME
all operating modes.
.Bl -tag -width indent
.It Cm @ Ns Pa archive
-(c and r mode only)
+(c and r modes only)
The specified archive is opened and the entries
in it will be appended to the current archive.
As a simple example,
.Dl Nm Fl a Fl jcf Pa archive.xxx source.c source.h
if it is unknown suffix or no suffix, creates a new archive with
restricted pax format and bzip2 compression.
+.It Fl Fl acls
+(c, r, u, x modes only)
+Archive or extract ACLs. This is the reverse of
+.Fl Fl no-acls
+and the default behavior in c, r, and u modes or if
+.Nm
+is run in x mode as root.
.It Fl B , Fl Fl read-full-blocks
Ignored for compatibility with other
.Xr tar 1
(x mode only)
Before removing file system objects to replace them, clear platform-specific
file flags that might prevent removal.
-.It Fl Fl disable-copyfile
-Mac OS X specific.
-Disable the use of
-.Xr copyfile 3 .
.It Fl Fl exclude Ar pattern
Do not process files or directories that match the
specified pattern.
Note that exclusions take precedence over patterns or filenames
specified on the command line.
+.It Fl Fl fflags
+(c, r, u, x modes only)
+Archive or extract file flags. This is the reverse of
+.Fl Fl no-fflags
+and the default behavior in c, r, and u modes or if
+.Nm
+is run in x mode as root.
.It Fl Fl format Ar format
(c, r, u mode only)
Use the specified format for the created archive.
in the archive;
the name will not be verified against the system group database.
.It Fl H
-(c and r mode only)
+(c and r modes only)
Symbolic links named on the command line will be followed; the
target of the link will be archived, not the link itself.
.It Fl h
-(c and r mode only)
+(c and r modes only)
Synonym for
.Fl L .
.It Fl I
Show usage.
.It Fl Fl hfsCompression
(x mode only)
-Mac OS X specific(v10.6 or later). Compress extracted regular files with HFS+ compression.
+Mac OS X specific (v10.6 or later). Compress extracted regular files with HFS+
+compression.
.It Fl Fl ignore-zeros
An alias of
.Fl Fl options Cm read_concatenated_archives
Do not overwrite existing files that are newer than the
versions appearing in the archive being extracted.
.It Fl L , Fl Fl dereference
-(c and r mode only)
+(c and r modes only)
All symbolic links will be followed.
Normally, symbolic links are archived as such.
With this option, the target of the link will be archived instead.
(x mode only)
Do not extract modification time.
By default, the modification time is set to the time stored in the archive.
+.It Fl Fl mac-metadata
+(c, r, u and x mode only)
+Mac OS X specific. Archive or extract ACLs and extended attributes using
+.Xr copyfile 3
+in AppleDouble format. This is the reverse of
+.Fl Fl no-mac-metadata .
+and the default behavior in c, r, and u modes or if
+.Nm
+is run in x mode as root.
.It Fl n , Fl Fl norecurse , Fl Fl no-recursion
(c, r, u modes only)
Do not recursively archive the contents of directories.
.Fl print0
option to
.Xr find 1 .
+.It Fl Fl no-acls
+(c, r, u, x modes only)
+Do not archive or extract ACLs. This is the reverse of
+.Fl Fl acls
+and the default behavior if
+.Nm
+is run as non-root in x mode.
+.It Fl Fl no-fflags
+(c, r, u, x modes only)
+Do not archive or extract file flags. This is the reverse of
+.Fl Fl fflags
+and the default behavior if
+.Nm
+is run as non-root in x mode.
+.It Fl Fl no-mac-metadata
+(x mode only)
+Mac OS X specific. Do not archive or extract ACLs and extended attributes using
+.Xr copyfile 3
+in AppleDouble format. This is the reverse of
+.Fl Fl mac-metadata .
+and the default behavior if
+.Nm
+is run as non-root in x mode.
+.It Fl n , Fl Fl norecurse , Fl Fl no-recursion
.It Fl Fl no-same-owner
(x mode only)
Do not extract owner and group IDs.
.Fl p
and the default behavior if
.Nm
-is run as non-root.
+is run as non-root and can be overridden by also specifying
+.Fl Fl acls ,
+.Fl Fl fflags ,
+.Fl Fl mac-metadata,
+.Fl Fl same-owner ,
+.Fl Fl same-permissions
+and
+.Fl Fl xattrs .
+.It Fl Fl no-xattrs
+(c, r, u, x modes only)
+Do not archive or extract extended attributes. This is the reverse of
+.Fl Fl xattrs
+and the default behavior if
+.Nm
+is run as non-root in x mode.
.It Fl Fl numeric-owner
This is equivalent to
.Fl Fl uname
.It Fl p , Fl Fl insecure , Fl Fl preserve-permissions
(x mode only)
Preserve file permissions.
-Attempt to restore the full permissions, including owner, file modes, file
-flags and ACLs, if available, for each item extracted from the archive.
-This is the default, if
+Attempt to restore the full permissions, including owner, file modes, ACLs,
+extended atributes and extended file flags, if available, for each item
+extracted from the archive. This is the default, if
.Nm
is being run by root and can be overridden by also specifying
-.Fl Fl no-same-owner
+.Fl Fl no-acls ,
+.Fl Fl no-fflags ,
+.Fl Fl no-mac-metadata,
+.Fl Fl no-same-owner ,
+.Fl Fl no-same-permissions
and
-.Fl Fl no-same-permissions .
+.Fl Fl no-xattrs .
.It Fl Fl passphrase Ar passphrase
The
.Pa passphrase
.Fl n
as well.
.It Fl Fl totals
-(c, r, u mode only)
+(c, r, u modes only)
After archiving all files, print a summary to stderr.
.It Fl U , Fl Fl unlink , Fl Fl unlink-first
(x mode only)
See
.Fl Fl exclude
for more information about the handling of exclusions.
+.It Fl Fl xattrs
+(c, r, u, x modes only)
+Archive or extract extended attributes. This is the reverse of
+.Fl Fl no-xattrs
+and the default behavior in c, r, and u modes or if
+.Nm
+is run in x mode as root.
.It Fl y
(c mode only)
Compress the resulting archive with
case 'a': /* GNU tar */
bsdtar->flags |= OPTFLAG_AUTO_COMPRESS;
break;
+ case OPTION_ACLS: /* GNU tar */
+ bsdtar->extract_flags |= ARCHIVE_EXTRACT_ACL;
+ bsdtar->readdisk_flags &= ~ARCHIVE_READDISK_NO_ACL;
+ bsdtar->flags |= OPTFLAG_ACLS;
+ break;
case 'B': /* GNU tar */
/* libarchive doesn't need this; just ignore it. */
break;
bsdtar->extract_flags |=
ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS;
break;
- case OPTION_DISABLE_COPYFILE: /* Mac OS X */
- bsdtar->readdisk_flags &= ~ARCHIVE_READDISK_MAC_COPYFILE;
- break;
case OPTION_EXCLUDE: /* GNU tar */
if (archive_match_exclude_pattern(
bsdtar->matching, bsdtar->argument) != ARCHIVE_OK)
lafe_errc(1, 0,
"Couldn't exclude %s\n", bsdtar->argument);
break;
+ case OPTION_FFLAGS:
+ bsdtar->extract_flags |= ARCHIVE_EXTRACT_FFLAGS;
+ bsdtar->readdisk_flags &= ~ARCHIVE_READDISK_NO_FFLAGS;
+ bsdtar->flags |= OPTFLAG_FFLAGS;
+ break;
case OPTION_FORMAT: /* GNU tar, others */
cset_set_format(bsdtar->cset, bsdtar->argument);
break;
case 'm': /* SUSv2 */
bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_TIME;
break;
+ case OPTION_MAC_METADATA: /* Mac OS X */
+ bsdtar->readdisk_flags |= ARCHIVE_READDISK_MAC_COPYFILE;
+ bsdtar->extract_flags |= ARCHIVE_EXTRACT_MAC_METADATA;
+ bsdtar->flags |= OPTFLAG_MAC_METADATA;
+ break;
case 'n': /* GNU tar */
bsdtar->flags |= OPTFLAG_NO_SUBDIRS;
break;
bsdtar->extract_flags |=
ARCHIVE_EXTRACT_NO_HFS_COMPRESSION;
break;
+ case OPTION_NO_ACLS: /* GNU tar */
+ bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_ACL;
+ bsdtar->readdisk_flags |= ARCHIVE_READDISK_NO_ACL;
+ bsdtar->flags |= OPTFLAG_NO_ACLS;
+ break;
+ case OPTION_NO_FFLAGS:
+ bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_FFLAGS;
+ bsdtar->readdisk_flags |= ARCHIVE_READDISK_NO_FFLAGS;
+ bsdtar->flags |= OPTFLAG_NO_FFLAGS;
+ break;
+ case OPTION_NO_MAC_METADATA: /* Mac OS X */
+ bsdtar->readdisk_flags &= ~ARCHIVE_READDISK_MAC_COPYFILE;
+ bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_MAC_METADATA;
+ bsdtar->flags |= OPTFLAG_NO_MAC_METADATA;
+ break;
case OPTION_NO_SAME_OWNER: /* GNU tar */
bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_OWNER;
break;
bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_FFLAGS;
bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_MAC_METADATA;
break;
- case OPTION_NO_XATTR: /* Issue #131 */
+ case OPTION_NO_XATTRS: /* GNU tar */
bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_XATTR;
bsdtar->readdisk_flags |= ARCHIVE_READDISK_NO_XATTR;
- bsdtar->flags |= OPTFLAG_NO_XATTR;
+ bsdtar->flags |= OPTFLAG_NO_XATTRS;
break;
case OPTION_NULL: /* GNU tar */
bsdtar->flags |= OPTFLAG_NULL;
case 'x': /* SUSv2 */
set_mode(bsdtar, opt);
break;
+ case OPTION_XATTRS: /* GNU tar */
+ bsdtar->extract_flags |= ARCHIVE_EXTRACT_XATTR;
+ bsdtar->readdisk_flags &= ~ARCHIVE_READDISK_NO_XATTR;
+ bsdtar->flags |= OPTFLAG_XATTRS;
+ break;
case 'y': /* FreeBSD version of GNU tar */
if (compression != '\0')
lafe_errc(1, 0,
only_mode(bsdtar, "--nopreserveHFSCompression", "x");
if (bsdtar->readdisk_flags & ARCHIVE_READDISK_HONOR_NODUMP)
only_mode(bsdtar, "--nodump", "cru");
- if (bsdtar->flags & OPTFLAG_NO_XATTR)
- only_mode(bsdtar, "--no-xattr", "crux");
+ if (bsdtar->flags & OPTFLAG_ACLS)
+ only_mode(bsdtar, "--acls", "crux");
+ if (bsdtar->flags & OPTFLAG_NO_ACLS)
+ only_mode(bsdtar, "--no-acls", "crux");
+ if (bsdtar->flags & OPTFLAG_XATTRS)
+ only_mode(bsdtar, "--xattrs", "crux");
+ if (bsdtar->flags & OPTFLAG_NO_XATTRS)
+ only_mode(bsdtar, "--no-xattrs", "crux");
+ if (bsdtar->flags & OPTFLAG_FFLAGS)
+ only_mode(bsdtar, "--fflags", "crux");
+ if (bsdtar->flags & OPTFLAG_NO_FFLAGS)
+ only_mode(bsdtar, "--no-fflags", "crux");
+ if (bsdtar->flags & OPTFLAG_MAC_METADATA)
+ only_mode(bsdtar, "--mac-metadata", "crux");
+ if (bsdtar->flags & OPTFLAG_NO_MAC_METADATA)
+ only_mode(bsdtar, "--no-mac-metadata", "crux");
if (bsdtar->flags & OPTFLAG_O) {
switch (bsdtar->mode) {
case 'c':
int bytes_per_block; /* -b block_size */
int bytes_in_last_block; /* See -b handling. */
int verbose; /* -v */
- int flags; /* Bitfield of boolean options */
+ unsigned int flags; /* Bitfield of boolean options */
int extract_flags; /* Flags for extract operation */
int readdisk_flags; /* Flags for read disk operation */
int strip_components; /* Remove this many leading dirs */
#define OPTFLAG_TOTALS (0x00001000) /* --totals */
#define OPTFLAG_UNLINK_FIRST (0x00002000) /* -U */
#define OPTFLAG_WARN_LINKS (0x00004000) /* --check-links */
-#define OPTFLAG_NO_XATTR (0x00008000) /* --no-xattr */
+#define OPTFLAG_NO_XATTRS (0x00008000) /* --no-xattrs */
+#define OPTFLAG_XATTRS (0x00010000) /* --xattrs */
+#define OPTFLAG_NO_ACLS (0x00020000) /* --no-acls */
+#define OPTFLAG_ACLS (0x00040000) /* --acls */
+#define OPTFLAG_NO_FFLAGS (0x00080000) /* --no-fflags */
+#define OPTFLAG_FFLAGS (0x00100000) /* --fflags */
+#define OPTFLAG_NO_MAC_METADATA (0x00200000) /* --no-mac-metadata */
+#define OPTFLAG_MAC_METADATA (0x00400000) /* --mac-metadata */
/* Fake short equivalents for long options that otherwise lack them. */
enum {
- OPTION_B64ENCODE = 1,
+ OPTION_ACLS = 1,
+ OPTION_B64ENCODE,
OPTION_CHECK_LINKS,
OPTION_CHROOT,
OPTION_CLEAR_NOCHANGE_FFLAGS,
- OPTION_DISABLE_COPYFILE,
OPTION_EXCLUDE,
+ OPTION_FFLAGS,
OPTION_FORMAT,
OPTION_GID,
OPTION_GNAME,
OPTION_LZIP,
OPTION_LZMA,
OPTION_LZOP,
+ OPTION_MAC_METADATA,
OPTION_NEWER_CTIME,
OPTION_NEWER_CTIME_THAN,
OPTION_NEWER_MTIME,
OPTION_NEWER_MTIME_THAN,
OPTION_NODUMP,
OPTION_NOPRESERVE_HFS_COMPRESSION,
+ OPTION_NO_ACLS,
+ OPTION_NO_FFLAGS,
+ OPTION_NO_MAC_METADATA,
OPTION_NO_SAME_OWNER,
OPTION_NO_SAME_PERMISSIONS,
- OPTION_NO_XATTR,
+ OPTION_NO_XATTRS,
OPTION_NULL,
OPTION_NUMERIC_OWNER,
OPTION_OLDER_CTIME,
OPTION_UNAME,
OPTION_USE_COMPRESS_PROGRAM,
OPTION_UUENCODE,
- OPTION_VERSION
+ OPTION_VERSION,
+ OPTION_XATTRS
};
int bsdtar_getopt(struct bsdtar *);
} tar_longopts[] = {
{ "absolute-paths", 0, 'P' },
{ "append", 0, 'r' },
+ { "acls", 0, OPTION_ACLS },
{ "auto-compress", 0, 'a' },
{ "b64encode", 0, OPTION_B64ENCODE },
{ "block-size", 1, 'b' },
{ "create", 0, 'c' },
{ "dereference", 0, 'L' },
{ "directory", 1, 'C' },
- { "disable-copyfile", 0, OPTION_DISABLE_COPYFILE },
+ { "disable-copyfile", 0, OPTION_NO_MAC_METADATA },
{ "exclude", 1, OPTION_EXCLUDE },
{ "exclude-from", 1, 'X' },
{ "extract", 0, 'x' },
{ "fast-read", 0, 'q' },
+ { "fflags", 0, OPTION_FFLAGS },
{ "file", 1, 'f' },
{ "files-from", 1, 'T' },
{ "format", 1, OPTION_FORMAT },
{ "lzip", 0, OPTION_LZIP },
{ "lzma", 0, OPTION_LZMA },
{ "lzop", 0, OPTION_LZOP },
+ { "mac-metadata", 0, OPTION_MAC_METADATA },
{ "modification-time", 0, 'm' },
{ "newer", 1, OPTION_NEWER_CTIME },
{ "newer-ctime", 1, OPTION_NEWER_CTIME },
{ "newer-mtime", 1, OPTION_NEWER_MTIME },
{ "newer-mtime-than", 1, OPTION_NEWER_MTIME_THAN },
{ "newer-than", 1, OPTION_NEWER_CTIME_THAN },
+ { "no-acls", 0, OPTION_NO_ACLS },
+ { "no-fflags", 0, OPTION_NO_FFLAGS },
+ { "no-mac-metadata", 0, OPTION_NO_MAC_METADATA },
{ "no-recursion", 0, 'n' },
{ "no-same-owner", 0, OPTION_NO_SAME_OWNER },
{ "no-same-permissions", 0, OPTION_NO_SAME_PERMISSIONS },
- { "no-xattr", 0, OPTION_NO_XATTR },
+ { "no-xattr", 0, OPTION_NO_XATTRS },
+ { "no-xattrs", 0, OPTION_NO_XATTRS },
{ "nodump", 0, OPTION_NODUMP },
{ "nopreserveHFSCompression",0, OPTION_NOPRESERVE_HFS_COMPRESSION },
{ "norecurse", 0, 'n' },
{ "uuencode", 0, OPTION_UUENCODE },
{ "verbose", 0, 'v' },
{ "version", 0, OPTION_VERSION },
+ { "xattrs", 0, OPTION_XATTRS },
{ "xz", 0, 'J' },
{ NULL, 0, 0 }
};