svn commit: r272268 - user/marcel/mkimg

Marcel Moolenaar marcel at FreeBSD.org
Sun Sep 28 19:55:22 UTC 2014


Author: marcel
Date: Sun Sep 28 19:55:21 2014
New Revision: 272268
URL: http://svnweb.freebsd.org/changeset/base/272268

Log:
  When SEEK_HOLE and SEEK_DATA return -1, then the entire file is data.
  Set hole and data accordingly and before acting on them.
  While here: remove some debugging printfs; we're good so far.

Modified:
  user/marcel/mkimg/image.c

Modified: user/marcel/mkimg/image.c
==============================================================================
--- user/marcel/mkimg/image.c	Sun Sep 28 19:17:33 2014	(r272267)
+++ user/marcel/mkimg/image.c	Sun Sep 28 19:55:21 2014	(r272268)
@@ -86,7 +86,6 @@ image_swap_alloc(size_t size)
 		image_swap_size = ofs;
 		ofs = -1LL;
 	}
-	fprintf(stderr, "SWAP: off=%jd, size=%zu\n", (intmax_t)ofs, size);
 	return (ofs);
 }
 
@@ -338,17 +337,19 @@ image_copyin_mapped(lba_t blk, int fd, u
 		hole = lseek(fd, cur, SEEK_HOLE);
 		data = lseek(fd, cur, SEEK_DATA);
 
-		fprintf(stderr, "XXX: %s: cur=%jd, pos=%jd, hole=%jd, "
-		    "data=%jd\n", __func__, (intmax_t)cur, (intmax_t)pos,
-		    (intmax_t)hole, (intmax_t)data);
+		/*
+		 * Treat the entire file as data if sparse files
+		 * are not supported by the underlying file system.
+		 */
+		if (hole == -1 && data == -1) {
+			data = cur;
+			hole = end;
+		}
 
 		if (cur == hole && data > hole) {
 			hole = pos;
 			pos = data & ~(secsz - 1);
 
-			fprintf(stderr, "GAP %jd-%jd\n",
-			    (intmax_t)hole, (intmax_t)pos);
-
 			blk += (pos - hole) / secsz;
 			error = image_chunk_skipto(blk);
 
@@ -358,9 +359,6 @@ image_copyin_mapped(lba_t blk, int fd, u
 			data = pos;
 			pos = (hole + secsz - 1) & ~(secsz - 1);
 
-			fprintf(stderr, "DATA %jd-%jd data\n",
-			    (intmax_t)data, (intmax_t)pos);
-
 			/* Sloppy... */
 			sz = pos - data;
 			assert((off_t)sz == pos - data);


More information about the svn-src-user mailing list