1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 11:55:55 +03:00

o Sync. only

This commit is contained in:
Joe Thornber 2001-11-21 09:20:05 +00:00
parent a7af42f14c
commit 7c77eca4f7
5 changed files with 258 additions and 0 deletions

View File

@ -0,0 +1,164 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the LGPL.
*/
#include "format-text.h"
#include "log.h"
#include "pool.h"
#include "config.h"
#include "hash.h"
/*
* The text format is a human readable metadata
* format that will be used to store the metadata
* backups from the LVM2 system. By being human
* readable it is hoped that people will be able
* to recieve a lot more support when things go
* wrong.
*
* The format instance is given a directory path
* upon creation. Each file in this directory
* whose name is of the form '*.vg' is a config
* file (see lib/config.[hc]), which contains a
* description of a single volume group.
*
* The prefix of the config file gives the volume group
* name.
*/
struct text_c {
char *dir;
};
/*
* Returns a list of config files, one for each
* .vg file in the given directory.
*/
struct config_list {
struct list list;
struct config_file *cf;
};
struct list *_get_configs(struct pool *mem, const char *dir)
{
}
void _put_configs(struct pool *mem, struct list *configs)
{
struct list *cfh;
struct config_list *cl;
list_iterate(cfh, configs) {
cl = list_item(cfh, struct config_file);
destroy_config_file(cl->cf);
}
pool_free(mem, configs);
}
/*
* Just returns the vg->name fields
struct list *get_vgs(struct format_instance *fi)
{
struct text_c *tc = (struct text_c *) fi->private;
}
struct list *get_pvs(struct format_instance *fi)
{
}
struct physical_volume *pv_read(struct format_instance *fi,
const char *pv_name)
{
}
int pv_setup(struct format_instance *fi, struct physical_volume *pv,
struct volume_group *vg)
{
}
int pv_write(struct format_instance *fi, struct physical_volume *pv)
{
}
int vg_setup(struct format_instance *fi, struct volume_group *vg)
{
}
struct volume_group *vg_read(struct format_instance *fi, const char *vg_name)
{
}
int vg_write(struct format_instance *fi, struct volume_group *vg)
{
}
void destroy(struct format_instance *fi)
{
/*
* We don't need to do anything here since
* everything is allocated from the pool.
*/
}
static struct format_handler _text_handler = {
get_vgs: _get_vgs,
get_pvs: _get_pvs,
pv_read: _pv_read,
pv_setup: _pv_setup,
pv_write: _pv_write,
vg_setup: _vg_setup,
vg_read: _vg_read,
vg_write: _vg_write,
destroy: _destroy
};
struct format_instance *text_format_create(struct cmd_context *cmd,
const char *dir)
{
struct format_instance *fi;
struct text_c *tc = NULL;
if (!(tc = pool_zalloc(cmd->mem, sizeof(*tc)))) {
stack;
return NULL;
}
if (!(tc->dir = pool_strdup(cmd->mem, dir))) {
stack;
goto bad;
}
if (!(fi = pool_alloc(cmd->mem, sizeof(*fi)))) {
stack;
goto bad;
}
fi->cmd = cmd;
fi->ops = _text_handler;
fi->private = tc;
return fi;
bad:
pool_free(mem, tc);
return NULL;
}

View File

@ -0,0 +1,13 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the LGPL.
*/
#ifndef _LVM_FORMAT_TEXT_H
#define _LVM_FORMAT_TEXT_H
struct format_instance *text_format_create(struct cmd_context,
const char *dir);
#endif

View File

@ -0,0 +1,19 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the LGPL.
*/
#include "text-rep.h"
struct volume_group *text_vg_import(struct pool *mem, struct config_file *cf)
{
log_err("text_vg_import not implemented yet.");
return NULL;
}
struct config_file *text_vg_export(struct pool *mem, struct volume_group *vg)
{
}

View File

@ -0,0 +1,13 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
*
* This file is released under the LGPL.
*/
#ifndef _LVM_TEXT_IMPORT_EXPORT_H
#define _LVM_TEXT_IMPORT_EXPORT_H
struct volume_group *text_vg_import(struct pool *mem, struct config_file *cf);
struct config_file *text_vg_export(struct pool *mem, struct volume_group *vg);
#endif

49
lib/format_text/sample.vg Normal file
View File

@ -0,0 +1,49 @@
# An example volume group
vg {
id = "ksjdlfksjldskjlsk"
name = "sample_volume_group"
status = [???]
extent_size = 8192 # 4M
extent_count = 1024
free_count = 430
max_lv = 99
max_pv = 255
physical_volumes = ["pv1", "pv2"]
logical_volumes = ["lv1", "lv2"]
}
pv1 {
id = "lksjdflksdlsk"
major = 123
minor = 23
status = [???]
size = ??
pe_start = 8192
pe_count = 300
pe_allocated = 30
}
lv1 {
id = "lksdflskj"
name = "music"
status = [???]
read_ahead = 1024
stripes = 1
size = ??
le_count = 30
map = ["pv1", 0,
"pv2", 1,
...
]
}