pass an extra open|create enum to metadata ctr
This commit is contained in:
parent
8f9d71ccc8
commit
076131aac1
@ -82,7 +82,7 @@ namespace {
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
metadata::metadata(std::string const &dev_path)
|
||||
metadata::metadata(std::string const &dev_path, open_type ot)
|
||||
: tm_(open_tm(dev_path)),
|
||||
sb_(read_superblock(tm_->get_bm())),
|
||||
metadata_sm_(open_metadata_sm(tm_, static_cast<void *>(&sb_.metadata_space_map_root_))),
|
||||
@ -107,6 +107,8 @@ metadata::commit()
|
||||
sb_.data_mapping_root_ = mappings_.get_root();
|
||||
sb_.device_details_root_ = details_.get_root();
|
||||
|
||||
// FIXME: copy the space map roots
|
||||
|
||||
write_ref superblock = tm_->get_bm()->superblock(SUPERBLOCK_LOCATION);
|
||||
superblock_disk *disk = reinterpret_cast<superblock_disk *>(superblock.data());
|
||||
superblock_traits::pack(sb_, *disk);
|
||||
|
@ -124,7 +124,12 @@ namespace thin_provisioning {
|
||||
// implementation of metadata. Implement more specific interfaces
|
||||
// on top of this.
|
||||
struct metadata {
|
||||
metadata(std::string const &dev_path);
|
||||
enum open_type {
|
||||
CREATE,
|
||||
OPEN
|
||||
};
|
||||
|
||||
metadata(std::string const &dev_path, open_type ot);
|
||||
|
||||
void commit();
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace po = boost::program_options;
|
||||
|
||||
namespace {
|
||||
void dump(string const &path, string const &format) {
|
||||
metadata::ptr md(new metadata(path));
|
||||
metadata::ptr md(new metadata(path, metadata::OPEN));
|
||||
emitter::ptr e;
|
||||
|
||||
if (format == "xml")
|
||||
|
@ -10,7 +10,7 @@ using namespace thin_provisioning;
|
||||
|
||||
namespace {
|
||||
int check(string const &path) {
|
||||
metadata::ptr md(new metadata(path));
|
||||
metadata::ptr md(new metadata(path, metadata::OPEN));
|
||||
|
||||
optional<error_set::ptr> maybe_errors = metadata_check(md);
|
||||
if (maybe_errors) {
|
||||
|
@ -18,11 +18,16 @@ namespace po = boost::program_options;
|
||||
|
||||
namespace {
|
||||
void restore(string const &backup_file, string const &dev) {
|
||||
metadata::ptr md(new metadata(dev));
|
||||
metadata::ptr md(new metadata(dev, metadata::CREATE));
|
||||
emitter::ptr restorer = create_restore_emitter(md);
|
||||
ifstream in(backup_file.c_str(), ifstream::in);
|
||||
parse_xml(in, restorer);
|
||||
in.close();
|
||||
try {
|
||||
parse_xml(in, restorer);
|
||||
|
||||
} catch (...) {
|
||||
in.close();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void usage(po::options_description const &desc) {
|
||||
|
Loading…
Reference in New Issue
Block a user