[Lldb-commits] [PATCH] D11303: Implement FileSystem::GetPermissions for Windows.
Adrian McCarthy
amccarth at google.com
Fri Jul 17 10:44:27 PDT 2015
amccarth created this revision.
amccarth added a reviewer: chaoren.
amccarth added a subscriber: lldb-commits.
I'm working on loading Windows mini dumps (like Linux core files). I'm doing this change as a separate PATCH in order to break the work into digestible chunks.
The core-loading code calls FileSpec::Readable (twice!) before attempting to open the file, so we need GetPermissions to indicate whether the user can read the file.
http://reviews.llvm.org/D11303
Files:
source/Host/windows/FileSystem.cpp
Index: source/Host/windows/FileSystem.cpp
===================================================================
--- source/Host/windows/FileSystem.cpp
+++ source/Host/windows/FileSystem.cpp
@@ -10,6 +10,8 @@
#include "lldb/Host/windows/windows.h"
#include <shellapi.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include "lldb/Host/FileSystem.h"
#include "llvm/Support/FileSystem.h"
@@ -71,7 +73,23 @@
FileSystem::GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions)
{
Error error;
- error.SetErrorStringWithFormat("%s is not supported on this host", __PRETTY_FUNCTION__);
+ // Beware that Windows's permission model is different from Unix's, and it's
+ // not clear if this API is supposed to check ACLs. To match the caller's
+ // expectations as closely as possible, we'll use Microsoft's _stat, which
+ // attempts to emulate POSIX stat. This should be good enough for basic
+ // checks like FileSpec::Readable.
+ struct _stat file_stats;
+ if (::_stat(file_spec.GetCString(), &file_stats) == 0)
+ {
+ // The owner permission bits in "st_mode" currently match the definitions
+ // for the owner file mode bits.
+ file_permissions = file_stats.st_mode & (_S_IREAD | _S_IWRITE | _S_IEXEC);
+ }
+ else
+ {
+ error.SetErrorToErrno();
+ }
+
return error;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11303.30014.patch
Type: text/x-patch
Size: 1371 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150717/1a718087/attachment.bin>
More information about the lldb-commits
mailing list