#include <dirent.h>
#include <ctype.h>
-static struct mda_header *_raw_read_mda_header(const struct format_type *fmt,
- struct device_area *dev_area);
-
static struct format_instance *_text_create_text_instance(const struct format_type
*fmt, const char *vgname,
const char *vgid,
if (!dev_open(area->dev))
return_0;
- if (!(mdah = _raw_read_mda_header(fmt, area)))
+ if (!(mdah = raw_read_mda_header(fmt, area)))
goto_out;
rlocn = mdah->raw_locns;
}
}
-static struct mda_header *_raw_read_mda_header(const struct format_type *fmt,
- struct device_area *dev_area)
+struct mda_header *raw_read_mda_header(const struct format_type *fmt,
+ struct device_area *dev_area)
{
struct mda_header *mdah;
if (!dev_open(dev_area->dev))
return_0;
- if (!(mdah = _raw_read_mda_header(fid->fmt, dev_area)))
+ if (!(mdah = raw_read_mda_header(fid->fmt, dev_area)))
return_0;
if (_find_vg_rlocn(dev_area, mdah, vgname, &noprecommit))
char *desc;
uint32_t wrap = 0;
- if (!(mdah = _raw_read_mda_header(fid->fmt, area)))
+ if (!(mdah = raw_read_mda_header(fid->fmt, area)))
goto_out;
if (!(rlocn = _find_vg_rlocn(area, mdah, vgname, &precommitted))) {
if (!dev_open(mdac->area.dev))
return_0;
- if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area)))
+ if (!(mdah = raw_read_mda_header(fid->fmt, &mdac->area)))
goto_out;
rlocn = _find_vg_rlocn(&mdac->area, mdah,
if (!found)
return 1;
- if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area)))
+ if (!(mdah = raw_read_mda_header(fid->fmt, &mdac->area)))
goto_out;
if (!(rlocn = _find_vg_rlocn(&mdac->area, mdah,
if (!dev_open(mdac->area.dev))
return_0;
- if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area)))
+ if (!(mdah = raw_read_mda_header(fid->fmt, &mdac->area)))
goto_out;
if (!(rlocn = _find_vg_rlocn(&mdac->area, mdah, vg->name, &noprecommit))) {
}
const char *vgname_from_mda(const struct format_type *fmt,
+ struct mda_header *mdah,
struct device_area *dev_area, struct id *vgid,
uint64_t *vgstatus, char **creation_host,
uint64_t *mda_free_sectors)
{
struct raw_locn *rlocn;
- struct mda_header *mdah;
uint32_t wrap = 0;
const char *vgname = NULL;
unsigned int len = 0;
if (mda_free_sectors)
*mda_free_sectors = ((dev_area->size - MDA_HEADER_SIZE) / 2) >> SECTOR_SHIFT;
- if (!(mdah = _raw_read_mda_header(fmt, dev_area)))
+ if (!mdah) {
+ log_error(INTERNAL_ERROR "vgname_from_mda called with NULL pointer for mda_header");
goto_out;
+ }
/* FIXME Cope with returning a list */
rlocn = mdah->raw_locns;
struct format_instance fid;
struct id vgid;
uint64_t vgstatus;
+ struct mda_header *mdah;
raw_list = &((struct mda_lists *) fmt->private)->raws;
continue;
}
- if ((vgname = vgname_from_mda(fmt, &rl->dev_area, &vgid, &vgstatus,
+ if (!(mdah = raw_read_mda_header(fmt, &rl->dev_area))) {
+ stack;
+ goto close_dev;
+ }
+
+ if ((vgname = vgname_from_mda(fmt, mdah,
+ &rl->dev_area, &vgid, &vgstatus,
NULL, NULL))) {
vg = _vg_read_raw_area(&fid, vgname, &rl->dev_area, 0);
if (vg)
lvmcache_update_vg(vg, 0);
}
+ close_dev:
if (!dev_close(rl->dev_area.dev))
stack;
}
struct raw_locn raw_locns[0]; /* NULL-terminated list */
} __attribute__ ((packed));
+struct mda_header *raw_read_mda_header(const struct format_type *fmt,
+ struct device_area *dev_area);
+
struct mda_lists {
struct dm_list dirs;
struct dm_list raws;
#define LVM2_LABEL "LVM2 001"
#define MDA_SIZE_MIN (8 * (unsigned) lvm_getpagesize())
+
+const char *vgname_from_mda(const struct format_type *fmt,
+ struct mda_header *mdah,
+ struct device_area *dev_area, struct id *vgid,
+ uint64_t *vgstatus, char **creation_host,
+ uint64_t *mda_free_sectors);
+
#endif
const char *vgname;
uint64_t vgstatus;
char *creation_host;
+ struct mda_header *mdah;
pvhdr = (struct pv_header *) ((void *) buf + xlate32(lh->offset_xl));
stack;
continue;
}
- if ((vgname = vgname_from_mda(info->fmt, &mdac->area,
+ if (!(mdah = raw_read_mda_header(info->fmt, &mdac->area))) {
+ stack;
+ goto close_dev;
+ }
+
+ if ((vgname = vgname_from_mda(info->fmt, mdah,
+ &mdac->area,
&vgid, &vgstatus, &creation_host,
&mdac->free_sectors)) &&
!lvmcache_update_vgname_and_id(info, vgname,
(char *) &vgid, vgstatus,
- creation_host))
+ creation_host)) {
+ if (!dev_close(mdac->area.dev))
+ stack;
return_0;
+ }
+ close_dev:
if (!dev_close(mdac->area.dev))
stack;
}