mirror of
git://sourceware.org/git/lvm2.git
synced 2025-02-27 01:57:55 +03:00
o test program for reading a vg
This commit is contained in:
parent
a14dbe1ea6
commit
46fda6281c
@ -14,6 +14,7 @@ SOURCES=\
|
|||||||
dev-mgr/dev-cache.c \
|
dev-mgr/dev-cache.c \
|
||||||
device/dev-cache.c \
|
device/dev-cache.c \
|
||||||
device/dev-io.c \
|
device/dev-io.c \
|
||||||
|
format1/format1.c \
|
||||||
log/log.c \
|
log/log.c \
|
||||||
mm/dbg_malloc.c \
|
mm/dbg_malloc.c \
|
||||||
mm/pool.c
|
mm/pool.c
|
||||||
|
@ -101,6 +101,7 @@ struct lv_list {
|
|||||||
struct disk_list {
|
struct disk_list {
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
|
|
||||||
struct pv_disk pv;
|
struct pv_disk pv;
|
||||||
struct vg_disk vg;
|
struct vg_disk vg;
|
||||||
struct list_head uuids;
|
struct list_head uuids;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
* Copyright (C) 2001 Sistina Software (UK) Limited.
|
* Copyright (C) 2001 Sistina Software (UK) Limited.
|
||||||
*
|
*
|
||||||
* This file is released under the GPL.
|
* This file is released under the GPL.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "disk-rep.h"
|
#include "disk-rep.h"
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
* Copyright (C) 2001 Sistina Software (UK) Limited.
|
* Copyright (C) 2001 Sistina Software (UK) Limited.
|
||||||
*
|
*
|
||||||
* This file is released under the GPL.
|
* This file is released under the GPL.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LVM_FORMAT1_H
|
#ifndef LVM_FORMAT1_H
|
||||||
|
@ -117,18 +117,22 @@ struct pv_list {
|
|||||||
|
|
||||||
/* ownership of returned objects passes */
|
/* ownership of returned objects passes */
|
||||||
struct io_space {
|
struct io_space {
|
||||||
/* Returns list of names of all vgs - vg component only, not full path*/
|
/* Returns list of names of all vgs - vg
|
||||||
|
component only, not full path*/
|
||||||
struct name_list *(*get_vgs)(struct io_space *is);
|
struct name_list *(*get_vgs)(struct io_space *is);
|
||||||
|
|
||||||
/* Returns list of fully-populated pv structures */
|
/* Returns list of fully-populated pv
|
||||||
|
structures */
|
||||||
struct pv_list *(*get_pvs)(struct io_space *is);
|
struct pv_list *(*get_pvs)(struct io_space *is);
|
||||||
|
|
||||||
/* Return PV with given name (may be full or relative path) */
|
/* Return PV with given name (may be full
|
||||||
|
or relative path) */
|
||||||
struct physical_volume *(*pv_read)(struct io_space *is,
|
struct physical_volume *(*pv_read)(struct io_space *is,
|
||||||
const char *pv_name);
|
const char *pv_name);
|
||||||
|
|
||||||
/* Write a PV structure to disk. */
|
/* Write a PV structure to disk. */
|
||||||
/* Fails if the PV is in a VG ie pv->vg_name must be null */
|
/* Fails if the PV is in a VG ie
|
||||||
|
pv->vg_name must be null */
|
||||||
int (*pv_write)(struct io_space *is, struct physical_volume *pv);
|
int (*pv_write)(struct io_space *is, struct physical_volume *pv);
|
||||||
|
|
||||||
/* if vg_name doesn't contain any slash, this function adds prefix */
|
/* if vg_name doesn't contain any slash, this function adds prefix */
|
||||||
@ -136,9 +140,9 @@ struct io_space {
|
|||||||
const char *vg_name);
|
const char *vg_name);
|
||||||
|
|
||||||
/* Write out complete VG metadata. */
|
/* Write out complete VG metadata. */
|
||||||
/* Ensure *internal* consistency before writing anything.
|
/* Ensure *internal* consistency before writing anything.
|
||||||
* eg. PEs can't refer to PVs not part of the VG
|
* eg. PEs can't refer to PVs not part of the VG
|
||||||
* Order write sequence to aid recovery if process is aborted
|
* Order write sequence to aid recovery if process is aborted
|
||||||
* (eg flush entire set of changes to each disk in turn)
|
* (eg flush entire set of changes to each disk in turn)
|
||||||
* It is the responsibility of the caller to ensure external
|
* It is the responsibility of the caller to ensure external
|
||||||
* consistency, eg by calling pv_write() if removing PVs from a VG
|
* consistency, eg by calling pv_write() if removing PVs from a VG
|
||||||
|
47
old-tests/format1/read_vg_t.c
Normal file
47
old-tests/format1/read_vg_t.c
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2001 Sistina Software (UK) Limited.
|
||||||
|
*
|
||||||
|
* This file is released under the GPL.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
#include "format1.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
struct io_space *ios;
|
||||||
|
struct volume_group *vg;
|
||||||
|
|
||||||
|
if (argc != 2) {
|
||||||
|
fprintf(stderr, "usage: read_vg_t <vg_name>\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
init_log(stderr);
|
||||||
|
init_debug(_LOG_DEBUG);
|
||||||
|
|
||||||
|
if (!dev_cache_init()) {
|
||||||
|
fprintf(stderr, "init of dev-cache failed\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dev_cache_add_dir("/dev")) {
|
||||||
|
fprintf(stderr, "couldn't add /dev to dir-cache\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ios = create_lvm_v1_format(NULL);
|
||||||
|
vg = ios->vg_read(ios, argv[1]);
|
||||||
|
|
||||||
|
if (!vg) {
|
||||||
|
fprintf(stderr, "couldn't read vg %s\n", argv[1]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ios->destroy(ios);
|
||||||
|
|
||||||
|
dump_memory();
|
||||||
|
fin_log();
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user