67 | | * in '''boot mode''' (kernel_mode == 0), it initialises only the statically defined Fat-Descriptor, using informations found in the boot sector and FS-INFO sector, that are loaded in the FAT descriptor 512 bytes buffer. In this mode, it is used by the boot code to load the ''kernel.elf'' file, and the various ''application.elf'' files, |
68 | | into memory by accessing directly to the block device. |
69 | | * in '''kernel mode''' (kernel_mode != 0), it uses the distributed kernel heap to initialises the dynamically allocated structures such as the Inode-Tree, the Fat-Cache, and the File-Cache for the root directory. |
70 | | |
71 | | It returns 0 if success / It returns -1 if failure. |
| 67 | * in '''boot mode''' (kernel_mode == 0), it initializes only the statically defined Fat-Descriptor, using informations found in the boot sector and FS-INFO sector, that are loaded in the FAT descriptor 512 bytes buffer. In this mode, it is used by the boot code to load the ''kernel.elf'' file, and the various ''application.elf'' files, into memory by accessing directly to the block device. |
| 68 | * in '''kernel mode''' (kernel_mode != 0), it uses the distributed kernel heap to initialize the dynamically allocated structures such as the Inode-Tree, the Fat-Cache, and the File-Cache for the root directory. |
| 69 | |
| 70 | Returns GIET_FAT32_OK on success. Returns a negative value on error: |
| 71 | * GIET_FAT32_IO_ERROR, |
| 72 | * GIET_FAT32_INVALID_BOOT_SECTOR |
84 | | * '''pathname''' : define both the specified directory and the file name. |
85 | | * '''flags''' : O_CREATE and O_RDONLY can be ored. |
86 | | It returns the file descriptor index if success. |
87 | | It returns a negative value if error: |
88 | | * -1 : "fat not initialised" |
89 | | * -2 : "path to parent not found" |
90 | | * -3 : "one name in path too long" |
91 | | * -4 : "file not found" |
92 | | * -5 : "Cannot update parent directory" |
93 | | * -6 : "Cannot update DATA region" |
94 | | * -7 : "Cannot update FAT region" |
95 | | * -8 : "Cannot update FS_INFO sector" |
96 | | * -9 : "file descriptor array full" |
| 84 | * '''pathname''' : defines both the specified directory and the file name. |
| 85 | * '''flags''' : O_CREATE, O_RDONLY, O_TRUNCATE (can be OR'ed). |
| 86 | Returns a file descriptor index on success. Returns a negative value on error: |
| 87 | * GIET_FAT32_NOT_INITIALIZED, |
| 88 | * GIET_FAT32_FILE_NOT_FOUND, |
| 89 | * GIET_FAT32_NAME_TOO_LONG, |
| 90 | * GIET_FAT32_IO_ERROR, |
| 91 | * GIET_FAT32_TOO_MANY_OPEN_FILES |
105 | | It returns 0 if success. It returns a negative value if error: |
106 | | * -1 : "FAT not initialised" |
107 | | * -2 : "Illegal file descriptor" |
108 | | * -3 : "File not open" |
109 | | * -4 : "Cannot update DATA regions" |
110 | | * -5 : "Cannot release memory" |
111 | | |
112 | | === __int '''_fat_file_info'''( unsigned int fd_id , struct fat_file_info_s* info )__ === |
| 100 | Returns GIET_FAT32_OK on success. Returns a negative value on error: |
| 101 | * GIET_FAT32_NOT_INITIALIZED, |
| 102 | * GIET_FAT32_INVALID_FD, |
| 103 | * GIET_FAT32_NOT_OPEN, |
| 104 | * GIET_FAT32_IO_ERROR |
| 105 | |
| 106 | === __int '''_fat_file_info'''( unsigned int fd_id , fat_file_info_t* info )__ === |
137 | | It access the File-Cache associated to the file identified by the file descriptor, and transfers count bytes from the user buffer, |
138 | | to the cache, starting from the current file offset. It loads all involved clusters into cache if required. If (offset + count) is larger than the current file size, it increases the file size. It allocates new clusters if required, and updates the Fat-Cache and the FAT region on block device. As it implements a Write-Back policy, the DATA region on block device is not updated, but the modified clusters are marked dirty. |
| 131 | It accesses the File-Cache associated to the file identified by the file descriptor, and transfers count bytes from the user buffer, to the cache, starting from the current file offset. It loads all involved clusters into cache if required. If (offset + count) is larger than the current file size, the file size will be increased. It allocates new clusters if required, and updates the Fat-Cache and the FAT region on block device. As it implements a Write-Back policy, the DATA region on block device is not updated, but the modified clusters are marked dirty. |
142 | | It returns the number of bytes actually transfered if success. It returns a negative value if error. |
143 | | * -1 : "FAT not initialised" |
144 | | * -2 : "Illegal file descriptor" |
145 | | * -3 : "File not open" |
146 | | * -4 : "File not writable" |
147 | | * -5 : "No free clusters" |
148 | | * -6 : "Cannot update parent directory entry" |
149 | | * -7 : "Cannot access File-Cache" |
| 135 | Returns number of bytes actually written on success. Returns a negative value on error: |
| 136 | * GIET_FAT32_NOT_INITIALIZED, |
| 137 | * GIET_FAT32_INVALID_FD, |
| 138 | * GIET_FAT32_NOT_OPEN, |
| 139 | * GIET_FAT32_READ_ONLY, |
| 140 | * GIET_FAT32_NO_FREE_SPACE, |
| 141 | * GIET_FAT32_IO_ERROR |
173 | | It returns 0 if success. It returns a negative value if error: |
174 | | * -1 : "Fat not initialised" |
175 | | * -2 : "Path to parent not found" |
176 | | * -3 : "One name in path too long" |
177 | | * -4 : "Directory already exist" |
178 | | * -5 : "No free cluster" |
179 | | * -6 : "Cannot update parent directory" |
180 | | * -7 : "Cannot update parent DATA region" |
181 | | * -8 : "Cannot update FAT region" |
182 | | * -9 : "Cannot update FS-INFO" |
183 | | * -10 : "Cannot update directory DATA region" |
| 165 | Returns GIET_FAT32_OK on success. Returns a negative value on error: |
| 166 | * GIET_FAT32_NOT_INITIALIZED, |
| 167 | * GIET_FAT32_FILE_NOT_FOUND, |
| 168 | * GIET_FAT32_NAME_TOO_LONG, |
| 169 | * GIET_FAT32_FILE_EXISTS, |
| 170 | * GIET_FAT32_NO_FREE_SPACE, |
| 171 | * GIET_FAT32_IO_ERROR |
194 | | It returns 0 if success. It returns a negative value if error: |
195 | | * -1 : "FAT not initialised" |
196 | | * -2 : "File/Directory not found" |
197 | | * -3 : "Name too long in path" |
198 | | * -4 : "Has the wrong type" |
199 | | * -5 : "File still open" |
200 | | * -6 : "Cannot scan directory" |
201 | | * -7 : "Directory not empty" |
202 | | * -8 : "Cannot remove file/dir from FS" |
| 182 | Returns GIET_FAT32_OK on success. Returns a negative value on error: |
| 183 | * GIET_FAT32_NOT_INITIALIZED, |
| 184 | * GIET_FAT32_FILE_NOT_FOUND, |
| 185 | * GIET_FAT32_NAME_TOO_LONG, |
| 186 | * GIET_FAT32_IS_DIRECTORY, |
| 187 | * GIET_FAT32_NOT_A_DIRECTORY, |
| 188 | * GIET_FAT32_IS_OPEN, |
| 189 | * GIET_FAT32_IO_ERROR, |
| 190 | * GIET_FAT32_DIRECTORY_NOT_EMPTY |
214 | | It returns 0 if success. It returns a negative value if error: |
215 | | * -1 : "FAT not initialised" |
216 | | * -2 : "old_path not found" |
217 | | * -3 : "new_path not found" |
218 | | * -4 : "cannot scan to_remove directory" |
219 | | * -5 : "to_remove directory not empty" |
220 | | * -6 : "to_remove file still referenced" |
221 | | * -7 : "cannot add new node to new_parent directory" |
222 | | * -8 : "cannot update new_parent directory on device" |
223 | | * -9 : "cannot remove old node from old_parent directory" |
224 | | * -10 : "cannot update old_parent directory on device" |
225 | | * -11 : "cannot remove to_remove node from FS" |
| 202 | Returns GIET_FAT32_OK on success. Returns a negative value on error: |
| 203 | * GIET_FAT32_NOT_INITIALIZED, |
| 204 | * GIET_FAT32_FILE_NOT_FOUND, |
| 205 | * GIET_FAT32_MOVE_INTO_SUBDIR, |
| 206 | * GIET_FAT32_IO_ERROR, |
| 207 | * GIET_FAT32_DIRECTORY_NOT_EMPTY, |
| 208 | * GIET_FAT32_IS_OPEN |
267 | | It returns 0 if success. It returns a negative value if error. |
268 | | * -1 : "FAT not initialised" |
269 | | * -2 : "File not found" |
270 | | * -3 : "Buffer too small" |
271 | | * -4 : "Cannot access block device" |
272 | | * -5 : "Cannot access FAT on block device" |
| 250 | Returns GIET_FAT32_OK on success. Returns negative value on error: |
| 251 | * GIET_FAT32_NOT_INITIALIZED |
| 252 | * GIET_FAT32_FILE_NOT_FOUND |
| 253 | * GIET_FAT32_BUFFER_TOO_SMALL |
| 254 | * GIET_FAT32_IO_ERROR |