mirror of
https://github.com/vgough/encfs.git
synced 2025-02-17 18:20:55 +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
|
// release all entries from map
|
||||||
openFiles.clear();
|
openFiles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<DirNode> EncFS_Context::getRoot(int *errCode) {
|
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;
|
std::shared_ptr<DirNode> ret = nullptr;
|
||||||
do {
|
do {
|
||||||
{
|
{
|
||||||
@ -57,7 +62,11 @@ std::shared_ptr<DirNode> EncFS_Context::getRoot(int *errCode) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = root;
|
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) {
|
if (!ret) {
|
||||||
|
@ -56,6 +56,7 @@ class EncFS_Context {
|
|||||||
|
|
||||||
void setRoot(const std::shared_ptr<DirNode> &root);
|
void setRoot(const std::shared_ptr<DirNode> &root);
|
||||||
std::shared_ptr<DirNode> getRoot(int *err);
|
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_Args> args;
|
||||||
std::shared_ptr<EncFS_Opts> opts;
|
std::shared_ptr<EncFS_Opts> opts;
|
||||||
|
@ -139,7 +139,11 @@ static int withFileNode(const char *opName, const char *path,
|
|||||||
EncFS_Context *ctx = context();
|
EncFS_Context *ctx = context();
|
||||||
|
|
||||||
int res = -EIO;
|
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) {
|
if (!FSRoot) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user