Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "sandbox/linux/services/libc_urandom_override.h" | 5 #include "sandbox/linux/services/libc_urandom_override.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #include <pthread.h> | 8 #include <pthread.h> |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 | 52 |
| 53 if (!g_libc_fopen) { | 53 if (!g_libc_fopen) { |
| 54 LOG(FATAL) << "Failed to get fopen() from libc."; | 54 LOG(FATAL) << "Failed to get fopen() from libc."; |
| 55 } else if (!g_libc_fopen64) { | 55 } else if (!g_libc_fopen64) { |
| 56 #if !defined(OS_OPENBSD) && !defined(OS_FREEBSD) | 56 #if !defined(OS_OPENBSD) && !defined(OS_FREEBSD) |
| 57 LOG(WARNING) << "Failed to get fopen64() from libc. Using fopen() instead."; | 57 LOG(WARNING) << "Failed to get fopen64() from libc. Using fopen() instead."; |
| 58 #endif // !defined(OS_OPENBSD) && !defined(OS_FREEBSD) | 58 #endif // !defined(OS_OPENBSD) && !defined(OS_FREEBSD) |
| 59 g_libc_fopen64 = g_libc_fopen; | 59 g_libc_fopen64 = g_libc_fopen; |
| 60 } | 60 } |
| 61 | 61 |
| 62 #if defined(LIBC_GLIBC) | |
| 62 // TODO(sergeyu): This works only on systems with glibc. Fix it to | 63 // TODO(sergeyu): This works only on systems with glibc. Fix it to |
| 63 // work properly on other systems if necessary. | 64 // work properly on other systems if necessary. |
| 64 g_libc_xstat = reinterpret_cast<XstatFunction>( | 65 g_libc_xstat = reinterpret_cast<XstatFunction>( |
| 65 dlsym(RTLD_NEXT, "__xstat")); | 66 dlsym(RTLD_NEXT, "__xstat")); |
| 66 g_libc_xstat64 = reinterpret_cast<Xstat64Function>( | 67 g_libc_xstat64 = reinterpret_cast<Xstat64Function>( |
| 67 dlsym(RTLD_NEXT, "__xstat64")); | 68 dlsym(RTLD_NEXT, "__xstat64")); |
| 68 | 69 |
| 69 if (!g_libc_xstat) { | 70 if (!g_libc_xstat) { |
| 70 LOG(FATAL) << "Failed to get __xstat() from libc."; | 71 LOG(FATAL) << "Failed to get __xstat() from libc."; |
| 71 } | 72 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 if (g_override_urandom && strcmp(path, kUrandomDevPath) == 0) { | 149 if (g_override_urandom && strcmp(path, kUrandomDevPath) == 0) { |
| 149 int result = __fxstat64(version, base::GetUrandomFD(), buf); | 150 int result = __fxstat64(version, base::GetUrandomFD(), buf); |
| 150 return result; | 151 return result; |
| 151 } else { | 152 } else { |
| 152 CHECK_EQ(0, pthread_once(&g_libc_file_io_funcs_guard, | 153 CHECK_EQ(0, pthread_once(&g_libc_file_io_funcs_guard, |
| 153 InitLibcFileIOFunctions)); | 154 InitLibcFileIOFunctions)); |
| 154 CHECK(g_libc_xstat64); | 155 CHECK(g_libc_xstat64); |
| 155 return g_libc_xstat64(version, path, buf); | 156 return g_libc_xstat64(version, path, buf); |
| 156 } | 157 } |
| 157 } | 158 } |
| 159 #endif // LIBC_GLIBC | |
|
jln (very slow on Chromium)
2013/06/12 20:27:59
Nit: this should be "// defined(LIBC_GLIBC)"
Mostyn Bramley-Moore
2013/06/12 20:41:41
That doesn't match the format used two lines down,
| |
| 158 | 160 |
| 159 #endif // !ADDRESS_SANITIZER | 161 #endif // !ADDRESS_SANITIZER |
| 160 | 162 |
| 161 } // namespace content | 163 } // namespace content |
| OLD | NEW |