summaryrefslogtreecommitdiffstats
path: root/lib/label
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2003-08-26 21:12:06 +0000
committerAlasdair Kergon <agk@redhat.com>2003-08-26 21:12:06 +0000
commit29ebccc3e26b472a0873951736f4057487b143c2 (patch)
tree4b52ffef65686a2cc24ac72d654a6ee213636b17 /lib/label
parent8b7a435dee35ceeb708f90e28107572a18de124c (diff)
downloadlvm2-29ebccc3e26b472a0873951736f4057487b143c2.tar.gz
lvm2-29ebccc3e26b472a0873951736f4057487b143c2.tar.xz
lvm2-29ebccc3e26b472a0873951736f4057487b143c2.zip
Cope better when format functions are missing.
Diffstat (limited to 'lib/label')
-rw-r--r--lib/label/label.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/label/label.c b/lib/label/label.c
index dc549daf..0c78ed0d 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -280,6 +280,11 @@ int label_write(struct device *dev, struct label *label)
struct label_header *lh = (struct label_header *) buf;
int r = 1;
+ if (!label->labeller->ops->write) {
+ log_err("Label handler does not support label writes");
+ return 0;
+ }
+
if ((LABEL_SIZE + (label->sector << SECTOR_SHIFT)) > LABEL_SCAN_SIZE) {
log_error("Label sector %" PRIu64 " beyond range (%ld)",
label->sector, LABEL_SCAN_SECTORS);
@@ -292,8 +297,10 @@ int label_write(struct device *dev, struct label *label)
lh->sector_xl = xlate64(label->sector);
lh->offset_xl = xlate32(sizeof(*lh));
- if (!label->labeller->ops->write(label, buf))
+ if (!label->labeller->ops->write(label, buf)) {
+ stack;
return 0;
+ }
lh->crc_xl = xlate32(calc_crc(INITIAL_CRC, &lh->offset_xl, LABEL_SIZE -
((void *) &lh->offset_xl - (void *) lh)));
@@ -327,7 +334,7 @@ int label_verify(struct device *dev)
return 0;
}
- return l->ops->verify(l, buf, sector);
+ return ((l->ops->verify) ? l->ops->verify(l, buf, sector) : 1);
}
void label_destroy(struct label *label)