1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<html> 3 4<head> 5<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> 6<META http-equiv="Content-Style-Type" content="text/css"> 7<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css"> 8<title>NANDSafeOpen</title> 9</head> 10 11<body> 12 13<h1>NANDSafeOpen</h1> 14<p> 15<font color="ff0000">We do not recommend the use of this function. If possible, consider using the NANDSimpleSafe version of this function.</font> 16</p> 17 18<h2>C Specification</h2> 19<dl><dd><pre><code> 20#include <revolution/nand.h> 21 22#define NAND_ACCESS_READ 0x01 23#define NAND_ACCESS_WRITE 0x02 24#define NAND_ACCESS_RW (NAND_ACCESS_READ | NAND_ACCESS_WRITE) 25 26s32 NANDSafeOpen(const char *path, NANDFileInfo *info, u8 accType, void *buf, u32 length); 27 28</code></pre></dd></dl> 29 30<h2>Arguments</h2> 31<p> 32<TABLE border="1" > 33 <tr> 34<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM><code><EM><STRONG>path</STRONG></EM></code></EM></STRONG></CODE></TD> 35<TD width="520">File name to open.</TD> 36 </tr> 37 <tr> 38<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>info</EM></STRONG></CODE></TD> 39<TD width="520">Pointer to a <CODE>NANDFileInfo</CODE> structure.</TD> 40 </tr> 41 <tr> 42<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>accType</EM></STRONG></CODE></TD> 43<TD width="520">Access type. Specifies either <code>NAND_ACCESS_READ</code>, <code>NAND_ACCESS_WRITE</code> or <CODE>NAND_ACCESS_RW</CODE>.</TD> 44 </tr> 45 <tr> 46<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>buf</EM></STRONG></CODE></TD> 47<TD width="520">Specifies the leading address of the buffer to be used when copying files. The buffer must be 32-byte aligned.</TD> 48 </tr> 49 <tr> 50<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>length</EM></STRONG></CODE></TD> 51<TD width="520">Specifies the size of the buffer to be used when copying files. Buffer size must be a multiple of 32 bytes. We recommend a size between 4 KB and 16 KB.</TD> 52 </tr> 53</TABLE> 54</p> 55 56<h2>Return Values</h2> 57<p> 58Returns one of the following codes: 59<p> 60<code>NAND_RESULT_OK<br> NAND_RESULT_ACCESS<br> NAND_RESULT_ALLOC_FAILED<br> NAND_RESULT_AUTHENTICATION<br> NAND_RESULT_BUSY<br> NAND_RESULT_CORRUPT<br> NAND_RESULT_ECC_CRIT<br> NAND_RESULT_INVALID<br> NAND_RESULT_MAXBLOCKS<br> NAND_RESULT_MAXFD<br> NAND_RESULT_MAXFILES<br> NAND_RESULT_NOEXISTS<br> NAND_RESULT_UNKNOWN<br> NAND_RESULT_FATAL_ERROR<br></code> 61</p> 62</p> 63 64<H2>Description</H2> 65<p> 66Opens a file in a manner that guarantees the atomic nature of file updates. The file opened using this function must be closed using <code><a href="./NANDSafeClose.html">NANDSafeClose</a></code> or <code><a href="./NANDSafeCloseAsync.html">NANDSafeCloseAsync</a></code>. Appropriate permissions (both read and write) must be set for the parent directory of the file where the NANDSafe type function is applied. 67</p> 68 69<p> 70This function may put the current thread to sleep. For precautions when calling similar functions, refer to <a href="../os/Interrupt/intro.html">Interrupts and Callback Functions</a>. 71</p> 72 73<h2>See Also</h2> 74<p> 75<code><a href="./NANDSafeOpenAsync.html">NANDSafeOpenAsync</a></code>, <code><a href="./NANDSafeClose.html">NANDSafeClose</a></code>, <code><a href="./NANDSafeCloseAsync.html">NANDSafeCloseAsync</a></code>, <a href="../os/Interrupt/intro.html">Interrupts and Callback Functions</a> 76</p> 77 78<H2>Revision History</H2> 79<p> 802007/09/25 Added information on the sleep status of threads.<br>2007/05/09 Added that the use of this function is not recommended.<br>2006/11/30 Added <CODE>NAND_RESULT_ALLOC_FAILED</CODE> and <CODE>NAND_RESULT_BUSY</CODE> codes.<br>2006/09/08 Added a requirement for the parent directory permissions.<br>2006/08/15 Initial version.<br> 81</p> 82 83<hr><p>CONFIDENTIAL</p></body> 84</html> 85