Changes between Version 18 and Version 19 of file_system
- Timestamp:
- Jul 8, 2015, 7:00:52 PM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
file_system
v18 v19 59 59 for each modified cluster. 60 60 61 == 4) Access Functions == 62 63 === int '''_fat_init'''( unsigned int kernel_mode ) === 61 == 4) Extern Functions == 62 63 The following functions implement the FAT related system calls. 64 65 === __int '''_fat_init'''( unsigned int kernel_mode )__ === 64 66 This function initializes the FAT structures. It is called twice, by the boot-loader, and by the kernel_init. 65 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, … … 69 71 It returns 0 if success / It returns -1 if failure. 70 72 71 === int '''_fat_open'''( char* pathname , unsigned int flags )===73 === __int '''_fat_open'''( char* pathname , unsigned int flags )__ === 72 74 This function implements the giet_fat_open() system call. 73 75 The semantic is similar to the UNIX open() function, but only the O_CREATE … … 94 96 * -9 : "file descriptor array full" 95 97 96 === int '''_fat_close'''( unsigned int fd_id )===98 === __int '''_fat_close'''( unsigned int fd_id )__ === 97 99 This function implements the "giet_fat_close()" system call. 98 100 The semantic is similar to the UNIX "close()" function. … … 107 109 * -4 : "Cannot release memory" 108 110 109 === int '''_fat_file_info'''( unsigned int fd_id , unsigned int* size , unsigned int* offset )===111 === __int '''_fat_file_info'''( unsigned int fd_id , unsigned int* size , unsigned int* offset )__ === 110 112 This function implements the giet_fat_file_info() system call. 111 113 It returns the size and the current offset value for a file identified by the "fd_id" argument. … … 118 120 * -3 : "File not open" 119 121 120 === int '''_fat_read'''( unsigned int fd_id , void* buffer , unsigned int count )===122 === __int '''_fat_read'''( unsigned int fd_id , void* buffer , unsigned int count )__ === 121 123 This function implements the "giet_fat_read()" system call. 122 124 It access the File-Cache associated to the file identified by the file descriptor, and transfers "count" bytes from the cache to the user buffer, starting from the current file offset. … … 129 131 * -2 : "Illegal file descriptor" 130 132 * -3 : "File not open" 131 * -4 : "Cannot load 132 133 === int '''_fat_write'''( unsigned int fd_id , void* buffer , unsigned int count )===134 This function implements the "giet_fat_write()" system call , that has the same semantic as the UNIX "write()" function.133 * -4 : "Cannot load file from device" 134 135 === __int '''_fat_write'''( unsigned int fd_id , void* buffer , unsigned int count )__ === 136 This function implements the "giet_fat_write()" system call. 135 137 It access the File-Cache associated to the file identified by the file descriptor, and transfers count bytes from the user buffer, 136 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. … … 138 140 * '''buffer''' : pointer on the memory buffer 139 141 * '''count''' : number of bytes 140 It returns the number of bytes actually transfered if success / It returns -1 if failure. 141 142 === int '''_fat_lseek'''( unsigned int fd_id , unsigned int offset , unsigned int whence ) === 143 This function implements the "giet_fat_lseek()" system call, that has the same semantic as the UNIX ''seek()'' function. 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" 150 151 === __int '''_fat_lseek'''( unsigned int fd_id , unsigned int offset , unsigned int whence )__ === 152 This function implements the "giet_fat_lseek()" system call. 144 153 It repositions the offset in the file defined by the file descriptor, according to the offset and whence arguments. 145 154 The accepted values for the whence argument are SEEK_SET and SEEK_CUR: … … 150 159 * '''offset''' : pointer on the memory buffer 151 160 * '''count''' : number of bytes 152 It returns new offset value (bytes) if success / It returns -1 if failure. 153 154 === int '''_fat_mkdir'''( char* pathname ) === 161 It returns new offset value (bytes) if success. It returns a negative value if error: 162 * -1 : "FAT not initialised" 163 * -2 : "Illegal file descriptor" 164 * -3 : "File not open" 165 * -4 : "Illegal whence argument" 166 167 === __int '''_fat_mkdir'''( char* pathname )__ === 155 168 This function implements the giet_fat_mkdir() system call, that has the same semantic as the UNIX ''mkdir()'' function. 156 169 It creates a new directory in the File System as specified by the pathname argument. … … 158 171 The Inode-Tree is updated. 159 172 * '''pathname''' : complete pathname 160 It returns 0 if success / It returns -1 if failure. 161 162 === int '''_fat_unlink'''( char* pathname ) === 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" 184 185 === __int '''_fat_remove'''( char* pathname , unsigned int should_be_dir )__ === 163 186 This function implements the giet_fat_unlink() system call, that has the same semantic as the UNIX ''unlink()'' function. 164 187 It removes the file identified by the pathname argument from the File System. An error is returned if the number of references … … 169 192 The Inode-Tree is updated. 170 193 * '''pathname''' : directory complete pathname 171 It returns 0 if success / It returns -1 if failure. 172 173 === int '''_fat_read_no_cache'''( char* pathname , unsigned int buffer_vbase , unsigned int buffer_size ) === 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" 203 204 === __int _fat_rename( char* old_path , new_path )__ === 205 This function implements the giet_fat_rename() system call. 206 It moves an existing file or directory from one node (defined by "old_path" 207 argument) to another node (defined by "new_path" argument) in the FS tree. 208 The type (file/directory) and content are not modified. 209 If the new_path file/dir exist, it is removed from the file system, but only 210 if the remove condition is respected (directory empty / file not referenced). 211 The removed entry is only removed after the new entry is actually created. 212 * '''old_path''' : old path-name (from root). 213 * '''new_path''' : new path-name (from root). 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" 226 227 === __int '''_fat_list'''( char* pathname )__ === 228 This function implements the giet_fat_list() system call. 229 It displays the content of a directory identified by the pathname argument. 230 It returns 0 if success. It returns a negative value if error: 231 * -1 : "FAT not initialised 232 * -2 : "Directory not found" 233 * -3 : "Name in path too long 234 * -4 : "Not a directory" 235 * -5 : "Cannot access directory" 236 237 === __int '''_fat_read_no_cache'''( char* pathname , unsigned int buffer_vbase , unsigned int buffer_size )__ === 174 238 This functiond load a file identified by the pathname argument into the memory buffer defined by the buffer_vbase / buffer_size arguments. It is intended to be called by the boot-loader, as it uses neither the dynamically allocated FAT structures (Inode-Tree, Fat_Cache or File-Cache), nor the File-Descriptor-Array. It uses only the 4096 bytes buffer defined in the FAT descriptor. 175 239 * '''pathname''' : file complete pathname 176 240 * '''buffer_vbase''' : memory buffer virtual address 177 241 * '''buffer_size''' : buffer size (bytes) 178 It returns 0 if success / It returns -1 if failure. 179 180 === int '''_fat_ioc_access'''( unsigned int use_irq , unsigned int to_mem , unsigned int lba , unsigned int buf_vaddr , unsigned int count ) === 242 It returns 0 if success. It returns a negative value if error. 243 * -1 : "FAT not initialised" 244 * -2 : "File not found" 245 * -3 : "Buffer too small" 246 * -4 : "Cannot access block device" 247 * -5 : "Cannot access FAT on block device" 248 249 == 5) Internal functions == 250 251 The following functions can be used to implement new system calls if required. 252 253 === __int '''_fat_ioc_access'''( unsigned int use_irq , unsigned int to_mem , unsigned int lba , unsigned int buf_vaddr , unsigned int count )__ === 181 254 This function transfer one or several blocks between the block device and a memory buffer by calling the relevant driver. 182 255 * '''use_irq''' : boolean (use descheduling mode if supported by the IOC driver)