summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-04 17:52:04 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-04 17:52:04 +0000
commit80a086c59537a006c36c8433a011f0a76e8a84d4 (patch)
tree2790c0bef400c2a8c31f4d0312b48a7b6f107781 /base
parent96921d17f7932adaa6cc5afc37b3d13c46715ae5 (diff)
downloadchromium_src-80a086c59537a006c36c8433a011f0a76e8a84d4.zip
chromium_src-80a086c59537a006c36c8433a011f0a76e8a84d4.tar.gz
chromium_src-80a086c59537a006c36c8433a011f0a76e8a84d4.tar.bz2
Linux: don't try and read shmmax in the sandbox.
In the sandbox, reading shmmax from proc always fails. Thus, we move the function into base and call it before starting the sandbox. The value is then cached. http://codereview.chromium.org/159843 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22393 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/sys_info.h5
-rw-r--r--base/sys_info_posix.cc18
2 files changed, 23 insertions, 0 deletions
diff --git a/base/sys_info.h b/base/sys_info.h
index 581720d..5469da54 100644
--- a/base/sys_info.h
+++ b/base/sys_info.h
@@ -65,6 +65,11 @@ class SysInfo {
// allocate.
static size_t VMAllocationGranularity();
+#if defined(OS_LINUX)
+ // Returns the maximum SysV shared memory segment size.
+ static size_t MaxSharedMemorySize();
+#endif
+
#if defined(OS_CHROMEOS)
// Returns the name of the version entry we wish to look up in the
// Linux Standard Base release information file.
diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc
index 388ccba..23156e2 100644
--- a/base/sys_info_posix.cc
+++ b/base/sys_info_posix.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/file_util.h"
#include "base/sys_info.h"
#include "base/basictypes.h"
@@ -150,4 +151,21 @@ size_t SysInfo::VMAllocationGranularity() {
return getpagesize();
}
+#if defined(OS_LINUX)
+// static
+size_t SysInfo::MaxSharedMemorySize() {
+ static size_t limit;
+ static bool limit_valid = false;
+
+ if (!limit_valid) {
+ std::string contents;
+ file_util::ReadFileToString(FilePath("/proc/sys/kernel/shmmax"), &contents);
+ limit = strtoul(contents.c_str(), NULL, 0);
+ limit_valid = true;
+ }
+
+ return limit;
+}
+#endif
+
} // namespace base