summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1994-06-28 07:12:43 +0000
committerjkh <jkh@FreeBSD.org>1994-06-28 07:12:43 +0000
commit032e36e1c30eb07d06117e3236c96edc221d55b5 (patch)
tree65745794a3ea02361c901ee53cd469597d2f4456 /gnu/usr.bin
parent0e44d1d495f88a0403d246e39ad2cf19a19c4114 (diff)
downloadFreeBSD-src-032e36e1c30eb07d06117e3236c96edc221d55b5.zip
FreeBSD-src-032e36e1c30eb07d06117e3236c96edc221d55b5.tar.gz
Add Chris Demetriou's --unlink changes.
I know that I said earlier that this should be unconditional behaviour, but I thought about it a little more and concluded that the principle of least surprise dictates that I make it an option.
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r--gnu/usr.bin/tar/extract.c36
-rw-r--r--gnu/usr.bin/tar/tar.c3
-rw-r--r--gnu/usr.bin/tar/tar.h1
3 files changed, 40 insertions, 0 deletions
diff --git a/gnu/usr.bin/tar/extract.c b/gnu/usr.bin/tar/extract.c
index d162cab..57f8222 100644
--- a/gnu/usr.bin/tar/extract.c
+++ b/gnu/usr.bin/tar/extract.c
@@ -310,6 +310,14 @@ extract_archive ()
fd = 1;
goto extract_file;
}
+
+ if (f_unlink && !f_keep) {
+ if (unlink(skipcrud + current_file_name) == -1)
+ if (errno != ENOENT)
+ msg_perror ("Could not unlink %s",
+ skipcrud + current_file_name);
+ }
+
#ifdef O_CTG
/*
* Contiguous files (on the Masscomp) have to specify
@@ -556,6 +564,13 @@ extract_archive ()
{
struct stat st1, st2;
+ if (f_unlink && !f_keep) {
+ if (unlink(skipcrud + current_file_name) == -1)
+ if (errno != ENOENT)
+ msg_perror ("Could not unlink %s",
+ skipcrud + current_file_name);
+ }
+
check = link (current_link_name, skipcrud + current_file_name);
if (check == 0)
@@ -578,6 +593,13 @@ extract_archive ()
#ifdef S_ISLNK
case LF_SYMLINK:
again_symlink:
+ if (f_unlink && !f_keep) {
+ if (unlink(skipcrud + current_file_name) == -1)
+ if (errno != ENOENT)
+ msg_perror ("Could not unlink %s",
+ skipcrud + current_file_name);
+ }
+
check = symlink (current_link_name,
skipcrud + current_file_name);
/* FIXME, don't worry uid, gid, etc... */
@@ -602,6 +624,13 @@ extract_archive ()
#endif
#if defined(S_IFCHR) || defined(S_IFBLK)
make_node:
+ if (f_unlink && !f_keep) {
+ if (unlink(skipcrud + current_file_name) == -1)
+ if (errno != ENOENT)
+ msg_perror ("Could not unlink %s",
+ skipcrud + current_file_name);
+ }
+
check = mknod (current_file_name + skipcrud,
(int) hstat.st_mode, (int) hstat.st_rdev);
if (check != 0)
@@ -619,6 +648,13 @@ extract_archive ()
/* If local system doesn't support FIFOs, use default case */
case LF_FIFO:
make_fifo:
+ if (f_unlink && !f_keep) {
+ if (unlink(skipcrud + current_file_name) == -1)
+ if (errno != ENOENT)
+ msg_perror ("Could not unlink %s",
+ skipcrud + current_file_name);
+ }
+
check = mkfifo (current_file_name + skipcrud,
(int) hstat.st_mode);
if (check != 0)
diff --git a/gnu/usr.bin/tar/tar.c b/gnu/usr.bin/tar/tar.c
index 9382582..ec2c3d1 100644
--- a/gnu/usr.bin/tar/tar.c
+++ b/gnu/usr.bin/tar/tar.c
@@ -181,6 +181,8 @@ struct option long_options[] =
{"force-local", 0, &f_force_local, 1},
{"atime-preserve", 0, &f_atime_preserve, 1},
+ {"unlink", 0, &f_unlink, 1},
+
{0, 0, 0, 0}
};
@@ -757,6 +759,7 @@ Other options:\n\
filter the archive through PROG (which must accept -d)\n\
--block-compress block the output of compression program for tapes\n\
-[0-7][lmh] specify drive and density\n\
+--unlink unlink files before creating them\n\
", stdout);
}
diff --git a/gnu/usr.bin/tar/tar.h b/gnu/usr.bin/tar/tar.h
index c3fec78..46d29d8 100644
--- a/gnu/usr.bin/tar/tar.h
+++ b/gnu/usr.bin/tar/tar.h
@@ -231,6 +231,7 @@ TAR_EXTERN char *f_volno_file; /* --volno-file */
TAR_EXTERN int f_force_local; /* --force-local */
TAR_EXTERN int f_atime_preserve;/* --atime-preserve */
TAR_EXTERN int f_compress_block; /* --compress-block */
+TAR_EXTERN int f_unlink; /* --unlink */
/*
* We default to Unix Standard format rather than 4.2BSD tar format.
OpenPOWER on IntegriCloud