diff mbox

[14/18] btrfs restore: report mismatch in file size

Message ID 1418244708-7087-15-git-send-email-mwilck@arcor.de (mailing list archive)
State New, archived
Headers show

Commit Message

mwilck@arcor.de Dec. 10, 2014, 8:51 p.m. UTC
From: Martin Wilck <mwilck@arcor.de>

A mismatch between the file size stored in the inode and the
number of bytes restored may indicate a problem.
restore reads data in 4k chunks, so it's normal that files are
truncated. Only emit the warning in unusual cases.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
---
 cmds-restore.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/cmds-restore.c b/cmds-restore.c
index 8ae3337..3c4dc7a 100644
--- a/cmds-restore.c
+++ b/cmds-restore.c
@@ -799,6 +799,12 @@  set_size:
 				file);
 	}
 
+	if (st.st_size != _INVALID_SIZE && (st.st_size > next_pos || 
+					    (st.st_size < next_pos &&
+					     (st.st_size >> 12) !=
+					     (next_pos >> 12) - 1)))
+		fprintf(stderr, "size mismatch: extpected %llu, got %llu (written %llu)\n",
+			st.st_size, next_pos, total_written);	
 	set_fd_attrs(fd, &st, file);
 	return ret;
 }