From 11cb66c391be342548ce819897cf17f573babc00 Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Tue, 10 Feb 2015 17:43:10 +0000 Subject: [PATCH] Add a new tar option --clear-nochange-fflags that causes file system flags which might prevent the removal or modifiction of files to be cleared before attempting to remove them. Sponsored by: DARPA, AFRL --- tar/bsdtar.1 | 4 ++++ tar/bsdtar.c | 4 ++++ tar/bsdtar.h | 1 + tar/cmdline.c | 1 + 4 files changed, 10 insertions(+) diff --git a/tar/bsdtar.1 b/tar/bsdtar.1 index 09402400f..9e45f191d 100644 --- a/tar/bsdtar.1 +++ b/tar/bsdtar.1 @@ -184,6 +184,10 @@ but before extracting entries from the archive. to the current directory after processing any .Fl C options and before extracting any files. +.It Fl Fl clear-nochange-fflags +(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 diff --git a/tar/bsdtar.c b/tar/bsdtar.c index a8c846b0c..93bf60a94 100644 --- a/tar/bsdtar.c +++ b/tar/bsdtar.c @@ -290,6 +290,10 @@ main(int argc, char **argv) case OPTION_CHROOT: /* NetBSD */ bsdtar->option_chroot = 1; break; + case OPTION_CLEAR_NOCHANGE_FFLAGS: + bsdtar->extract_flags |= + ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS; + break; case OPTION_DISABLE_COPYFILE: /* Mac OS X */ bsdtar->readdisk_flags &= ~ARCHIVE_READDISK_MAC_COPYFILE; break; diff --git a/tar/bsdtar.h b/tar/bsdtar.h index 8e64b0a79..c05bfe888 100644 --- a/tar/bsdtar.h +++ b/tar/bsdtar.h @@ -119,6 +119,7 @@ enum { OPTION_B64ENCODE = 1, OPTION_CHECK_LINKS, OPTION_CHROOT, + OPTION_CLEAR_NOCHANGE_FFLAGS, OPTION_DISABLE_COPYFILE, OPTION_EXCLUDE, OPTION_FORMAT, diff --git a/tar/cmdline.c b/tar/cmdline.c index bb905812d..fd0712a0d 100644 --- a/tar/cmdline.c +++ b/tar/cmdline.c @@ -74,6 +74,7 @@ static const struct bsdtar_option { { "cd", 1, 'C' }, { "check-links", 0, OPTION_CHECK_LINKS }, { "chroot", 0, OPTION_CHROOT }, + { "clear-nochange-fflags", 0, OPTION_CLEAR_NOCHANGE_FFLAGS }, { "compress", 0, 'Z' }, { "confirmation", 0, 'w' }, { "create", 0, 'c' }, -- 2.47.2