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 "base/linux_util.h" | 5 #include "base/linux_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 <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 scoped_ptr<char[]> syscall_data(new char[expected_data.length()]); | 280 scoped_ptr<char[]> syscall_data(new char[expected_data.length()]); |
281 for (std::vector<pid_t>::const_iterator | 281 for (std::vector<pid_t>::const_iterator |
282 i = tids.begin(); i != tids.end(); ++i) { | 282 i = tids.begin(); i != tids.end(); ++i) { |
283 const pid_t current_tid = *i; | 283 const pid_t current_tid = *i; |
284 snprintf(buf, sizeof(buf), "/proc/%d/task/%d/syscall", pid, current_tid); | 284 snprintf(buf, sizeof(buf), "/proc/%d/task/%d/syscall", pid, current_tid); |
285 int fd = open(buf, O_RDONLY); | 285 int fd = open(buf, O_RDONLY); |
286 if (fd < 0) | 286 if (fd < 0) |
287 continue; | 287 continue; |
288 if (syscall_supported != NULL) | 288 if (syscall_supported != NULL) |
289 *syscall_supported = true; | 289 *syscall_supported = true; |
290 bool read_ret = | 290 bool read_ret = ReadFromFD(fd, syscall_data.get(), expected_data.length()); |
291 file_util::ReadFromFD(fd, syscall_data.get(), expected_data.length()); | |
292 close(fd); | 291 close(fd); |
293 if (!read_ret) | 292 if (!read_ret) |
294 continue; | 293 continue; |
295 | 294 |
296 if (0 == strncmp(expected_data.c_str(), syscall_data.get(), | 295 if (0 == strncmp(expected_data.c_str(), syscall_data.get(), |
297 expected_data.length())) { | 296 expected_data.length())) { |
298 return current_tid; | 297 return current_tid; |
299 } | 298 } |
300 } | 299 } |
301 return -1; | 300 return -1; |
302 } | 301 } |
303 | 302 |
304 } // namespace base | 303 } // namespace base |
OLD | NEW |