From 8cdf0a831c0816c4d38b28c878a7fc3de361adfb Mon Sep 17 00:00:00 2001 From: Patrick Caulfield Date: Tue, 18 Dec 2001 14:39:32 +0000 Subject: [PATCH] Wipe the first label if writing the second one failed. --- lib/label/label.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/label/label.c b/lib/label/label.c index a27729434..1ea94be0a 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -267,8 +267,16 @@ int label_write(struct device *dev, struct label *label) /* Write another at the end of the device */ status2 = dev_write(dev, offset[1], sizeof(struct label_ondisk) + label->datalen, block); if (!status2) + { + char zerobuf[sizeof(struct label_ondisk)]; log_error("Error writing label 2\n"); + /* Wipe the first label so it doesn't get confusing */ + memset(zerobuf, 0, sizeof(struct label_ondisk)); + if (!dev_write(dev, offset[0], sizeof(struct label_ondisk), zerobuf)) + log_error("Error erasing label 1\n"); + } + pool_free(label_pool, block); dev_close(dev);