bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] create: Always check for sparseness if '--hole-detection=raw'


From: Douglas Anderson
Subject: [PATCH] create: Always check for sparseness if '--hole-detection=raw'
Date: Mon, 26 Feb 2024 15:08:48 -0800

If we're using 'hole-detection=raw' then we're going to be manually
looking for sparseness in our files. We don't really care about
whether the OS thinks they're sparse, so don't do the check about the
number of blocks the OS thinks the file takes.

Without this change if I use "tar --hole-detection=raw -cf" to tar up
a file that's got lots of zeros (but isn't marked by the OS as
sparse), when I untar the file then it's still not sparse. With this
change then the zeros are correctly transformed into sparseness.

---
This is the same patch that was submitted via Savannah [1], but I'm
not terribly familiar with the process for submitting tar patches so I
thought I'd maybe post to this list too. Sorry if I've got this wrong.

[1] https://savannah.gnu.org/patch/index.php?10432
---
 src/create.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/create.c b/src/create.c
index bcb4a394aa40..b8c561ebfa97 100644
--- a/src/create.c
+++ b/src/create.c
@@ -1772,7 +1772,9 @@ dump_file0 (struct tar_stat_info *st, char const *name, 
char const *p)
        {
          enum dump_status status;
 
-         if (fd && sparse_option && ST_IS_SPARSE (st->stat))
+         if (fd && sparse_option
+             && (hole_detection == HOLE_DETECTION_RAW
+                 || ST_IS_SPARSE (st->stat)))
            {
              status = sparse_dump_file (fd, st);
              if (status == dump_status_not_implemented)

---
base-commit: fac2b4c11a8bb9720e34a8baa786613859a52d23
change-id: 20240226-fix_raw_hole_detection-027875748c92

Best regards,
-- 
Douglas Anderson <dianders@chromium.org>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]