[contrib] ewheeler_emitter.so

For thin_dump
This commit is contained in:
Joe Thornber 2016-03-24 15:21:20 +00:00
parent 6c4f3ad2ff
commit 83dc84f790
2 changed files with 90 additions and 1 deletions

View File

@ -1,6 +1,7 @@
PLUGINS=\ PLUGINS=\
contrib/thin_sexp_emitter.so \ contrib/thin_sexp_emitter.so \
contrib/tmakatos_emitter.so contrib/tmakatos_emitter.so \
contrib/ewheeler_emitter.so
contrib: $(PLUGINS) contrib: $(PLUGINS)
@ -12,4 +13,8 @@ contrib/tmakatos_emitter.so: contrib/tmakatos_emitter.o
$(V)echo " [LD] $@" $(V)echo " [LD] $@"
$(V)$(CC) -shared -Wl,-soname,tmakatos_emitter.so -o $@ $< $(V)$(CC) -shared -Wl,-soname,tmakatos_emitter.so -o $@ $<
contrib/ewheeler_emitter.so: contrib/ewheeler_emitter.o
$(V)echo " [LD] $@"
$(V)$(CC) -shared -Wl,-soname,ewheeler_emitter.so -o $@ $<

View File

@ -0,0 +1,84 @@
#include "thin-provisioning/emitter.h"
using namespace std;
using namespace thin_provisioning;
//----------------------------------------------------------------
namespace {
template <typename T>
std::ostream &operator << (ostream &out, boost::optional<T> const &maybe) {
if (maybe)
out << *maybe;
return out;
}
class old_emitter : public emitter {
public:
old_emitter(ostream &out)
: out_(out) {
}
void begin_superblock(string const &uuid,
uint64_t time,
uint64_t trans_id,
boost::optional<uint32_t> flags,
boost::optional<uint32_t> version,
uint32_t data_block_size,
uint64_t nr_data_blocks,
boost::optional<uint64_t> metadata_snap) {
data_block_size_ = data_block_size;
}
void end_superblock() {
}
void begin_device(uint32_t dev_id,
uint64_t mapped_blocks,
uint64_t trans_id,
uint64_t creation_time,
uint64_t snap_time) {
}
void end_device() {
}
void begin_named_mapping(string const &name) {
}
void end_named_mapping() {
}
void identifier(string const &name) {
}
void range_map(uint64_t origin_begin, uint64_t data_begin, uint32_t time, uint64_t len) {
out_ << (data_block_size_ << 9)*origin_begin
<< ":" << (data_block_size_ << 9)*len
<< ":" << (data_block_size_ << 9)*data_begin
<< endl;
}
void single_map(uint64_t origin_block, uint64_t data_block, uint32_t time) {
out_ << (data_block_size_ << 9)*origin_block
<< ":" << (data_block_size_ << 9)
<< ":" << (data_block_size_ << 9)*data_block
<< endl;
}
private:
ostream &out_;
uint64_t data_block_size_;
};
}
//----------------------------------------------------------------
extern "C" {
emitter::ptr create_emitter(ostream &out) {
return emitter::ptr(new old_emitter(out));
}
}
//----------------------------------------------------------------