From 49898835fde9dc8ceb25f21cda6fb9541961c05f Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Tue, 25 Apr 2017 13:20:07 +0300 Subject: [PATCH] Ticket #2297: show empty directories in incremental tar archives. How to reproduce: 1. Create two tar files with empty dir: $ mkdir -p dir/dir1; mkdir dir/dir2; touch dir/dir1/file $ tar cf normal.tar dir/ $ tar cf incremental.tar -g incremental.snap dir/ 2. Press Enter to enter to normal.tar. Result: normal.tar contains dir/dir2, incremental.tar doesn't. Expected result: incremental.tar contains dir/dir2. This patch also fixes Ticket #3709: Wrong directories owner for tar --numeric-owner -g. How to reproduce: As root: # mkdir -p TEST/TEST2 # echo aaa > TEST/TEST2/aaa.txt # chown 10000:10000 TEST # chown 10001:10001 TEST/TEST2 # chown 10002:10002 TEST/TEST2/aaa.txt # tar --numeric-owner -zcf test1.tar.gz TEST # tar --numeric-owner -g test.inc -zcf test2.tar.gz TEST and now view these tarballs with long view. Directories of test2.tar.gz have owner root instead of 10000 or 10001, but if you untar them using tar -xvf directories owners are correct Signed-off-by: Andrew Borodin --- src/vfs/tar/tar.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/vfs/tar/tar.c b/src/vfs/tar/tar.c index 3afd8d68d..5e34e17f8 100644 --- a/src/vfs/tar/tar.c +++ b/src/vfs/tar/tar.c @@ -388,7 +388,7 @@ tar_fill_stat (struct vfs_s_super *archive, struct stat *st, union record *heade * know about the other modes but I think I cause no new * problem when I adjust them, too. -- Norbert. */ - if (header->header.linkflag == LF_DIR) + if (header->header.linkflag == LF_DIR || header->header.linkflag == LF_DUMPDIR) st->st_mode |= S_IFDIR; else if (header->header.linkflag == LF_SYMLINK) st->st_mode |= S_IFLNK; @@ -554,15 +554,10 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, si else *h_size = tar_from_oct (1 + 12, header->header.size); - /* - * Skip over directory snapshot info records that - * are stored in incremental tar archives. - */ if (header->header.linkflag == LF_DUMPDIR) { if (arch->type == TAR_UNKNOWN) arch->type = TAR_GNU; - return STATUS_SUCCESS; } /*