From 6c1a67327382108b2249aed91974d13a3b21a61e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Fri, 18 Oct 2013 17:58:16 +0200 Subject: [PATCH] Care specially for the parent of the root (owned by root and 0755 permissions). --- src/VfsNs.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/VfsNs.cpp b/src/VfsNs.cpp index 43fb293..273cc3c 100644 --- a/src/VfsNs.cpp +++ b/src/VfsNs.cpp @@ -1280,12 +1280,13 @@ ExtendedStat VfsCatalog::getParent(const std::string& path, std::string* parentPath, std::string* name) throw (DmException) { + std::vector components; bool absPath; if (path.empty()) vfsThrow(EINVAL, "empty path"); - std::vector components = Url::splitPath(path); + components = Url::splitPath(path); *name = components.back(); components.pop_back(); @@ -1297,10 +1298,23 @@ ExtendedStat VfsCatalog::getParent(const std::string& path, // / // name // - // We can't check parent of root. + + // Root directory is special case. + if (absPath) { + ExtendedStat xStat; + + memset(&xStat.stat, 0, sizeof xStat.stat); + xStat.stat.st_mode = S_IFDIR | 0755; + xStat.name = "/.."; + + *parentPath = xStat.name; + + debug("parent of root directory, owner %u, group %u, permissions %06o", xStat.stat.st_uid, xStat.stat.st_gid, xStat.stat.st_mode); + return xStat; + } + // Single name is relative path with parent ".". - // - *parentPath = absPath ? "/" : this->getWorkingDir(); + *parentPath = this->getWorkingDir(); } else { // // At least one directory: -- 1.8.2.3