OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2013 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_DESC_CACHEABILITY_DESC_CACHEABILITY_H_ | 7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_DESC_CACHEABILITY_DESC_CACHEABILITY_H_ |
8 #define NATIVE_CLIENT_SRC_TRUSTED_DESC_CACHEABILITY_DESC_CACHEABILITY_H_ | 8 #define NATIVE_CLIENT_SRC_TRUSTED_DESC_CACHEABILITY_DESC_CACHEABILITY_H_ |
9 | 9 |
10 #include "native_client/src/include/nacl_base.h" | 10 #include "native_client/src/include/nacl_base.h" |
11 | 11 |
12 EXTERN_C_BEGIN | 12 EXTERN_C_BEGIN |
13 | 13 |
14 struct NaClDesc; | 14 struct NaClDesc; |
15 struct NaClFileToken; | 15 struct NaClFileToken; |
16 struct NaClValidationCache; | 16 struct NaClValidationCache; |
17 | 17 |
18 /* | 18 /* |
19 * NaClDescSetFileToken associates the contents of |token| with |desc| | |
20 * as NaClDesc metadata. Any other metadata previously associated | |
21 * with |desc| is released / destroyed. Returns non-zero value for | |
22 * success. (Boolean function.) | |
23 */ | |
24 int NaClDescSetFileToken(struct NaClDesc *desc, | |
25 struct NaClFileToken const *token); | |
26 | |
27 /* | |
28 * NaClDescGetFileToken checks if there is metadata associated with | |
29 * |desc| that contains a previously serialized NaClFileToken object. | |
30 * If so, it writes the NaClFileToken pointed to by |out_token| with | |
31 * the file token, and returns a non-zero value. (Boolean function.) | |
32 */ | |
33 int NaClDescGetFileToken(struct NaClDesc *desc, | |
34 struct NaClFileToken *out_token); | |
35 | |
36 /* | |
37 * NaClExchangeFileTokenForMappableDesc checks the |file_token| with | 19 * NaClExchangeFileTokenForMappableDesc checks the |file_token| with |
38 * the |validation_cache| and, if the file token is valid, i.e., for a | 20 * the |validation_cache| and, if the file token is valid, i.e., for a |
39 * file that should be safe to map (immutable for the duration of our | 21 * file that should be safe to map (immutable for the duration of our |
40 * execution), returns a NaClDesc for that file that should be used | 22 * execution), returns a NaClDesc for that file that should be used |
41 * for the memory mapping. | 23 * for the memory mapping. |
42 */ | 24 */ |
43 struct NaClDesc *NaClExchangeFileTokenForMappableDesc( | 25 struct NaClDesc *NaClExchangeFileTokenForMappableDesc( |
44 struct NaClFileToken *file_token, | 26 struct NaClFileToken *file_token, |
45 struct NaClValidationCache *validation_cache); | 27 struct NaClValidationCache *validation_cache); |
46 | 28 |
47 /* | 29 /* |
48 * NaClReplaceDescIfValidationCacheAssertsMappable checks | 30 * NaClReplaceDescIfValidationCacheAssertsMappable checks |
49 * |*desc_in_out| to see if it contains a NaClFileToken as metadata, | 31 * |*desc_in_out| to see if it contains a NaClFileToken as metadata, |
50 * and if so, queries the |validation_cache| with it. If the | 32 * and if so, queries the |validation_cache| with it. If the |
51 * validation cache says that this is a "safe" file by returning what | 33 * validation cache says that this is a "safe" file by returning what |
52 * should be an equivalent file descriptor (in the Chrome embedding, | 34 * should be an equivalent file descriptor (in the Chrome embedding, |
53 * via a separate, trusted communication link) the |*desc_in_out| | 35 * via a separate, trusted communication link) the |*desc_in_out| |
54 * reference count is decremented and then the NaClDesc pointer is | 36 * reference count is decremented and then the NaClDesc pointer is |
55 * replaced with one that wraps the validator-supplied file | 37 * replaced with one that wraps the validator-supplied file |
56 * descriptor. | 38 * descriptor. |
57 */ | 39 */ |
58 void NaClReplaceDescIfValidationCacheAssertsMappable( | 40 void NaClReplaceDescIfValidationCacheAssertsMappable( |
59 struct NaClDesc **desc_in_out, | 41 struct NaClDesc **desc_in_out, |
60 struct NaClValidationCache *validation_cache); | 42 struct NaClValidationCache *validation_cache); |
61 | 43 |
62 EXTERN_C_END | 44 EXTERN_C_END |
63 | 45 |
64 #endif | 46 #endif |
OLD | NEW |