From 67b02086d2781dfc5d63db3eef63a629cd4902e8 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sun, 19 Jul 2009 03:57:34 -0400 Subject: [PATCH] Sort short option list, fill in missing -I option, update manpage options to include -0, -J, -j, -lzma, and -h. Since Windows no longer tries to automatically turn on ownership restore, we need --preserve-owner to allow users to manually turn it on. SVN-Revision: 1240 --- cpio/bsdcpio.1 | 29 +++++++++++++++++++++++++++++ cpio/cmdline.c | 3 ++- cpio/cpio.c | 3 +++ cpio/cpio.h | 1 + 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/cpio/bsdcpio.1 b/cpio/bsdcpio.1 index 81b34626b..79b6997ef 100644 --- a/cpio/bsdcpio.1 +++ b/cpio/bsdcpio.1 @@ -80,6 +80,9 @@ specified directory. Unless specifically stated otherwise, options are applicable in all operating modes. .Bl -tag -width indent +.It Fl 0 +Read filenames separated by NUL characters instead of newlines. +This is necessary if any of the filenames being read might contain newlines. .It Fl A (o mode only) Append to the specified archive. @@ -142,6 +145,11 @@ for more complete information about the formats currently supported by the underlying .Xr libarchive 3 library. +.It Fl H Ar format +Synonym for +.Fl -format . +.It Fl h , Fl -help +Print usage information. .It Fl I Ar file Read archive from .Ar file . @@ -154,6 +162,14 @@ Disable security checks during extraction or copying. This allows extraction via symbolic links and path names containing .Sq .. in the name. +.It Fl J +(o mode only) +Compress the file with xz-compatible compression before writing it. +In input mode, this option is ignored; xz compression is recognized +automatically on input. +.It Fl j +Synonym for +.Fl y . .It Fl L (o and p modes) All symbolic links will be followed. @@ -163,6 +179,11 @@ With this option, the target of the link will be archived or copied instead. (p mode only) Create links from the target directory to the original files, instead of copying. +.It Fl lzma +(o mode only) +Compress the file with lzma-compatible compression before writing it. +In input mode, this option is ignored; lzma compression is recognized +automatically on input. .It Fl m (i and p modes) Set file modification time on created files to match @@ -176,6 +197,10 @@ By default, displays the user and group names when they are provided in the archive, or looks up the user and group names in the system password database. +.It Fl no-preserve-owner +(i mode only) +Do not attempt to restore file ownership. +This is the default when run by non-root users. .It Fl O Ar file Write archive to .Ar file . @@ -185,6 +210,10 @@ See above for description. .It Fl p Pass-through mode. See above for description. +.It Fl preserve-owner +(i mode only) +Restore file ownership. +This is the default when run by the root user. .It Fl -quiet Suppress unnecessary messages. .It Fl R Oo user Oc Ns Oo : Oc Ns Oo group Oc diff --git a/cpio/cmdline.c b/cpio/cmdline.c index f090e260b..6dd6082b7 100644 --- a/cpio/cmdline.c +++ b/cpio/cmdline.c @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD: src/usr.bin/cpio/cmdline.c,v 1.5 2008/12/06 07:30:40 kientzl /* * Short options for cpio. Please keep this sorted. */ -static const char *short_options = "0AaBC:F:O:cdE:f:H:hiJjLlmnopR:rtuvW:yZz"; +static const char *short_options = "0AaBC:cdE:F:f:H:hI:iJjLlmnO:opR:rtuvW:yZz"; /* * Long options for cpio. Please keep this sorted. @@ -77,6 +77,7 @@ static const struct option { { "owner", 1, 'R' }, { "pass-through", 0, 'p' }, { "preserve-modification-time", 0, 'm' }, + { "preserve-owner", 0, OPTION_PRESERVE_OWNER }, { "quiet", 0, OPTION_QUIET }, { "unconditional", 0, 'u' }, { "verbose", 0, 'v' }, diff --git a/cpio/cpio.c b/cpio/cpio.c index ae3990a01..88c484bd4 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -261,6 +261,9 @@ main(int argc, char *argv[]) cpio->mode = opt; cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT; break; + case OPTION_PRESERVE_OWNER: + cpio->extract_flags |= ARCHIVE_EXTRACT_OWNER; + break; case OPTION_QUIET: /* GNU cpio */ cpio->quiet = 1; break; diff --git a/cpio/cpio.h b/cpio/cpio.h index 4b38b5ff7..a64dceb8a 100644 --- a/cpio/cpio.h +++ b/cpio/cpio.h @@ -98,6 +98,7 @@ enum { OPTION_INSECURE = 1, OPTION_LZMA, OPTION_NO_PRESERVE_OWNER, + OPTION_PRESERVE_OWNER, OPTION_QUIET, OPTION_VERSION }; -- 2.47.3