mirror of
https://github.com/vgough/encfs.git
synced 2024-11-24 08:53:10 +01:00
Do not count usage on root path (#471)
This commit is contained in:
parent
6567b82822
commit
8caea461a7
@ -47,7 +47,12 @@ EncFS_Context::~EncFS_Context() {
|
||||
// release all entries from map
|
||||
openFiles.clear();
|
||||
}
|
||||
|
||||
std::shared_ptr<DirNode> EncFS_Context::getRoot(int *errCode) {
|
||||
return getRoot(errCode, false);
|
||||
}
|
||||
|
||||
std::shared_ptr<DirNode> EncFS_Context::getRoot(int *errCode, bool skipUsageCount) {
|
||||
std::shared_ptr<DirNode> ret = nullptr;
|
||||
do {
|
||||
{
|
||||
@ -57,7 +62,11 @@ std::shared_ptr<DirNode> EncFS_Context::getRoot(int *errCode) {
|
||||
break;
|
||||
}
|
||||
ret = root;
|
||||
++usageCount;
|
||||
// On some system, stat of "/" is allowed even if the calling user is
|
||||
// not allowed to list / to go deeper. Do not then count this call.
|
||||
if (!skipUsageCount) {
|
||||
++usageCount;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
|
@ -56,6 +56,7 @@ class EncFS_Context {
|
||||
|
||||
void setRoot(const std::shared_ptr<DirNode> &root);
|
||||
std::shared_ptr<DirNode> getRoot(int *err);
|
||||
std::shared_ptr<DirNode> getRoot(int *err, bool skipUsageCount);
|
||||
|
||||
std::shared_ptr<EncFS_Args> args;
|
||||
std::shared_ptr<EncFS_Opts> opts;
|
||||
|
@ -139,7 +139,11 @@ static int withFileNode(const char *opName, const char *path,
|
||||
EncFS_Context *ctx = context();
|
||||
|
||||
int res = -EIO;
|
||||
std::shared_ptr<DirNode> FSRoot = ctx->getRoot(&res);
|
||||
bool skipUsageCount = false;
|
||||
if (strlen(path) == 1) {
|
||||
skipUsageCount = true;
|
||||
}
|
||||
std::shared_ptr<DirNode> FSRoot = ctx->getRoot(&res, skipUsageCount);
|
||||
if (!FSRoot) {
|
||||
return res;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user