From c6cc24ea3f84672e8e33855eeb2de0fda7019107 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 10 Jan 2002 18:12:26 +0000 Subject: [PATCH] o _read_id function for import.c --- lib/Makefile.in | 1 - lib/format1/disk-rep.c | 2 +- lib/format_text/import.c | 30 ++++++++++++++++++++++++++---- lib/label/label.c | 2 +- lib/label/label.h | 2 +- lib/metadata/merge.c | 1 + 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/lib/Makefile.in b/lib/Makefile.in index 14039c89d..1daa300b2 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -34,7 +34,6 @@ SOURCES=\ format_text/flags.c \ format_text/format-text.c \ format_text/import.c \ - label/label.c \ log/log.c \ metadata/lv_manip.c \ metadata/merge.c \ diff --git a/lib/format1/disk-rep.c b/lib/format1/disk-rep.c index 5f7a4b167..177b7dd5e 100644 --- a/lib/format1/disk-rep.c +++ b/lib/format1/disk-rep.c @@ -337,7 +337,7 @@ struct disk_list *read_disk(struct device *dev, struct pool *mem, } /* - * Build a list of pv_d's structures, allocated from mem. + * Build a list of pv_d's structures, allocated from mem. * We keep track of the first object allocated form the pool * so we can free off all the memory if something goes wrong. */ diff --git a/lib/format_text/import.c b/lib/format_text/import.c index 8a614b78b..0455a604d 100644 --- a/lib/format_text/import.c +++ b/lib/format_text/import.c @@ -7,6 +7,7 @@ #include "import-export.h" #include "pool.h" #include "log.h" +#include "uuid.h" typedef int (*section_fn)(struct pool *mem, @@ -19,6 +20,29 @@ typedef int (*section_fn)(struct pool *mem, #define _read_int64(root, path, result) \ get_config_uint64(root, path, '/', result) +static int _read_id(struct id *id, struct config_node *cn, const char *path) +{ + struct config_value *cv; + + if (!(cn = find_config_node(cn, path, '/'))) { + log_err("Couldn't find uuid."); + return 0; + } + + cv = cn->v; + if (!cv || !cv->v.str) { + log_err("uuid must be a string."); + return 0; + } + + if (!id_read_format(id, cv->v.str)) { + log_err("Invalid uuid."); + return 0; + } + + return 1; +} + static int _read_pv(struct pool *mem, struct volume_group *vg, struct config_node *pvn, struct config_node *vgn) @@ -34,12 +58,10 @@ static int _read_pv(struct pool *mem, pv = &pvl->pv; -/******** FIXME _read_id undefined if (!_read_id(&pv->id, vgn, "id")) { log_err("Couldn't read uuid for volume group."); return 0; } -*************/ /* * FIXME: need label/vgcache code to convert the uuid @@ -167,14 +189,14 @@ static int _read_segment(struct pool *mem, struct volume_group *vg, return 0; } -/**********FIXME _find_pv undefined +#if 0 if (!(pv = _find_pv(cv->v.str, pv_hash))) { log_err("Couldn't find physical volume (%s) for " "segment '%s'.", cn->v->v.str ? cn->v->v.str : "NULL", sn->key); return 0; } -*******************/ +#endif seg->area[s].pv = pv; diff --git a/lib/label/label.c b/lib/label/label.c index f7c67173a..0dbccc6e9 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001 Sistina Software + * Copyright (C) 2002 Sistina Software * * This file is released under the LGPL. */ diff --git a/lib/label/label.h b/lib/label/label.h index 314b0ea97..ea607b682 100644 --- a/lib/label/label.h +++ b/lib/label/label.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001 Sistina Software (UK) Limited. + * Copyright (C) 2002 Sistina Software (UK) Limited. * * This file is released under the LGPL. */ diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c index 2b2f0cb41..4d7f674bf 100644 --- a/lib/metadata/merge.c +++ b/lib/metadata/merge.c @@ -5,6 +5,7 @@ */ #include "log.h" +#include "metadata.h" /* * Returns success if the segments were -- 2.43.5