From 44a98910ba82993ad6d0d4e96d2134b323c42294 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Thu, 17 Dec 2020 19:55:49 -0500 Subject: [PATCH] msp policies stopped before root path --- src/fs_path.cpp | 29 +++++++++++------------------ src/policy_msplfs.cpp | 6 +++--- src/policy_msplus.cpp | 6 +++--- src/policy_mspmfs.cpp | 6 +++--- src/policy_msppfrd.cpp | 8 ++++---- 5 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/fs_path.cpp b/src/fs_path.cpp index ba0919d8..861973f3 100644 --- a/src/fs_path.cpp +++ b/src/fs_path.cpp @@ -40,32 +40,25 @@ namespace fs string dirname(const string &path_) { - string rv; - string::reverse_iterator i; - string::reverse_iterator ei; + std::size_t i; - rv = path_; + i = path_.size() - 1; + while((i > 0) && (path_[i] == '/')) + i--; - i = rv.rbegin(); - ei = rv.rend(); - while(*i == '/' && i != ei) - i++; + while((i > 0) && (path_[i] != '/')) + i--; - while(*i != '/' && i != ei) - i++; + while((i > 0) && (path_[i] == '/')) + i--; - while(*i == '/' && i != ei) - i++; - - rv.erase(i.base(),rv.end()); - - return rv; + return path_.substr(0,i+1); } string - basename(const string &path) + basename(const string &path_) { - return path.substr(path.find_last_of('/')+1); + return path_.substr(path_.find_last_of('/')+1); } } } diff --git a/src/policy_msplfs.cpp b/src/policy_msplfs.cpp index 242d95c9..3d6a6f61 100644 --- a/src/policy_msplfs.cpp +++ b/src/policy_msplfs.cpp @@ -85,15 +85,15 @@ namespace msplfs error = ENOENT; fusepath = fusepath_; - do + for(;;) { basepath = msplfs::create_1(branches_,fusepath,&error); if(basepath) break; - + if(fusepath == "/") + break; fusepath = fs::path::dirname(fusepath); } - while(!fusepath.empty()); if(basepath == NULL) return (errno=error,-1); diff --git a/src/policy_msplus.cpp b/src/policy_msplus.cpp index 98d71157..28278fc2 100644 --- a/src/policy_msplus.cpp +++ b/src/policy_msplus.cpp @@ -85,15 +85,15 @@ namespace msplus error = ENOENT; fusepath = fusepath_; - do + for(;;) { basepath = msplus::create_1(branches_,fusepath,&error); if(basepath) break; - + if(fusepath == "/") + break; fusepath = fs::path::dirname(fusepath); } - while(!fusepath.empty()); if(basepath == NULL) return (errno=error,-1); diff --git a/src/policy_mspmfs.cpp b/src/policy_mspmfs.cpp index 14dc920d..edc8e9b6 100644 --- a/src/policy_mspmfs.cpp +++ b/src/policy_mspmfs.cpp @@ -85,15 +85,15 @@ namespace mspmfs error = ENOENT; fusepath = fusepath_; - do + for(;;) { basepath = mspmfs::create_1(branches_,fusepath,&error); if(basepath) break; - + if(fusepath == "/") + break; fusepath = fs::path::dirname(fusepath); } - while(!fusepath.empty()); if(basepath == NULL) return (errno=error,-1); diff --git a/src/policy_msppfrd.cpp b/src/policy_msppfrd.cpp index 0fa7ccaf..dd4f8931 100644 --- a/src/policy_msppfrd.cpp +++ b/src/policy_msppfrd.cpp @@ -108,15 +108,15 @@ namespace msppfrd string fusepath; fusepath = fusepath_; - do + for(;;) { error = msppfrd::create_1(branches_,fusepath,branchinfo_,sum_); if(branchinfo_->size()) - return error; - + break; + if(fusepath == "/") + break; fusepath = fs::path::dirname(fusepath); } - while(!fusepath.empty()); return error; }