
Signed-off-by: Christoph Hellwig <hch@lst.de>

diff --git a/sheep/farm/snap.c b/sheep/farm/snap.c
index 3134c28..1e5917d 100644
--- a/sheep/farm/snap.c
+++ b/sheep/farm/snap.c
@@ -161,10 +161,17 @@ int snap_file_write(uint32_t epoch, unsigned char *trunksha1, unsigned char *out
 	struct strbuf buf = STRBUF_INIT;
 	struct sd_node nodes[SD_MAX_NODES];
 	int tgt_epoch = user ? sys_epoch() : epoch;
-	uint64_t epoch_size = epoch_log_read(tgt_epoch, (char *)nodes, sizeof(nodes));
-	struct sha1_file_hdr hdr = { .size = epoch_size + SHA1_LEN,
-				     .priv = tgt_epoch };
+	uint64_t epoch_size;
+	struct sha1_file_hdr hdr;
+
+	epoch_size = epoch_log_read(tgt_epoch, (char *)nodes, sizeof(nodes));
+	if (epoch_size == -1)
+		return -1;
+
 	memcpy(hdr.tag, TAG_SNAP, TAG_LEN);
+	hdr.size = epoch_size + SHA1_LEN;
+	hdr.priv = tgt_epoch;
+	hdr.reserved = 0;
 
 	strbuf_add(&buf, &hdr, sizeof(hdr));
 	strbuf_add(&buf, trunksha1, SHA1_LEN);


