OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/proc_util.h" | 5 #include "sandbox/linux/services/proc_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 <string.h> | 10 #include <string.h> |
11 #include <sys/stat.h> | 11 #include <sys/stat.h> |
12 #include <sys/types.h> | 12 #include <sys/types.h> |
13 | 13 |
| 14 #include <memory> |
| 15 |
14 #include "base/logging.h" | 16 #include "base/logging.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/posix/eintr_wrapper.h" | 17 #include "base/posix/eintr_wrapper.h" |
17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
18 | 19 |
19 namespace sandbox { | 20 namespace sandbox { |
20 namespace { | 21 namespace { |
21 | 22 |
22 struct DIRCloser { | 23 struct DIRCloser { |
23 void operator()(DIR* d) const { | 24 void operator()(DIR* d) const { |
24 DCHECK(d); | 25 DCHECK(d); |
25 PCHECK(0 == closedir(d)); | 26 PCHECK(0 == closedir(d)); |
26 } | 27 } |
27 }; | 28 }; |
28 | 29 |
29 typedef scoped_ptr<DIR, DIRCloser> ScopedDIR; | 30 typedef std::unique_ptr<DIR, DIRCloser> ScopedDIR; |
30 | 31 |
31 base::ScopedFD OpenDirectory(const char* path) { | 32 base::ScopedFD OpenDirectory(const char* path) { |
32 DCHECK(path); | 33 DCHECK(path); |
33 base::ScopedFD directory_fd( | 34 base::ScopedFD directory_fd( |
34 HANDLE_EINTR(open(path, O_RDONLY | O_DIRECTORY | O_CLOEXEC))); | 35 HANDLE_EINTR(open(path, O_RDONLY | O_DIRECTORY | O_CLOEXEC))); |
35 PCHECK(directory_fd.is_valid()); | 36 PCHECK(directory_fd.is_valid()); |
36 return directory_fd; | 37 return directory_fd; |
37 } | 38 } |
38 | 39 |
39 } // namespace | 40 } // namespace |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 HANDLE_EINTR(open("/proc/", O_DIRECTORY | O_RDONLY | O_CLOEXEC))); | 111 HANDLE_EINTR(open("/proc/", O_DIRECTORY | O_RDONLY | O_CLOEXEC))); |
111 return HasOpenDirectory(proc_fd.get()); | 112 return HasOpenDirectory(proc_fd.get()); |
112 } | 113 } |
113 | 114 |
114 // static | 115 // static |
115 base::ScopedFD ProcUtil::OpenProc() { | 116 base::ScopedFD ProcUtil::OpenProc() { |
116 return OpenDirectory("/proc/"); | 117 return OpenDirectory("/proc/"); |
117 } | 118 } |
118 | 119 |
119 } // namespace sandbox | 120 } // namespace sandbox |
OLD | NEW |