From 5db85f80383a88b6e4b4155034247f0152537295 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 21 Apr 2008 08:23:54 -0700 Subject: [PATCH] filepath: a few fixes --- src/TODO | 4 +--- src/include/filepath.h | 15 ++++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/TODO b/src/TODO index 2997018eec702..4f83b25066aa0 100644 --- a/src/TODO +++ b/src/TODO @@ -40,10 +40,8 @@ kernel client - vfs - can we use dentry_path(), if it gets merged into mainline? - io / osd client - - kick requests when new map arrives - osd ack vs commit handling. hmm! -- unmount - - send (+deliver!) unmount message + - fix handling of resent message pages client - clean up client mds session vs mdsmap behavior? diff --git a/src/include/filepath.h b/src/include/filepath.h index ad3225dda4e2e..c2aea8f7e744f 100644 --- a/src/include/filepath.h +++ b/src/include/filepath.h @@ -33,8 +33,8 @@ using namespace std; #include "encodable.h" class filepath { - inodeno_t ino; // base inode. ino=0 implies relative path - string path; // relative path + inodeno_t ino; // base inode. ino=0 implies pure relative path. + string path; // relative path. leading / IFF ino=1. /** bits - path segments * this is ['a', 'b', 'c'] for both the aboslute and relative case. @@ -86,10 +86,10 @@ class filepath { ino = 0; } filepath(const string& s, inodeno_t i) : ino(i), path(s) { - assert(s[0] != '/'); + assert((ino == 1) == (s[0] == '/')); } filepath(const char* s, inodeno_t i) : ino(i), path(s) { - assert(s[0] != '/'); + assert((ino == 1) == (s[0] == '/')); } filepath(const filepath& o) { ino = o.ino; @@ -131,8 +131,9 @@ class filepath { } bool empty() const { return path.length() == 0; } - bool absolute() const { return ino > 0; } - bool relative() const { return !absolute(); } + bool absolute() const { return ino == 1; } + bool pure_relative() const { return ino == 0; } + bool ino_relative() const { return ino > 0; } const string& operator[](int i) const { if (bits.empty() && path.length() > 0) parse_bits(); @@ -182,7 +183,7 @@ class filepath { bits.push_back(s); } void append(const filepath& a) { - assert(a.relative()); + assert(a.pure_relative()); for (unsigned i=0; i