\hypertarget{group__Eina__Mmap__Group}{}\doxysection{Mmap Group}
\label{group__Eina__Mmap__Group}\index{Mmap Group@{Mmap Group}}


These functions provide helpers for safe mmap handling.  


\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} \mbox{\hyperlink{group__Eina__Mmap__Group_gaf51405e08c9985f057b8d0137846c905}{eina\+\_\+mmap\+\_\+safety\+\_\+enabled\+\_\+set}} (\mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} enabled)
\begin{DoxyCompactList}\small\item\em Enables or disables safe mmaped IO handling. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} \mbox{\hyperlink{group__Eina__Mmap__Group_ga83fe5e7a2a2b5afc721dcfed955ae5c1}{eina\+\_\+mmap\+\_\+safety\+\_\+enabled\+\_\+get}} (void)
\begin{DoxyCompactList}\small\item\em Gets the enabled state of mmap safety. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
These functions provide helpers for safe mmap handling. 

\begin{DoxySince}{Since}
1.\+1.\+0 
\end{DoxySince}


\doxysubsection{Function Documentation}
\mbox{\Hypertarget{group__Eina__Mmap__Group_gaf51405e08c9985f057b8d0137846c905}\label{group__Eina__Mmap__Group_gaf51405e08c9985f057b8d0137846c905}} 
\index{Mmap Group@{Mmap Group}!eina\_mmap\_safety\_enabled\_set@{eina\_mmap\_safety\_enabled\_set}}
\index{eina\_mmap\_safety\_enabled\_set@{eina\_mmap\_safety\_enabled\_set}!Mmap Group@{Mmap Group}}
\doxysubsubsection{\texorpdfstring{eina\_mmap\_safety\_enabled\_set()}{eina\_mmap\_safety\_enabled\_set()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} eina\+\_\+mmap\+\_\+safety\+\_\+enabled\+\_\+set (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}}}]{enabled }\end{DoxyParamCaption})}



Enables or disables safe mmaped IO handling. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em enabled} & The enabled state (to enable, pass \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\+\_\+\+TRUE}}) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\+\_\+\+TRUE}} on success, \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}} on failure.
\end{DoxyReturn}
This enables (if possible on your platform) a signal handler for SIGBUS, that replaces the \char`\"{}bad page\char`\"{} with a page of 0\textquotesingle{}s (from /dev/zero) if a SIGBUS occurs. This allows for safe mmap() of files that may truncate or from files on devices with IO errors. Normally these cases will result in a SIGBUS being delivered (and termination of your process), but when \char`\"{}mmap safety\char`\"{} is enabled, this will not occur. Instead a page of bytes of the value 0 will replace the \char`\"{}bad page\char`\"{}, allowing the process to continue and allow its own parsing error detection to safely abort the operation without the process falling apart.

If you disable mmap safety, the SIGBUS handler will be restored to its default handler. Note that \mbox{\hyperlink{group__Eina__File__Group_gaae165c21af09fca39c2d1f89a92cb6b1}{eina\+\_\+file\+\_\+map\+\_\+all()}} and \mbox{\hyperlink{group__Eina__File__Group_ga5c56a04cf4de6d43f73ce39b970132fa}{eina\+\_\+file\+\_\+map\+\_\+new()}} will automatically enable mmap safety as they provide an mmaped file IO layer, and rely on mmap to not fail for any part of the file.

If you set up your own SIGBUS handler, then this will effectively disable the safe mmap handling and make you liable to crashing on IO to or from such \char`\"{}damaged files\char`\"{} that would take down your process.

\begin{DoxySince}{Since}
1.\+1.\+0 
\end{DoxySince}


References \mbox{\hyperlink{group__Eina__Cpu__Group_gaeef096d5fa4ad1222937c80f60149231}{eina\+\_\+cpu\+\_\+page\+\_\+size()}}, \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\+\_\+\+FALSE}}, \mbox{\hyperlink{group__Eina__File__Group_ga858aff49902b2278be3e59aff989ed46}{eina\+\_\+file\+\_\+close\+\_\+on\+\_\+exec()}}, \mbox{\hyperlink{group__Eina__File__Group_gaedcc484fea6c2dc20b7f48664ce42dd6}{EINA\+\_\+\+LOG\+\_\+\+COLOR\+\_\+\+DEFAULT}}, \mbox{\hyperlink{group__Eina__Log__Group_ga79d0a42ab10dd0e7760b33ae33a6aae0}{eina\+\_\+log\+\_\+domain\+\_\+register()}}, \mbox{\hyperlink{group__Eina__Log__Group_ga2e33caeeeb6051526c01b7fea4d6c91b}{EINA\+\_\+\+LOG\+\_\+\+ERR}}, and \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\+\_\+\+TRUE}}.



Referenced by \mbox{\hyperlink{group__Eet__Cipher__Group_ga0bedcc0ed03bcf6f09002cc888c755e2}{eet\+\_\+identity\+\_\+open()}}, \mbox{\hyperlink{group__Eina__File__Group_gaae165c21af09fca39c2d1f89a92cb6b1}{eina\+\_\+file\+\_\+map\+\_\+all()}}, and \mbox{\hyperlink{group__Eina__File__Group_ga5c56a04cf4de6d43f73ce39b970132fa}{eina\+\_\+file\+\_\+map\+\_\+new()}}.

\mbox{\Hypertarget{group__Eina__Mmap__Group_ga83fe5e7a2a2b5afc721dcfed955ae5c1}\label{group__Eina__Mmap__Group_ga83fe5e7a2a2b5afc721dcfed955ae5c1}} 
\index{Mmap Group@{Mmap Group}!eina\_mmap\_safety\_enabled\_get@{eina\_mmap\_safety\_enabled\_get}}
\index{eina\_mmap\_safety\_enabled\_get@{eina\_mmap\_safety\_enabled\_get}!Mmap Group@{Mmap Group}}
\doxysubsubsection{\texorpdfstring{eina\_mmap\_safety\_enabled\_get()}{eina\_mmap\_safety\_enabled\_get()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} eina\+\_\+mmap\+\_\+safety\+\_\+enabled\+\_\+get (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}



Gets the enabled state of mmap safety. 

\begin{DoxyReturn}{Returns}
The safety state (\mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\+\_\+\+TRUE}} if enabled)
\end{DoxyReturn}
This returns the mmap safety state set by \mbox{\hyperlink{group__Eina__Mmap__Group_gaf51405e08c9985f057b8d0137846c905}{eina\+\_\+mmap\+\_\+safety\+\_\+enabled\+\_\+set()}}. See \mbox{\hyperlink{group__Eina__Mmap__Group_gaf51405e08c9985f057b8d0137846c905}{eina\+\_\+mmap\+\_\+safety\+\_\+enabled\+\_\+set()}} for more information.

\begin{DoxySince}{Since}
1.\+1.\+0 
\end{DoxySince}
