Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: base/files/file_util_posix.cc

Issue 2807463004: GN: aix port along with linux_s390x, linux_ppc64 and linux_ppc64le support. (Closed)
Patch Set: removed the changes from //base/BUILD.gn Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/files/file_util.h ('k') | base/logging.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/files/file_util.h" 5 #include "base/files/file_util.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <libgen.h> 10 #include <libgen.h>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 #if defined(OS_ANDROID) 50 #if defined(OS_ANDROID)
51 #include "base/android/content_uri_utils.h" 51 #include "base/android/content_uri_utils.h"
52 #include "base/os_compat_android.h" 52 #include "base/os_compat_android.h"
53 #endif 53 #endif
54 54
55 #if !defined(OS_IOS) 55 #if !defined(OS_IOS)
56 #include <grp.h> 56 #include <grp.h>
57 #endif 57 #endif
58 58
59 // We need to do this on AIX due to some inconsistencies in how AIX
60 // handles XOPEN_SOURCE and ALL_SOURCE.
61 #if defined(OS_AIX)
62 extern "C" char* mkdtemp(char* path);
63 #endif
64
59 namespace base { 65 namespace base {
60 66
61 namespace { 67 namespace {
62 68
63 #if defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL) 69 #if defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL)
64 static int CallStat(const char *path, stat_wrapper_t *sb) { 70 static int CallStat(const char *path, stat_wrapper_t *sb) {
65 ThreadRestrictions::AssertIOAllowed(); 71 ThreadRestrictions::AssertIOAllowed();
66 return stat(path, sb); 72 return stat(path, sb);
67 } 73 }
68 static int CallLstat(const char *path, stat_wrapper_t *sb) { 74 static int CallLstat(const char *path, stat_wrapper_t *sb) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 int CreateAndOpenFdForTemporaryFile(FilePath directory, FilePath* path) { 155 int CreateAndOpenFdForTemporaryFile(FilePath directory, FilePath* path) {
150 ThreadRestrictions::AssertIOAllowed(); // For call to mkstemp(). 156 ThreadRestrictions::AssertIOAllowed(); // For call to mkstemp().
151 *path = directory.Append(base::TempFileName()); 157 *path = directory.Append(base::TempFileName());
152 const std::string& tmpdir_string = path->value(); 158 const std::string& tmpdir_string = path->value();
153 // this should be OK since mkstemp just replaces characters in place 159 // this should be OK since mkstemp just replaces characters in place
154 char* buffer = const_cast<char*>(tmpdir_string.c_str()); 160 char* buffer = const_cast<char*>(tmpdir_string.c_str());
155 161
156 return HANDLE_EINTR(mkstemp(buffer)); 162 return HANDLE_EINTR(mkstemp(buffer));
157 } 163 }
158 164
159 #if defined(OS_LINUX) 165 #if defined(OS_LINUX) || defined(OS_AIX)
160 // Determine if /dev/shm files can be mapped and then mprotect'd PROT_EXEC. 166 // Determine if /dev/shm files can be mapped and then mprotect'd PROT_EXEC.
161 // This depends on the mount options used for /dev/shm, which vary among 167 // This depends on the mount options used for /dev/shm, which vary among
162 // different Linux distributions and possibly local configuration. It also 168 // different Linux distributions and possibly local configuration. It also
163 // depends on details of kernel--ChromeOS uses the noexec option for /dev/shm 169 // depends on details of kernel--ChromeOS uses the noexec option for /dev/shm
164 // but its kernel allows mprotect with PROT_EXEC anyway. 170 // but its kernel allows mprotect with PROT_EXEC anyway.
165 bool DetermineDevShmExecutable() { 171 bool DetermineDevShmExecutable() {
166 bool result = false; 172 bool result = false;
167 FilePath path; 173 FilePath path;
168 174
169 ScopedFD fd(CreateAndOpenFdForTemporaryFile(FilePath("/dev/shm"), &path)); 175 ScopedFD fd(CreateAndOpenFdForTemporaryFile(FilePath("/dev/shm"), &path));
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 921 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
916 922
917 int GetMaximumPathComponentLength(const FilePath& path) { 923 int GetMaximumPathComponentLength(const FilePath& path) {
918 ThreadRestrictions::AssertIOAllowed(); 924 ThreadRestrictions::AssertIOAllowed();
919 return pathconf(path.value().c_str(), _PC_NAME_MAX); 925 return pathconf(path.value().c_str(), _PC_NAME_MAX);
920 } 926 }
921 927
922 #if !defined(OS_ANDROID) 928 #if !defined(OS_ANDROID)
923 // This is implemented in file_util_android.cc for that platform. 929 // This is implemented in file_util_android.cc for that platform.
924 bool GetShmemTempDir(bool executable, FilePath* path) { 930 bool GetShmemTempDir(bool executable, FilePath* path) {
925 #if defined(OS_LINUX) 931 #if defined(OS_LINUX) || defined(OS_AIX)
926 bool use_dev_shm = true; 932 bool use_dev_shm = true;
927 if (executable) { 933 if (executable) {
928 static const bool s_dev_shm_executable = DetermineDevShmExecutable(); 934 static const bool s_dev_shm_executable = DetermineDevShmExecutable();
929 use_dev_shm = s_dev_shm_executable; 935 use_dev_shm = s_dev_shm_executable;
930 } 936 }
931 if (use_dev_shm) { 937 if (use_dev_shm) {
932 *path = FilePath("/dev/shm"); 938 *path = FilePath("/dev/shm");
933 return true; 939 return true;
934 } 940 }
935 #endif 941 #endif
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 return false; 1019 return false;
1014 1020
1015 DeleteFile(from_path, true); 1021 DeleteFile(from_path, true);
1016 return true; 1022 return true;
1017 } 1023 }
1018 1024
1019 } // namespace internal 1025 } // namespace internal
1020 1026
1021 #endif // !defined(OS_NACL_NONSFI) 1027 #endif // !defined(OS_NACL_NONSFI)
1022 } // namespace base 1028 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_util.h ('k') | base/logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698