diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/eina/src/include/eina_mmap.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/libraries/eina/src/include/eina_mmap.h b/libraries/eina/src/include/eina_mmap.h new file mode 100644 index 0000000..d7e3819 --- /dev/null +++ b/libraries/eina/src/include/eina_mmap.h | |||
@@ -0,0 +1,59 @@ | |||
1 | #ifndef EINA_MMAP_H_ | ||
2 | #define EINA_MMAP_H_ | ||
3 | |||
4 | /** | ||
5 | * @addtogroup Eina_Mmap_Group Mmap Group | ||
6 | * | ||
7 | * @brief These functions provide helpers for safe mmap handling | ||
8 | * | ||
9 | * @{ | ||
10 | * | ||
11 | * @since 1.1.0 | ||
12 | */ | ||
13 | |||
14 | /** | ||
15 | * @brief Enable or disable safe mmaped IO handling | ||
16 | * | ||
17 | * @param enabled The enabled state (to enable, pass EINA_TRUE) | ||
18 | * | ||
19 | * This enables (if possible on your platform) a signal handler for | ||
20 | * SIGBUS, that replaces the "bad page" with a pzge of 0's (from /dev/zero) | ||
21 | * if a SIGBUS occurs. This allows for safe mmap() of files that may truncate | ||
22 | * or from files on devices with IO errors. Normally these cases will result | ||
23 | * in a SIGBUS being delivered (and termination of yyour process), but | ||
24 | * when "mmap safety" is enabled, this will not occur. Instead a page of | ||
25 | * bytes of the value 0 will replace the "bad page", allowing the process | ||
26 | * to continue and allow its own parsing error detection to safely abort | ||
27 | * the operation without the process falling apart. | ||
28 | * | ||
29 | * If you disable mmap safety, the SIGBUS handler will be restored to its | ||
30 | * default handler. Note that eina_file_map_all() and eina_file_map_new() | ||
31 | * will automatically enable mmap safety as they provide an mmaped file IO | ||
32 | * layer, and rely on mmap to not fail for any part of the file. | ||
33 | * | ||
34 | * If you set up your own SIGBUS handler, then this will effectively disable | ||
35 | * the safe mmap handling and make you liable to crashes on IO to or from | ||
36 | * such "damaged files" that would take down your process. | ||
37 | * | ||
38 | * @since 1.1.0 | ||
39 | */ | ||
40 | EAPI Eina_Bool | ||
41 | eina_mmap_safety_enabled_set(Eina_Bool enabled); | ||
42 | |||
43 | /** | ||
44 | * @brief Get the enabled state of mmap safety. | ||
45 | * | ||
46 | * @return The safety state (EINA_TRUE if enabled) | ||
47 | * | ||
48 | * This returns the mmap safety state set by eina_mmap_safety_enabled_set(). | ||
49 | * See eina_mmap_safety_enabled_set() for more information. | ||
50 | * | ||
51 | * @since 1.1.0 | ||
52 | */ | ||
53 | EAPI Eina_Bool | ||
54 | eina_mmap_safety_enabled_get(void); | ||
55 | |||
56 | /** | ||
57 | * @} | ||
58 | */ | ||
59 | #endif | ||