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


These functions provide helpers for safe mmap handling.  


\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool} \hyperlink{group__Eina__Mmap__Group_ga3452104185eaee1f8d9acab09561e037}{eina\+\_\+mmap\+\_\+safety\+\_\+enabled\+\_\+set} (\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool} enabled)
\begin{DoxyCompactList}\small\item\em Enable or disable safe mmaped I\+O handling. \end{DoxyCompactList}\item 
\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool} \hyperlink{group__Eina__Mmap__Group_ga1aee5310614057b6dc62a67564ec6a2a}{eina\+\_\+mmap\+\_\+safety\+\_\+enabled\+\_\+get} (void)
\begin{DoxyCompactList}\small\item\em Get the enabled state of mmap safety. \end{DoxyCompactList}\end{DoxyCompactItemize}


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

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


\subsection{Function Documentation}
\hypertarget{group__Eina__Mmap__Group_ga3452104185eaee1f8d9acab09561e037}{\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}}
\subsubsection[{eina\+\_\+mmap\+\_\+safety\+\_\+enabled\+\_\+set}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Eina\+\_\+\+Bool} eina\+\_\+mmap\+\_\+safety\+\_\+enabled\+\_\+set (
\begin{DoxyParamCaption}
\item[{{\bf Eina\+\_\+\+Bool}}]{enabled}
\end{DoxyParamCaption}
)}}\label{group__Eina__Mmap__Group_ga3452104185eaee1f8d9acab09561e037}


Enable or disable safe mmaped I\+O handling. 


\begin{DoxyParams}{Parameters}
{\em enabled} & The enabled state (to enable, pass \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{E\+I\+N\+A\+\_\+\+T\+R\+U\+E}) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{E\+I\+N\+A\+\_\+\+T\+R\+U\+E} on success, \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{E\+I\+N\+A\+\_\+\+F\+A\+L\+S\+E} on failure.
\end{DoxyReturn}
This enables (if possible on your platform) a signal handler for S\+I\+G\+B\+U\+S, that replaces the \char`\"{}bad page\char`\"{} with a page of 0's (from /dev/zero) if a S\+I\+G\+B\+U\+S occurs. This allows for safe \hyperlink{group__Escape__Mman_ga1a69b9ee2b96ed0934c9f9c433f348ce}{mmap()} of files that may truncate or from files on devices with I\+O errors. Normally these cases will result in a S\+I\+G\+B\+U\+S 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 S\+I\+G\+B\+U\+S handler will be restored to its default handler. Note that \hyperlink{group__Eina__File__Group_ga880f977c352766672d54991421835e7d}{eina\+\_\+file\+\_\+map\+\_\+all()} and \hyperlink{group__Eina__File__Group_ga8a9f5b50c7a12340421da059501660be}{eina\+\_\+file\+\_\+map\+\_\+new()} will automatically enable mmap safety as they provide an mmaped file I\+O layer, and rely on mmap to not fail for any part of the file.

If you set up your own S\+I\+G\+B\+U\+S handler, then this will effectively disable the safe mmap handling and make you liable to crashes on I\+O to or from such \char`\"{}damaged files\char`\"{} that would take down your process.

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


References eina\+\_\+cpu\+\_\+page\+\_\+size(), E\+I\+N\+A\+\_\+\+F\+A\+L\+S\+E, E\+I\+N\+A\+\_\+\+L\+O\+G\+\_\+\+C\+O\+L\+O\+R\+\_\+\+D\+E\+F\+A\+U\+L\+T, eina\+\_\+log\+\_\+domain\+\_\+register(), E\+I\+N\+A\+\_\+\+L\+O\+G\+\_\+\+E\+R\+R, and fcntl().



Referenced by eet\+\_\+identity\+\_\+open(), eina\+\_\+file\+\_\+map\+\_\+all(), and eina\+\_\+file\+\_\+map\+\_\+new().

\hypertarget{group__Eina__Mmap__Group_ga1aee5310614057b6dc62a67564ec6a2a}{\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}}
\subsubsection[{eina\+\_\+mmap\+\_\+safety\+\_\+enabled\+\_\+get}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Eina\+\_\+\+Bool} eina\+\_\+mmap\+\_\+safety\+\_\+enabled\+\_\+get (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}\label{group__Eina__Mmap__Group_ga1aee5310614057b6dc62a67564ec6a2a}


Get the enabled state of mmap safety. 

\begin{DoxyReturn}{Returns}
The safety state (\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{E\+I\+N\+A\+\_\+\+T\+R\+U\+E} if enabled)
\end{DoxyReturn}
This returns the mmap safety state set by \hyperlink{group__Eina__Mmap__Group_ga3452104185eaee1f8d9acab09561e037}{eina\+\_\+mmap\+\_\+safety\+\_\+enabled\+\_\+set()}. See \hyperlink{group__Eina__Mmap__Group_ga3452104185eaee1f8d9acab09561e037}{eina\+\_\+mmap\+\_\+safety\+\_\+enabled\+\_\+set()} for more information.

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