xref: /utopia/UTPA2-700.0.x/projects/tmplib/include/MsFS.h (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 //    Software and any modification/derivatives thereof.
18 //    No right, ownership, or interest to MStar Software and any
19 //    modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 //    supplied together with third party`s software and the use of MStar
23 //    Software may require additional licenses from third parties.
24 //    Therefore, you hereby agree it is your sole responsibility to separately
25 //    obtain any and all third party right and license necessary for your use of
26 //    such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 //    MStar`s confidential information and you agree to keep MStar`s
30 //    confidential information in strictest confidence and not disclose to any
31 //    third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 //    kind. Any warranties are hereby expressly disclaimed by MStar, including
35 //    without limitation, any warranties of merchantability, non-infringement of
36 //    intellectual property rights, fitness for a particular purpose, error free
37 //    and in conformity with any international standard.  You agree to waive any
38 //    claim against MStar for any loss, damage, cost or expense that you may
39 //    incur related to your use of MStar Software.
40 //    In no event shall MStar be liable for any direct, indirect, incidental or
41 //    consequential damages, including without limitation, lost of profit or
42 //    revenues, lost or damage of data, and unauthorized system use.
43 //    You agree that this Section 4 shall still apply without being affected
44 //    even if MStar Software has been modified by MStar in accordance with your
45 //    request or instruction for your use, except otherwise agreed by both
46 //    parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 //    services in relation with MStar Software to you for your use of
50 //    MStar Software in conjunction with your or your customer`s product
51 //    ("Services").
52 //    You understand and agree that, except otherwise agreed by both parties in
53 //    writing, Services are provided on an "AS IS" basis and the warranty
54 //    disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 //    or otherwise:
58 //    (a) conferring any license or right to use MStar name, trademark, service
59 //        mark, symbol or any other identification;
60 //    (b) obligating MStar or any of its affiliates to furnish any person,
61 //        including without limitation, you and your customers, any assistance
62 //        of any kind whatsoever, or any information; or
63 //    (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 //    of Taiwan, R.O.C., excluding its conflict of law rules.
67 //    Any and all dispute arising out hereof or related hereto shall be finally
68 //    settled by arbitration referred to the Chinese Arbitration Association,
69 //    Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 //    Rules of the Association by three (3) arbitrators appointed in accordance
71 //    with the said Rules.
72 //    The place of arbitration shall be in Taipei, Taiwan and the language shall
73 //    be English.
74 //    The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 //
81 // Copyright (c) 2006-2007 MStar Semiconductor, Inc.
82 // All rights reserved.
83 //
84 // Unless otherwise stipulated in writing, any and all information contained
85 // herein regardless in any format shall remain the sole proprietary of
86 // MStar Semiconductor Inc. and be kept in strict confidence
87 // (��MStar Confidential Information��) by the recipient.
88 // Any unauthorized act including without limitation unauthorized disclosure,
89 // copying, use, reproduction, sale, distribution, modification, disassembling,
90 // reverse engineering and compiling of the contents of MStar Confidential
91 // Information is unlawful and strictly prohibited. MStar hereby reserves the
92 // rights to any and all damages, losses, costs and expenses resulting therefrom.
93 //
94 /// @file   apiFS.h
95 /// @author MStar Semiconductor Inc.
96 /// @brief  FileSystem wrapper
97 /// @note   Most of the APIs follows POSIX Specification including: \n
98 ///                  - Files and Directories [POSIX Section 5] \n
99 ///                  - Input and Output [POSIX Section 6]
100 /// @note   With some limitations: \n
101 ///                  - Doesn't support symolic link, user/group/other ID, ...
102 /// @note   Plz reference Open Group's Single Unix Specification V3 for detailed POSIX API descriptions: \n
103 ///                  - http://www.opengroup.org/onlinepubs/009695399/
104 ///////////////////////////////////////////////////////////////////////////////////////////////////
105 
106 #ifndef __MSFS_H__
107 #define __MSFS_H__
108 
109 //-------------------------------------------------------------------------------------------------
110 // Include Files
111 //-------------------------------------------------------------------------------------------------
112 #ifdef __cplusplus
113 extern "C"
114 {
115 #endif
116 
117 #include "MsTypes.h"
118 #include "stdlib.h"
119 #include "stdio.h"
120 #include "dirent.h"
121 
122 //-------------------------------------------------------------------------------------------------
123 // Defines
124 //------------------------------------------------------------------------------------------------
125 
126 //-------------------------------------------------------------------------------------------------
127 // Macros
128 //-------------------------------------------------------------------------------------------------
129 
130 //-------------------------------------------------------------------------------------------------
131 // Type and Structure Declaration
132 //-------------------------------------------------------------------------------------------------
133 
134 //-------------------------------------------------------------------------------------------------
135 // Extern Functions
136 //-------------------------------------------------------------------------------------------------
137 // // int MsFS_Init( int bUnicode);
138 // int MsFS_Init(int bUnitcode);
139 
140 //
141 // Mount/Umount operations
142 //
143 // int MsFS_Mount( const char *devname, const char *dir, const char *fsname, unsigned long mountflags, const void* data );
144 // int MsFS_Umount( const char *dir);
145 
146 //
147 // File/Directory operations
148 //
149 // int MsFS_Open( const char *path, int oflag, ... );
150 // int MsFS_Unlink( const char *path );
151 // int MsFS_MkDir( const char *path, mode_t mode );
152 // int MsFS_RmDir( const char *path );
153 // int MsFS_ChDir(const char *path);
154 // int MsFS_Rename( const char *path1, const char *path2 );
155 // int MsFS_Link( const char *path1, const char *path2 );
156 // int MsFS_Stat( const char *path, struct stat *buf );
157 // int MsFS_FStat( int fd, struct stat *buf );
158 // long MsFS_PathConf( const char *path, int name );
159 // long MsFS_FPathConf( int fd, int name );
160 // int MsFS_Access( const char *path, int amode );
161 // char* MsFS_GetCwd( char *buf, size_t size );
162 // DIR* MsFS_OpenDir( const char *dirname );
163 // struct dirent* MsFS_ReadDir( DIR *dirp );
164 // void MsFS_RewindDir( DIR *dirp );
165 // void MsFS_CloseDir( DIR *dirp );
166 
167 
168 //
169 // File IO operations
170 //
171 // ssize_t MsFS_Read( int fd, void *buf, size_t len );
172 // ssize_t MsFS_Write( int fd, const void *buf, size_t len );
173 // int MsFS_Close( int fd );
174 // MS_U64 MsFS_Lseek( int fd, MS_U64 pos, int whence );
175 // int MsFS_FCntl( int fd, int cmd, ... );
176 // // int MsFS_FSync( int fd );
177 void MsFS_Sync(void);
178 
179 
180 //
181 // Standard C Library's counterparts
182 //
183 FILE * MsFS_Fopen( const char *filename, const char *mode );
184 int MsFS_Fclose( FILE *stream );
185 size_t MsFS_Fread( void *data, size_t itemsize, size_t nitems, FILE *stream );
186 size_t MsFS_Fwrite( const void *data, size_t itemsize, size_t nitems, FILE *stream );
187 int MsFS_Fseek( FILE *stream, MS_U64 pos, int whence );
188 void MsFS_Rewind( FILE *stream );
189 MS_U64 MsFS_Ftell( FILE *stream );
190 int MsFS_Fflush(FILE *stream);
191 
192 //
193 // File system information query
194 //
195 typedef struct
196 {
197     MS_U32      u32ClusTotal;
198     MS_U32      u32ClusFree;
199     MS_U32      u32ClusSize;
200 } MApi_FsInfo;
201 
202 // MS_BOOL MApi_FS_Info(const char *path, MS_BOOL bUnicode, MApi_FsInfo* pFsInfo);
203 
204 #ifdef __cplusplus
205 }
206 #endif
207 
208 
209 #endif // #ifndef __MSFS_H__
210