diff options
Diffstat (limited to 'gnu/usr.bin/tar/extract.c')
-rw-r--r-- | gnu/usr.bin/tar/extract.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gnu/usr.bin/tar/extract.c b/gnu/usr.bin/tar/extract.c index d162cab04ec6..57f82227d886 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) |