summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--netfs/fuse/fuseConfig.ice3
-rw-r--r--netfs/fuse/fuseDirs.cpp8
-rw-r--r--netfs/unittests/altFuse.xml1
-rw-r--r--netfs/unittests/testCore.cpp56
4 files changed, 54 insertions, 14 deletions
diff --git a/netfs/fuse/fuseConfig.ice b/netfs/fuse/fuseConfig.ice
index 52116ea..e425c21 100644
--- a/netfs/fuse/fuseConfig.ice
+++ b/netfs/fuse/fuseConfig.ice
@@ -20,6 +20,9 @@ module NetFS {
["slicer:name:async"]
bool Async = false;
+
+ ["slicer:name:listdir"]
+ bool ListDir = true;
};
["slicer:key:name","slicer:value:resource","slicer:item:resource"]
diff --git a/netfs/fuse/fuseDirs.cpp b/netfs/fuse/fuseDirs.cpp
index c277798..2b51a66 100644
--- a/netfs/fuse/fuseDirs.cpp
+++ b/netfs/fuse/fuseDirs.cpp
@@ -53,7 +53,7 @@ FuseApp::readdir(const char * p, void * buf, fuse_fill_dir_t filler, off_t, stru
std::string path(p);
path += "/";
auto expiry = time(NULL) + 2;
- if (od->remoteV2) {
+ if (fcr->ListDir && od->remoteV2) {
for (const auto & e : od->remoteV2->listdir()) {
filler(buf, e.first.c_str(), NULL, 0);
statCache.add(path + e.first, converter.convert(e.second), expiry);
@@ -62,12 +62,6 @@ FuseApp::readdir(const char * p, void * buf, fuse_fill_dir_t filler, off_t, stru
else {
for (const auto & e : od->remote->readdir()) {
filler(buf, e.c_str(), NULL, 0);
- std::string epath = path + e;
- auto asga = volume->begin_getattr(reqEnv(), epath);
- statCache.addFactory(epath,
- [asga,this]() {
- return converter.convert(volume->end_getattr(asga));
- }, expiry);
}
}
return 0;
diff --git a/netfs/unittests/altFuse.xml b/netfs/unittests/altFuse.xml
index 37f55a3..22b791a 100644
--- a/netfs/unittests/altFuse.xml
+++ b/netfs/unittests/altFuse.xml
@@ -5,6 +5,7 @@
<name>testvol</name>
<resource>
<export>testvol</export>
+ <listdir>false</listdir>
<endpoints>
<endpoint>overridden</endpoint>
</endpoints>
diff --git a/netfs/unittests/testCore.cpp b/netfs/unittests/testCore.cpp
index de5c9d2..34e2cec 100644
--- a/netfs/unittests/testCore.cpp
+++ b/netfs/unittests/testCore.cpp
@@ -51,6 +51,15 @@ class Core {
{
}
+ static
+ int
+ nameListAdd(void *buf, const char *name, const struct stat *, off_t)
+ {
+ static_cast<NetFS::NameList *>(buf)->push_back(name);
+ return 0;
+ }
+
+
protected:
MockDaemonHost daemonHost;
FuseMockHost fuseHost;
@@ -160,13 +169,6 @@ BOOST_AUTO_TEST_CASE( testSandboxing )
BOOST_REQUIRE(boost::filesystem::exists(binDir / testExport / "inside2"));
}
-int
-nameListAdd(void *buf, const char *name, const struct stat *, off_t)
-{
- static_cast<NetFS::NameList *>(buf)->push_back(name);
- return 0;
-}
-
void
enableWriteOnDir(const fuse_operations * fuse, const char * dir)
{
@@ -502,6 +504,46 @@ BOOST_AUTO_TEST_SUITE_END();
BOOST_FIXTURE_TEST_SUITE( NetfsAltCore, AltCore );
+BOOST_AUTO_TEST_CASE( noListDir )
+{
+ struct fuse_file_info fi;
+ memset(&fi, 0, sizeof(fi));
+ BOOST_REQUIRE_EQUAL(fuse->mkdir("/test", 0700), 0);
+ BOOST_REQUIRE(boost::filesystem::is_directory(binDir / testExport / "test"));
+ BOOST_REQUIRE_EQUAL(fuse->mkdir("/test", 0700), -EEXIST);
+
+ BOOST_REQUIRE_EQUAL(fuse->opendir("/test", &fi), 0);
+ NetFS::NameList nl;
+ BOOST_REQUIRE_EQUAL(fuse->readdir("/test", &nl, &nameListAdd, 0, &fi), 0);
+ BOOST_REQUIRE_EQUAL(nl.size(), 2);
+ std::sort(nl.begin(), nl.end());
+ BOOST_REQUIRE_EQUAL(nl[0], ".");
+ BOOST_REQUIRE_EQUAL(nl[1], "..");
+ BOOST_REQUIRE_EQUAL(fuse->releasedir("/test", &fi), 0);
+ nl.clear();
+
+ BOOST_REQUIRE_EQUAL(fuse->mkdir("/test/sub", 0700), 0);
+ BOOST_REQUIRE_EQUAL(fuse->opendir("/test", &fi), 0);
+ BOOST_REQUIRE_EQUAL(fuse->readdir("/test", &nl, &nameListAdd, 0, &fi), 0);
+ BOOST_REQUIRE_EQUAL(nl.size(), 3);
+ std::sort(nl.begin(), nl.end());
+ BOOST_REQUIRE_EQUAL(nl[0], ".");
+ BOOST_REQUIRE_EQUAL(nl[1], "..");
+ BOOST_REQUIRE_EQUAL(nl[2], "sub");
+ BOOST_REQUIRE_EQUAL(fuse->releasedir("/test", &fi), 0);
+ nl.clear();
+
+ BOOST_REQUIRE_EQUAL(fuse->readdir("/test", &nl, &nameListAdd, 0, &fi), -EBADF);
+ BOOST_REQUIRE_EQUAL(fuse->releasedir("/test", &fi), -EBADF);
+
+ BOOST_REQUIRE_EQUAL(fuse->rmdir("/test"), -ENOTEMPTY);
+ BOOST_REQUIRE_EQUAL(fuse->rmdir("/test/sub"), 0);
+ BOOST_REQUIRE_EQUAL(fuse->rmdir("/test"), 0);
+ BOOST_REQUIRE(!boost::filesystem::is_directory(binDir / testExport / "test"));
+ BOOST_REQUIRE_EQUAL(fuse->rmdir("/test"), -ENOENT);
+ BOOST_REQUIRE_EQUAL(fuse->opendir("/test", &fi), -ENOENT);
+}
+
BOOST_AUTO_TEST_CASE( testFGWrites )
{
struct fuse_file_info fi;