From 5c8af8d21a7ae6281b95825a91d6dc372719e1d3 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 10 Oct 2001 10:05:29 +0000 Subject: [PATCH] o pv_write for orphan pv's --- lib/format1/disk-rep.c | 6 ++++++ lib/format1/format1.c | 41 ++++++++++++++++++++++++++++++++++++- lib/format1/import-export.c | 5 ++++- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/lib/format1/disk-rep.c b/lib/format1/disk-rep.c index 7463d53c5..e93d7afc7 100644 --- a/lib/format1/disk-rep.c +++ b/lib/format1/disk-rep.c @@ -400,6 +400,12 @@ static int _write_all_pv(struct disk_list *data) return 0; } + /* + * Stop here for orphan pv's. + */ + if (data->pv.vg_name[0] == '\0') + return 1; + if (!_write_vg(data)) { log_err("failed to write vg data to %s", pv_name); return 0; diff --git a/lib/format1/format1.c b/lib/format1/format1.c index 4b5a9f02d..186caf691 100644 --- a/lib/format1/format1.c +++ b/lib/format1/format1.c @@ -314,8 +314,47 @@ static int _pv_setup(struct io_space *is, struct physical_volume *pv, static int _pv_write(struct io_space *is, struct physical_volume *pv) { - log_err("format1:pv_write not implemented."); + struct pool *mem; + struct disk_list *dl; + struct list_head pvs; + + INIT_LIST_HEAD(&pvs); + + if (pv->vg_name) { + log_info("pv_write should only be called for an orphan pv"); + return 0; + } + + if (!(mem = pool_create(1024))) { + stack; + return 0; + } + + + if (!(dl = pool_alloc(mem, sizeof(*dl)))) { + stack; + return 0; + } + dl->mem = mem; + dl->dev = pv->dev; + + if (!export_pv(&dl->pv, pv)) { + stack; + goto bad; + } + + list_add(&dl->list, &pvs); + if (!write_pvs(&pvs)) { + stack; + goto bad; + } + + pool_destroy(mem); return 1; + + bad: + pool_destroy(mem); + return 0; } diff --git a/lib/format1/import-export.c b/lib/format1/import-export.c index fc786334f..3ce4b58f2 100644 --- a/lib/format1/import-export.c +++ b/lib/format1/import-export.c @@ -124,7 +124,10 @@ int export_pv(struct pv_disk *pvd, struct physical_volume *pv) return 0; } - strcpy(pvd->vg_name, pv->vg_name); + memset(pvd->vg_name, 0, sizeof(pvd->vg_name)); + + if (pv->vg_name) + strcpy(pvd->vg_name, pv->vg_name); //pvd->pv_major = MAJOR(pv->dev); //pvd->pv_number = ??;