From f07d2835d1ed3b239caa3a2118fc99a2ef087c32 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 5 Feb 2012 21:28:17 -0800 Subject: [PATCH] ceph-dencoder: filepath Signed-off-by: Sage Weil --- src/include/filepath.h | 15 ++++++++++++++- src/test/encoding/types.h | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/include/filepath.h b/src/include/filepath.h index f26235e280e66..884707591977c 100644 --- a/src/include/filepath.h +++ b/src/include/filepath.h @@ -16,7 +16,6 @@ #ifndef CEPH_FILEPATH_H #define CEPH_FILEPATH_H - /* * BUG: /a/b/c is equivalent to a/b/c in dentry-breakdown, but not string. * -> should it be different? how? should this[0] be "", with depth 4? @@ -32,6 +31,9 @@ using namespace std; #include "buffer.h" #include "encoding.h" +#include "common/Formatter.h" + + class filepath { inodeno_t ino; // base inode. ino=0 implies pure relative path. string path; // relative path. @@ -195,6 +197,17 @@ class filepath { ::decode(path, blp); encoded = true; } + void dump(Formatter *f) const { + f->dump_unsigned("base_ino", ino); + f->dump_string("relative_path", path); + } + static void generate_test_instances(list& o) { + o.push_back(new filepath); + o.push_back(new filepath("/usr/bin", 0)); + o.push_back(new filepath("/usr/sbin", 1)); + o.push_back(new filepath("var/log", 1)); + o.push_back(new filepath("foo/bar", 101)); + } }; WRITE_CLASS_ENCODER(filepath) diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index 86c99682be97d..f2cda3fd3e448 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -1,6 +1,9 @@ #include "include/CompatSet.h" TYPE(CompatSet) +#include "include/filepath.h" +TYPE(filepath) + #include "msg/msg_types.h" TYPE(entity_name_t) TYPE(entity_addr_t) -- 2.39.5