]> sourceware.org Git - lvm2.git/commitdiff
Wipe the first label if writing the second one failed.
authorPatrick Caulfield <pcaulfie@redhat.com>
Tue, 18 Dec 2001 14:39:32 +0000 (14:39 +0000)
committerPatrick Caulfield <pcaulfie@redhat.com>
Tue, 18 Dec 2001 14:39:32 +0000 (14:39 +0000)
lib/label/label.c

index a277294342a30ff2ba9c1326db1cc4646e17e6d6..1ea94be0a47067477af255c7e209ff450aeb9f09 100644 (file)
@@ -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);
 
This page took 0.037769 seconds and 5 git commands to generate.