Changes between Version 18 and Version 19 of file_system


Ignore:
Timestamp:
Jul 8, 2015, 7:00:52 PM (9 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • file_system

    v18 v19  
    5959for each modified cluster.
    6060
    61 == 4) Access Functions ==
    62 
    63 === int '''_fat_init'''( unsigned int kernel_mode ) ===
     61== 4) Extern Functions ==
     62
     63The following functions implement the FAT related system calls.
     64
     65=== __int '''_fat_init'''( unsigned int kernel_mode )__ ===
    6466This function initializes the  FAT structures. It is called twice, by the boot-loader, and by the kernel_init.
    6567 *  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,
     
    6971It returns 0 if success /  It returns -1 if failure.
    7072
    71 === int '''_fat_open'''( char* pathname , unsigned int flags ) ===
     73=== __int '''_fat_open'''( char* pathname , unsigned int flags )__ ===
    7274This function implements the giet_fat_open() system call.
    7375The semantic is similar to the UNIX open() function,  but only the O_CREATE
     
    9496 *   -9  :  "file descriptor array full"
    9597
    96 === int '''_fat_close'''( unsigned int fd_id  ) ===
     98=== __int '''_fat_close'''( unsigned int fd_id  )__ ===
    9799This function implements the "giet_fat_close()" system call.
    98100The semantic is similar to the UNIX "close()" function.
     
    107109 *  -4  : "Cannot release memory"
    108110
    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 )__ ===
    110112This function implements the giet_fat_file_info() system call.
    111113It returns the size and the current offset value for a file identified  by the "fd_id" argument.
     
    118120 *  -3  : "File not open"
    119121
    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 )__ ===
    121123This function implements the "giet_fat_read()" system call.
    122124It 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.
     
    129131 *  -2  : "Illegal file descriptor"
    130132 *  -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 )__ ===
     136This function implements the "giet_fat_write()" system call.
    135137It access the File-Cache associated to the file identified by the file descriptor, and transfers count bytes from the user buffer,
    136138to 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.
     
    138140 * '''buffer''' : pointer on the memory buffer
    139141 * '''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.
     142It 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 )__ ===
     152This function implements the "giet_fat_lseek()" system call.
    144153It repositions the offset in the file defined by the file descriptor, according to the offset and whence arguments.
    145154The accepted values for the whence argument are SEEK_SET and SEEK_CUR:
     
    150159 * '''offset''' : pointer on the memory buffer
    151160 * '''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 ) ===
     161It 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 )__ ===
    155168This function implements the giet_fat_mkdir() system call, that has the same semantic as the UNIX ''mkdir()'' function.
    156169It creates a new directory in the File System as specified by the pathname argument.
     
    158171The Inode-Tree is updated.
    159172 * '''pathname''' : complete pathname
    160 It returns 0 if success /  It returns -1 if failure.
    161 
    162 === int '''_fat_unlink'''( char* pathname ) ===
     173It 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 )__ ===
    163186This function implements the giet_fat_unlink() system call, that has the same semantic as the UNIX ''unlink()'' function.
    164187It removes the file identified by the pathname argument from the File System. An error is returned if the number of references
     
    169192The Inode-Tree is updated.
    170193 * '''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 ) ===
     194It 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 )__ ===
     205This function implements the giet_fat_rename() system call.
     206It moves an existing file or directory from one node (defined by "old_path"
     207argument) to another node (defined by "new_path" argument) in the FS tree.
     208The type (file/directory) and content are not modified.
     209If the new_path file/dir exist, it is removed from the file system, but only 
     210if the remove condition is respected (directory empty / file not referenced).
     211The 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).
     214It 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 )__ ===
     228This function implements the giet_fat_list() system call.
     229It displays the content of a directory identified by the pathname argument.
     230It 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 )__ ===
    174238This 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.
    175239 * '''pathname''' : file complete pathname
    176240 * '''buffer_vbase''' : memory buffer virtual address
    177241 * '''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 ) ===
     242It 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
     251The 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 )__ ===
    181254This function transfer one or several blocks between the block device and a memory buffer by calling the relevant driver.
    182255 * '''use_irq''' : boolean (use descheduling mode if supported by the IOC driver)