Commit 347fdde1 authored by Fabian Vogt's avatar Fabian Vogt

Don't try to mount outside of remote dirs

- Previously, stat $mnt/foo would try to mount QUrl("/foo") and fail
  with -EBADF
parent 83b1018a
......@@ -1078,8 +1078,16 @@ void KIOFuseVFS::lookup(fuse_req_t req, fuse_ino_t parent, const char *name)
if(auto child = that->nodeByName(parentNode, nodeName))
return that->replyEntry(req, child);
// Not found - try again
that->mountUrl(QUrl(that->remoteUrl(parentNode).toString() + QLatin1Char('/') + nodeName), [=](auto node, int error) {
QUrl parentUrl = that->remoteUrl(parentNode);
if(parentUrl.isEmpty())
{
// Directory not remote, so definitely does not exist
fuse_reply_err(req, ENOENT);
return;
}
// Not in the local tree, but remote - try again
that->mountUrl(QUrl(parentUrl.toString() + QLatin1Char('/') + nodeName), [=](auto node, int error) {
if(error && error != ENOENT)
fuse_reply_err(req, error);
else
......
......@@ -53,6 +53,7 @@ private Q_SLOTS:
void testDeletionOps();
void testArchiveOps();
void testKioErrorMapping();
void testRootLookup();
#ifdef WASTE_DISK_SPACE
void testReadWrite4GBFile();
#endif // WASTE_DISK_SPACE
......@@ -576,6 +577,14 @@ void FileOpsTest::testKioErrorMapping()
QCOMPARE(errno, EPERM);
}
void FileOpsTest::testRootLookup()
{
struct stat st;
// Verify that it does not exist...
QCOMPARE(stat(qPrintable(QStringLiteral("%1/invalid").arg(m_mountDir.path())), &st), -1);
// ... and set errno correctly
QCOMPARE(errno, ENOENT);
}
#ifdef WASTE_DISK_SPACE
void FileOpsTest::testReadWrite4GBFile()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment