5 * @addtogroup Eina_Mmap_Group Mmap Group
7 * @brief These functions provide helpers for safe mmap handling
15 * @brief Enable or disable safe mmaped IO handling
17 * @param enabled The enabled state (to enable, pass #EINA_TRUE)
18 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
20 * This enables (if possible on your platform) a signal handler for
21 * SIGBUS, that replaces the "bad page" with a page of 0's (from /dev/zero)
22 * if a SIGBUS occurs. This allows for safe mmap() of files that may truncate
23 * or from files on devices with IO errors. Normally these cases will result
24 * in a SIGBUS being delivered (and termination of your process), but
25 * when "mmap safety" is enabled, this will not occur. Instead a page of
26 * bytes of the value 0 will replace the "bad page", allowing the process
27 * to continue and allow its own parsing error detection to safely abort
28 * the operation without the process falling apart.
30 * If you disable mmap safety, the SIGBUS handler will be restored to its
31 * default handler. Note that eina_file_map_all() and eina_file_map_new()
32 * will automatically enable mmap safety as they provide an mmaped file IO
33 * layer, and rely on mmap to not fail for any part of the file.
35 * If you set up your own SIGBUS handler, then this will effectively disable
36 * the safe mmap handling and make you liable to crashes on IO to or from
37 * such "damaged files" that would take down your process.
42 eina_mmap_safety_enabled_set(Eina_Bool enabled);
45 * @brief Get the enabled state of mmap safety.
47 * @return The safety state (#EINA_TRUE if enabled)
49 * This returns the mmap safety state set by eina_mmap_safety_enabled_set().
50 * See eina_mmap_safety_enabled_set() for more information.
55 eina_mmap_safety_enabled_get(void);