[Lldb-commits] [PATCH] D153822: FileSystem::EnumerateDirectory should keep iterating if one entry has an invalid Status
Jason Molenda via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 26 17:53:53 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2c1108f44342: FileSystem::EnumerateDirectory should skip entries w/o Status, not halt (authored by jasonmolenda).
Changed prior to commit:
https://reviews.llvm.org/D153822?vs=534792&id=534800#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153822/new/
https://reviews.llvm.org/D153822
Files:
lldb/source/Host/common/FileSystem.cpp
lldb/unittests/Host/FileSystemTest.cpp
Index: lldb/unittests/Host/FileSystemTest.cpp
===================================================================
--- lldb/unittests/Host/FileSystemTest.cpp
+++ lldb/unittests/Host/FileSystemTest.cpp
@@ -51,6 +51,11 @@
FilesAndDirs.find(Path.str());
if (I == FilesAndDirs.end())
return make_error_code(llvm::errc::no_such_file_or_directory);
+ // Simulate a broken symlink, where it points to a file/dir that
+ // does not exist.
+ if (I->second.isSymlink() &&
+ I->second.getPermissions() == sys::fs::perms::no_perms)
+ return std::error_code(ENOENT, std::generic_category());
return I->second;
}
ErrorOr<std::unique_ptr<vfs::File>>
@@ -152,6 +157,13 @@
sys::fs::file_type::symlink_file, sys::fs::all_all);
addEntry(Path, S);
}
+
+ void addBrokenSymlink(StringRef Path) {
+ vfs::Status S(Path, UniqueID(FSID, FileID++),
+ std::chrono::system_clock::now(), 0, 0, 0,
+ sys::fs::file_type::symlink_file, sys::fs::no_perms);
+ addEntry(Path, S);
+ }
};
} // namespace
@@ -178,6 +190,7 @@
D->addRegularFile("/foo");
D->addDirectory("/bar");
D->addSymlink("/baz");
+ D->addBrokenSymlink("/lux");
D->addRegularFile("/qux", ~sys::fs::perms::all_read);
D->setCurrentWorkingDirectory("/");
return D;
Index: lldb/source/Host/common/FileSystem.cpp
===================================================================
--- lldb/source/Host/common/FileSystem.cpp
+++ lldb/source/Host/common/FileSystem.cpp
@@ -192,7 +192,7 @@
const auto &Item = *Iter;
ErrorOr<vfs::Status> Status = m_fs->status(Item.path());
if (!Status)
- break;
+ continue;
if (!find_files && Status->isRegularFile())
continue;
if (!find_directories && Status->isDirectory())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153822.534800.patch
Type: text/x-patch
Size: 1817 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230627/019b6168/attachment.bin>
More information about the lldb-commits
mailing list