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 #ifndef SANDBOX_BPF_H__ | 5 #ifndef SANDBOX_BPF_H__ |
6 #define SANDBOX_BPF_H__ | 6 #define SANDBOX_BPF_H__ |
7 | 7 |
8 #include <endian.h> | 8 #include <endian.h> |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <fcntl.h> | 10 #include <fcntl.h> |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 friend class Sandbox; | 169 friend class Sandbox; |
170 public: | 170 public: |
171 // We can either wrap a symbolic ErrorCode (i.e. enum values), an errno | 171 // We can either wrap a symbolic ErrorCode (i.e. enum values), an errno |
172 // value (in the range 1..4095), or a pointer to a TrapFnc callback | 172 // value (in the range 1..4095), or a pointer to a TrapFnc callback |
173 // handling a SECCOMP_RET_TRAP trap. | 173 // handling a SECCOMP_RET_TRAP trap. |
174 // All of these different values are stored in the "err_" field. So, code | 174 // All of these different values are stored in the "err_" field. So, code |
175 // that is using the ErrorCode class typically operates on a single 32bit | 175 // that is using the ErrorCode class typically operates on a single 32bit |
176 // field. | 176 // field. |
177 // This is not only quiet efficient, it also makes the API really easy to | 177 // This is not only quiet efficient, it also makes the API really easy to |
178 // use. | 178 // use. |
179 ErrorCode(int err = SB_INVALID) { | 179 ErrorCode(int err = SB_INVALID) |
| 180 : id_(0), |
| 181 fnc_(NULL), |
| 182 aux_(NULL) { |
180 switch (err) { | 183 switch (err) { |
181 case SB_INVALID: | 184 case SB_INVALID: |
182 err_ = SECCOMP_RET_INVALID; | 185 err_ = SECCOMP_RET_INVALID; |
183 break; | 186 break; |
184 case SB_ALLOWED: | 187 case SB_ALLOWED: |
185 err_ = SECCOMP_RET_ALLOW; | 188 err_ = SECCOMP_RET_ALLOW; |
186 break; | 189 break; |
187 case SB_INSPECT_ARG_1...SB_INSPECT_ARG_6: | 190 case SB_INSPECT_ARG_1...SB_INSPECT_ARG_6: |
188 die("Not implemented"); | 191 die("Not implemented"); |
189 break; | 192 break; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 static Traps *traps_; | 374 static Traps *traps_; |
372 static TrapIds trapIds_; | 375 static TrapIds trapIds_; |
373 static ErrorCode *trapArray_; | 376 static ErrorCode *trapArray_; |
374 static size_t trapArraySize_; | 377 static size_t trapArraySize_; |
375 DISALLOW_IMPLICIT_CONSTRUCTORS(Sandbox); | 378 DISALLOW_IMPLICIT_CONSTRUCTORS(Sandbox); |
376 }; | 379 }; |
377 | 380 |
378 } // namespace | 381 } // namespace |
379 | 382 |
380 #endif // SANDBOX_BPF_H__ | 383 #endif // SANDBOX_BPF_H__ |
OLD | NEW |