Testcase for a minor issue:

$ > sparse_file

$ chattr +S sparse_file

$ dd if=/dev/zero bs=1M count=1 conv=sparse,notrunc of=sparse_file
...
$ lssparse sparse_file # OK

$ lssparse -H sparse_file # OK
Hole range[0]: offset=0x0,      length=0x100000

$ printf X >> sparse_file

$ lssparse sparse_file # OK
Data range[1]: offset=0x100000, length=0x1

$ lssparse -H sparse_file # Missing 'Hole range[0]'
Data range[1]: offset=0x100000, length=0x1

The condition at lssparse.c:161 is never true:

   141      for (i=1 ;;) {
   ...
   161          if (print_holes && (i == 0) && (data_start > 0)) {

Possible patch attached. Important: Not tested with other corner cases.

--
Regards,
Christian


--- lssparse.c.orig     2025-04-01 10:48:54.000000000 +0200
+++ lssparse.c  2025-04-02 15:45:54.179794300 +0200
@@ -138,7 +138,7 @@
      * $ /cygdrive/c/Windows/system32/fsutil sparse queryrange ... #
      * output
      */
-    for (i=1 ;;) {
+    for (i=0 ;;) {
         data_start = lseek(fd, offset, SEEK_DATA);
         if (data_start == -1)
             break;
-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to