mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
o sync
This commit is contained in:
parent
a25004545e
commit
721128e86d
@ -194,6 +194,8 @@ int dev_cache_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
INIT_LIST_HEAD(&_cache.dirs);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -227,6 +229,10 @@ struct device *_insert_new(const char *name)
|
||||
struct device *dev_cache_get(const char *name, struct dev_filter *f)
|
||||
{
|
||||
struct device *d = (struct device *) hash_lookup(_cache.devices, name);
|
||||
|
||||
if (!d && (d = _create_dev(name)))
|
||||
hash_insert(_cache.devices, name, d);
|
||||
|
||||
return (d && (!f || f->passes_filter(f, d))) ? d : NULL;
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ static struct logical_volume *_find_lv(struct volume_group *vg,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct physical_volume *_find_pv(struct volume_group *vg,
|
||||
static struct physical_volume *_find_pv(struct volume_group *vg,
|
||||
struct device *dev)
|
||||
{
|
||||
struct list_head *tmp;
|
||||
@ -307,7 +307,7 @@ static struct volume_group *_vg_read(struct io_space *is, const char *vg_name)
|
||||
static struct disk_list *_flatten_pv(struct pool *mem, struct volume_group *vg,
|
||||
struct physical_volume *pv)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
static int _flatten_vg(struct pool *mem, struct volume_group *vg,
|
||||
@ -347,9 +347,38 @@ static int _vg_write(struct io_space *is, struct volume_group *vg)
|
||||
}
|
||||
#endif
|
||||
|
||||
struct io_space *create_lvm1_format(void)
|
||||
void _destroy(struct io_space *ios)
|
||||
{
|
||||
return NULL;
|
||||
dbg_free(ios->prefix);
|
||||
dbg_free(ios);
|
||||
}
|
||||
|
||||
struct io_space *create_lvm1_format(const char *prefix, struct pool *mem,
|
||||
struct dev_filter *filter)
|
||||
{
|
||||
struct io_space *ios = dbg_malloc(sizeof(*ios));
|
||||
|
||||
ios->get_vgs = NULL;
|
||||
ios->get_pvs = NULL;
|
||||
ios->pv_read = NULL;
|
||||
ios->pv_write = NULL;
|
||||
ios->vg_read = _vg_read;
|
||||
ios->vg_write = NULL;
|
||||
ios->destroy = _destroy;
|
||||
|
||||
ios->prefix = dbg_malloc(strlen(prefix) + 1);
|
||||
if (!ios->prefix) {
|
||||
stack;
|
||||
dbg_free(ios);
|
||||
return 0;
|
||||
}
|
||||
strcpy(ios->prefix, prefix);
|
||||
|
||||
ios->mem = mem;
|
||||
ios->filter = filter;
|
||||
ios->private = NULL;
|
||||
|
||||
return ios;
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "metadata.h"
|
||||
|
||||
struct io_space *create_lvm1_format(struct dev_filter *filter);
|
||||
struct io_space *create_lvm1_format(const char *prefix, struct pool *mem,
|
||||
struct dev_filter *filter);
|
||||
|
||||
#endif
|
||||
|
@ -162,7 +162,6 @@ struct io_space {
|
||||
/* Current volume group prefix. */
|
||||
/* Default to "/dev/" */
|
||||
char *prefix;
|
||||
|
||||
struct pool *mem;
|
||||
struct dev_filter *filter;
|
||||
void *private;
|
||||
|
@ -15,6 +15,6 @@ TARGETS=read_vg_t
|
||||
|
||||
include ../../make.tmpl
|
||||
|
||||
read_vg_t: read_vg_t.o
|
||||
read_vg_t: read_vg_t.o $(top_srcdir)/lib/liblvm.a
|
||||
$(CC) -o read_vg_t read_vg_t.o -L$(top_srcdir)/lib -llvm
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "log.h"
|
||||
#include "format1.h"
|
||||
#include "dbg_malloc.h"
|
||||
#include "pool.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -14,6 +15,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
struct io_space *ios;
|
||||
struct volume_group *vg;
|
||||
struct pool *mem;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "usage: read_vg_t <vg_name>\n");
|
||||
@ -33,7 +35,18 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ios = create_lvm1_format(NULL);
|
||||
if (!(mem = pool_create(10 * 1024))) {
|
||||
fprintf(stderr, "couldn't create pool\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ios = create_lvm1_format("/dev", mem, NULL);
|
||||
|
||||
if (!ios) {
|
||||
fprintf(stderr, "failed to create io_space for format1\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
vg = ios->vg_read(ios, argv[1]);
|
||||
|
||||
if (!vg) {
|
||||
|
Loading…
Reference in New Issue
Block a user