diff options
author | mcgrathr@chromium.org <mcgrathr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-06 18:07:05 +0000 |
---|---|---|
committer | mcgrathr@chromium.org <mcgrathr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-06 18:07:05 +0000 |
commit | 103dccfa2877fed72cdcd7daafba3c81a51ab923 (patch) | |
tree | d45afb9c2a47c9fe53c0e98dfd0f3d02f4dd173d /base/file_util.h | |
parent | a1cff7858ed955e9792955dce46277ba57b2cb81 (diff) | |
download | chromium_src-103dccfa2877fed72cdcd7daafba3c81a51ab923.zip chromium_src-103dccfa2877fed72cdcd7daafba3c81a51ab923.tar.gz chromium_src-103dccfa2877fed72cdcd7daafba3c81a51ab923.tar.bz2 |
Adaptively use temp dir instead of /dev/shm for executable shmem file on Linux
On some Linux systems, files from /dev/shm cannot have PROT_EXEC applied to
their mappings. This depends on picayune setup details that vary between
distributions and kernels and could vary between installations. So just
use an empirical test of whether it works or not, and fall back to using
generic temporary space instead of /dev/shm for the executable case if needed.
BUG= http://code.google.com/p/chromium/issues/detail?id=103377
TEST= SharedMemory.AnonymousExecutable with /dev/shm mounted noexec
R=mark@chromium.org
Review URL: http://codereview.chromium.org/8800025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113228 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util.h')
-rw-r--r-- | base/file_util.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/base/file_util.h b/base/file_util.h index 90ec1ae..78827e9 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -259,7 +259,7 @@ BASE_EXPORT bool IsDirectoryEmpty(const FilePath& dir_path); BASE_EXPORT bool GetTempDir(FilePath* path); // Get a temporary directory for shared memory files. // Only useful on POSIX; redirects to GetTempDir() on Windows. -BASE_EXPORT bool GetShmemTempDir(FilePath* path); +BASE_EXPORT bool GetShmemTempDir(FilePath* path, bool executable); // Get the home directory. This is more complicated than just getenv("HOME") // as it knows to fall back on getpwent() etc. @@ -279,7 +279,10 @@ BASE_EXPORT bool CreateTemporaryFileInDir(const FilePath& dir, // Returns a handle to the opened file or NULL if an error occured. BASE_EXPORT FILE* CreateAndOpenTemporaryFile(FilePath* path); // Like above but for shmem files. Only useful for POSIX. -BASE_EXPORT FILE* CreateAndOpenTemporaryShmemFile(FilePath* path); +// The executable flag says the file needs to support using +// mprotect with PROT_EXEC after mapping. +BASE_EXPORT FILE* CreateAndOpenTemporaryShmemFile(FilePath* path, + bool executable); // Similar to CreateAndOpenTemporaryFile, but the file is created in |dir|. BASE_EXPORT FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path); |