[llvm] r184630 - Create the file with the right permissions instead of setting it afterwards.

罗勇刚(Yonggang Luo) luoyonggang at gmail.com
Mon Jun 24 11:47:09 PDT 2013


Patch:
Add all_read, all_write, all_exe.
Use owner_read | owner_write instead 0600
Use all_read | all_write instead 0666


523565e3ad76c5938990cefa48603a7f9d619964
 include/llvm/Support/FileSystem.h | 7 +++++--
 tools/llvm-ar/ArchiveWriter.cpp   | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/llvm/Support/FileSystem.h
b/include/llvm/Support/FileSystem.h
index 5c514dc..5073c7c 100644
--- a/include/llvm/Support/FileSystem.h
+++ b/include/llvm/Support/FileSystem.h
@@ -111,6 +111,9 @@ enum perms {
   others_write =   02,
   others_exe   =   01,
   others_all   = others_read | others_write | others_exe,
+  all_read     = owner_read | group_read | others_read,
+  all_write    = owner_write | group_write | others_write,
+  all_exe      = owner_exe | group_exe | others_exe,
   all_all      = owner_all | group_all | others_all,
   set_uid_on_exe  = 04000,
   set_gid_on_exe  = 02000,
@@ -542,11 +545,11 @@ error_code status_known(const Twine &path, bool &result);
 ///          otherwise a platform specific error_code.
 error_code unique_file(const Twine &model, int &result_fd,
                        SmallVectorImpl<char> &result_path,
-                       bool makeAbsolute = true, unsigned mode = 0600);
+                       bool makeAbsolute = true, unsigned mode =
owner_read | owner_write);

 /// @brief Simpler version for clients that don't want an open file.
 error_code unique_file(const Twine &Model, SmallVectorImpl<char> &ResultPath,
-                       bool MakeAbsolute = true, unsigned Mode = 0600);
+                       bool MakeAbsolute = true, unsigned Mode =
owner_read | owner_write);

 /// @brief Canonicalize path.
 ///
diff --git a/tools/llvm-ar/ArchiveWriter.cpp b/tools/llvm-ar/ArchiveWriter.cpp
index 8f010ad..8dcc636 100644
--- a/tools/llvm-ar/ArchiveWriter.cpp
+++ b/tools/llvm-ar/ArchiveWriter.cpp
@@ -268,7 +268,7 @@ bool Archive::writeToDisk(bool TruncateNames,
std::string *ErrMsg) {
   int TmpArchiveFD;
   SmallString<128> TmpArchive;
   error_code EC = sys::fs::unique_file("temp-archive-%%%%%%%.a", TmpArchiveFD,
-                                       TmpArchive, true, 0666);
+                                       TmpArchive, true, all_read | all_write);
   if (EC)
     return true;



More information about the llvm-commits mailing list