| 1 | This patch is needed in order to build Guix on a Btrfs file system. |
| 2 | |
| 3 | |
| 4 | From da922703282b0d3b8837a99a9c7fdd32f1d20d49 Mon Sep 17 00:00:00 2001 |
| 5 | From: Mark H Weaver <[email protected]> |
| 6 | Date: Tue, 9 Jan 2018 20:16:14 -0500 |
| 7 | Subject: [PATCH] Remove nonportable check for files containing only zeroes. |
| 8 | |
| 9 | This check benefitted only one unlikely case (large files containing |
| 10 | only zeroes, on systems that do not support SEEK_HOLE) and was based |
| 11 | on an assumption about file system behavior that is not mandated by |
| 12 | POSIX and no longer holds in practice, namely that for sufficiently |
| 13 | large files, (st_blocks == 0) implies that the file contains only |
| 14 | zeroes. Examples of file systems that violate this assumption include |
| 15 | Linux's /proc file system and Btrfs. |
| 16 | |
| 17 | * src/sparse.c (sparse_scan_file_wholesparse): Remove this function. |
| 18 | (sparse_scan_file_seek): Remove the initial check for files containing |
| 19 | only zeroes. |
| 20 | |
| 21 | src/sparse.c | 24 ------------------------ |
| 22 | 1 file changed, 24 deletions(-) |
| 23 | |
| 24 | diff --git a/src/sparse.c b/src/sparse.c |
| 25 | index d41c0ea..3de6560 100644 |
| 26 | |
| 27 | |
| 28 | sparse_scan_file_raw (struct tar_sparse_file *file) |
| 29 | return tar_sparse_scan (file, scan_end, NULL); |
| 30 | } |
| 31 | |
| 32 | -static bool |
| 33 | -sparse_scan_file_wholesparse (struct tar_sparse_file *file) |
| 34 | -{ |
| 35 | - struct tar_stat_info *st = file->stat_info; |
| 36 | - struct sp_array sp = {0, 0}; |
| 37 | - |
| 38 | - /* Note that this function is called only for truly sparse files of size >= 1 |
| 39 | - block size (checked via ST_IS_SPARSE before). See the thread |
| 40 | - http://www.mail-archive.com/[email protected]/msg04209.html for more info */ |
| 41 | - if (ST_NBLOCKS (st->stat) == 0) |
| 42 | - { |
| 43 | - st->archive_file_size = 0; |
| 44 | - sp.offset = st->stat.st_size; |
| 45 | - sparse_add_map (st, &sp); |
| 46 | - return true; |
| 47 | - } |
| 48 | - |
| 49 | - return false; |
| 50 | -} |
| 51 | - |
| 52 | #ifdef SEEK_HOLE |
| 53 | /* Try to engage SEEK_HOLE/SEEK_DATA feature. */ |
| 54 | static bool |
| 55 | sparse_scan_file_seek (struct tar_sparse_file *file) |
| 56 | static bool |
| 57 | sparse_scan_file (struct tar_sparse_file *file) |
| 58 | { |
| 59 | - /* always check for completely sparse files */ |
| 60 | - if (sparse_scan_file_wholesparse (file)) |
| 61 | - return true; |
| 62 | - |
| 63 | switch (hole_detection) |
| 64 | { |
| 65 | case HOLE_DETECTION_DEFAULT: |
| 66 | -- |
| 67 | 2.15.1 |
| 68 |