summaryrefslogtreecommitdiff
path: root/mkfs.c
diff options
context:
space:
mode:
authorWang Shilong <wangsl.fnst@cn.fujitsu.com>2014-03-11 18:29:08 +0800
committerChris Mason <clm@fb.com>2014-03-21 09:51:31 -0700
commit3bb703dcaec52b187526e5a0a5faf145ab18a716 (patch)
tree9968ba999b7486a1d0824aa79935f0e53c1cb608 /mkfs.c
parentd1fffb0221509e8a5c844e9ca9b27a340c35cb53 (diff)
Btrfs-progs: mkfs: don't create extent for an empty file
Steps to reproduce: # mkdir -p /tmp/test # touch /tmp/test/file # mkfs.btrfs -f /dev/sda13 -r /tmp/test # btrfs check /dev/sda13 For an empty file, don't create extent data for it. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'mkfs.c')
-rw-r--r--mkfs.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/mkfs.c b/mkfs.c
index 2dc90c24..2f7dfef7 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -619,6 +619,9 @@ static int add_file_items(struct btrfs_trans_handle *trans,
struct extent_buffer *eb = NULL;
int fd;
+ if (st->st_size == 0)
+ return 0;
+
fd = open(path_name, O_RDONLY);
if (fd == -1) {
fprintf(stderr, "%s open failed\n", path_name);