Changes between Version 42 and Version 43 of file_system


Ignore:
Timestamp:
Feb 2, 2016, 11:08:32 PM (9 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • file_system

    v42 v43  
    5151|| larger than 1 Gbytes                 ||  4       ||
    5252
    53 For the '''File-Caches''', the GIET_VM implements a '''Write-Back''' policy. In case of write, the data are always modified in the cache. In case of miss, new clusters are allocated to the target file, the cache is updated from the block device if required, and the data are modified in the cache, but not on the block device. The modified clusters are written on the block device only when the last reference is closed, using the dirty flag implemented in each cluster descriptor.
     53For the '''File-Caches''', the GIET_VM implements a '''Write-Back''' policy. In case of write, the data are always modified in the cache. In case of miss, new clusters are allocated to the target file, the cache is updated from the block device if required, and the data are modified in the cache, but not on the block device. The modified clusters are written on the block device only when the last reference is closed, using the dirty flag implemented in each buffer descriptor.
    5454
    5555For the '''Fat_Cache''', the GIET_VM implements a '''Write-Through''' policy. When the FAT content is modified
     
    5959== 4) Extern Functions ==
    6060
    61 The following functions implement the FAT related system calls.
     61=== __int '''_fat_ioc_access'''( unsigned int use_irq ,  unsigned int to_mem ,  unsigned int lba , unsigned int buf_vaddr , unsigned int count )__ ===
     62This function transfers one or several blocks between the block device and a memory buffer by calling the relevant driver. The <use_irq>  boolean argument forces the descheduling mode if supported by the IOC driver.
     63The <to_mem> boolean argument defines the transfer direction (from block device to memory if non zero). The
     64<lba> argument is the first block address on the block device. The <buf_vaddr> argument is the memory buffer virtual address. The <count> argument is the number of blocks to be transferred.
     65
     66It returns 0 on success, or a negative value on failure.
    6267
    6368=== __int '''_fat_init'''( unsigned int kernel_mode )__ ===
    6469This function initializes the  FAT structures. It is called twice, by the boot-loader, and by the kernel_init.
    65  *  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.
     70The <kernel_mode> argument defines the initialization mode:
     71 *  in '''boot mode''' (kernel_mode == 0), it initializes only the statically defined Fat-Descriptor, using informations found in the BOOT sector, that is 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.
    6672 *  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.
    6773
    68 Returns GIET_FAT32_OK on success. Returns a negative value on error:
    69  * GIET_FAT32_IO_ERROR,
    70  * GIET_FAT32_INVALID_BOOT_SECTOR
     74Returns GIET_FAT32_OK on success. Returns a negative value on error.
    7175
    7276=== __int '''_fat_open'''( char* pathname , unsigned int flags )__ ===
    73 This function implements the giet_fat_open() system call.
    74 The semantic is similar to the UNIX open() function,  but only the O_CREATE, O_RDONLY and O_TRUNCATE flags are supported. The UNIX access rights are not supported.
    75 If the file does not exist in the specified directory, it is created, and the Inode-Tree,
    76 the Fat-Cache and the FAT region on device are updated.
    77 If the specified directory does not exist, an error is returned.
    78 It allocates a file descriptor to the calling task, for the file identified
    79 by "pathname". If several tasks try to open the same file, each task 
    80 obtains a private file descriptor and the reference count is updated.
    81 A node name (file or directory) cannot be larger than 31 characters.
    82  * '''pathname''' : defines both the specified directory and the file name.
    83  * '''flags''' :  O_CREATE, O_RDONLY, O_TRUNCATE (can be OR'ed).
    84 Returns a file descriptor index on success. Returns a negative value on error:
    85  * GIET_FAT32_NOT_INITIALIZED,
    86  * GIET_FAT32_FILE_NOT_FOUND,
    87  * GIET_FAT32_NAME_TOO_LONG,
    88  * GIET_FAT32_IO_ERROR,
    89  * GIET_FAT32_TOO_MANY_OPEN_FILES
     77This function implements the ''giet_fat_open()'' system call. It allocates a file descriptor to the calling task, for the file identified by the <pathname> argument.
     78The semantic is similar to the UNIX ''open()'' function,  but only the O_CREAT, O_RDONLY and O_TRUNCATE <flags> are supported. The UNIX access rights are not supported.
     79If the file does not exist in the specified directory, it is created, and the Inode-Tree, the Fat-Cache and the FAT region on device are updated. If the specified directory does not exist, an error is returned.
     80If several tasks try to open the same file, each task  obtains a private file descriptor and the reference count is updated.
     81WARNING : A node name (file or directory) cannot be larger than 31 characters.
     82
     83Returns a file descriptor index on success. Returns a negative value on error.
    9084
    9185=== __int '''_fat_close'''( unsigned int fd_id  )__ ===
    92 This function implements the "giet_fat_close()" system call.
    93 The semantic is similar to the UNIX "close()" function.
    94 It decrements the inode reference count, and releases the fd_id entry in the file descriptors array.
     86This function implements the ''giet_fat_close()'' system call.
     87The semantic is similar to the UNIX ''close()'' function.
     88It decrements the inode reference count for the file identified by the <fd_id> argument.
    9589If the reference count is zero, it writes all dirty clusters on block device, and releases the memory allocated to the file_cache:
    9690The cache 64-Tree infrastructure (depending on file size) is kept, but all buffers and all buffer descriptors are released.
    97  * '''fd_id''' : file descriptor index
    98 Returns GIET_FAT32_OK on success. Returns a negative value on error:
    99  * GIET_FAT32_NOT_INITIALIZED,
    100  * GIET_FAT32_INVALID_FD,
    101  * GIET_FAT32_NOT_OPEN,
    102  * GIET_FAT32_IO_ERROR
     91
     92Returns GIET_FAT32_OK on success. Returns a negative value on error.
    10393
    10494=== __int '''_fat_file_info'''( unsigned int fd_id , fat_file_info_t* info )__ ===
    105 This function implements the giet_fat_file_info() system call.
    106 It returns the size, offset value and is_dir info for a file identified by the "fd_id" argument.
    107  * '''fd_id''' : file descriptor index
    108  * '''info''' : pointer to the fat_file_info_s struct storing the values (return buffer)
    109 Returns GIET_FAT32_OK on success. Returns a negative value on error:
    110  * GIET_FAT32_NOT_INITIALIZED,
    111  * GIET_FAT32_INVALID_FD,
    112  * GIET_FAT32_NOT_OPEN
    113 
    114 === __int '''_fat_read'''( unsigned int fd_id , paddr_t buffer , unsigned int count, unsigned int phys )__ ===
    115 This function implements the "giet_fat_read()" system call.
    116 It accesses 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.
     95This function implements the ''giet_fat_file_info()'' system call.
     96It returns in the <info> argument, the size, offset, and is_dir attributes for a file identified by the <fd_id> argument.
     97
     98Returns GIET_FAT32_OK on success. Returns a negative value on error.
     99
     100=== __int '''_fat_read'''( unsigned int fd_id , unsigned int vaddr , unsigned int count, unsigned int extend, unsigned int offset , unsigned int modes )__ ===
     101This function implements the ''giet_fat_read()'' system call.
     102It accesses the File_Cache associated to the file identified by the <fd_id> argument, and transfers <count> bytes from the cache to the buffer defined by the <vaddr> argument, starting from the current file offset.
     103The <modes> argument define the special access modes:
     104If FAT_PADDR_MODE is set, the <extend> argument defines the physical address extension.
     105If FAT_FORCED_OFFSET is set, the <offset> argument define the actual file offset.
    117106In case of miss in the File_Cache, it loads all involved clusters into the cache.
    118  * '''fd_id''' : file descriptor index
    119  * '''buffer''' : pointer to the memory buffer
    120  * '''count''' : number of bytes
    121  * '''phys''' : use _physical_memcpy instead of memcpy
    122 Returns the number of bytes actually transferred. Returns a negative value on error:
    123  * GIET_FAT32_NOT_INITIALIZED,
    124  * GIET_FAT32_INVALID_FD,
    125  * GIET_FAT32_NOT_OPEN,
    126  * GIET_FAT32_IO_ERROR
    127 
    128 === __int '''_fat_write'''( unsigned int fd_id , void* buffer , unsigned int count )__ ===
    129 This function implements the "giet_fat_write()" system call.
    130 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.
    131  * '''fd_id''' : file descriptor index
    132  * '''buffer''' : pointer on the memory buffer
    133  * '''count''' : number of bytes
    134 Returns number of bytes actually written on success. Returns a negative value on error:
    135  * GIET_FAT32_NOT_INITIALIZED,
    136  * GIET_FAT32_INVALID_FD,
    137  * GIET_FAT32_NOT_OPEN,
    138  * GIET_FAT32_READ_ONLY,
    139  * GIET_FAT32_NO_FREE_SPACE,
    140  * GIET_FAT32_IO_ERROR
     107
     108Returns the number of bytes actually transferred. Returns a negative value on error.
     109
     110=== __int '''_fat_write'''( unsigned int fd_id , unsigned int vaddr , unsigned int count , unsigned int extend , unsigned int modes )__ ===
     111This function implements the ''giet_fat_write()'' system call.
     112It accesses the File_Cache associated to the file identified by the <fd_id> argument, and transfers <count> bytes from the  buffer defined by the <vaddr> argument to the cache, starting from the current file offset.
     113The <modes> argument define the special access modes:
     114If FAT_PADDR_MODE is set, the <extend> argument defines the physical address extension.
     115It loads all involved clusters into cache if required. If (offset + count) is larger than the current file size, the file size is increased. It allocates new clusters if required, and updates the Fat-Cache. The FAT region and the FS-INFO sector are updated 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.
     116
     117Returns number of bytes actually written on success. Returns a negative value on error.
    141118
    142119=== __int '''_fat_lseek'''( unsigned int fd_id , unsigned int offset , unsigned int whence )__ ===
    143 This function implements the "giet_fat_lseek()" system call.
    144 It repositions the offset in the file defined by the file descriptor, according to the offset and whence arguments.
    145 The accepted values for the whence argument are SEEK_SET / SEEK_CUR / SEEK_END :
     120This function implements the ''giet_fat_lseek()'' system call.
     121It repositions the offset in the file descriptor defined by the <fd_id> argument, according to the <offset> and <whence> arguments.
     122The accepted values for the <whence> argument are SEEK_SET / SEEK_CUR / SEEK_END :
    146123 * SEEK_SET =>  new_offset = offset
    147124 * SEEK_CUR =>  new_offset = current_offset + offset
    148125 * SEEK_END => new_offset = file_size + offset
    149 Arguments:
    150  * '''fd_id''' : file descriptor index
    151  * '''offset''' : offset value (can be negative)
    152  * '''whence''' : SEEK_SET / SEEK_CUR / SEEK_END
    153 Returns new seek value (in bytes) on success. Returns a negative value on error:
    154  * GIET_FAT32_NOT_INITIALIZED,
    155  * GIET_FAT32_INVALID_FD,
    156  * GIET_FAT32_NOT_OPEN,
    157  * GIET_FAT32_INVALID_ARG
     126
     127Returns new seek value (in bytes) on success. Returns a negative value on error
    158128
    159129=== __int '''_fat_mkdir'''( char* pathname )__ ===
    160 This function implements the giet_fat_mkdir() system call, that has the same semantic as the UNIX ''mkdir()'' function.
    161 It creates a new directory in the File System as specified by the pathname argument.
    162 The FAT region is updated.
     130This function implements the ''giet_fat_mkdir()'' system call, that has the same semantic as the UNIX ''mkdir()'' function.
     131It creates a new directory in the File System as specified by the <pathname> argument.
     132The FAT region and the FS_INFO sector on block device are updated.
    163133The Inode-Tree is updated.
    164  * '''pathname''' : complete pathname
    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
     134
     135Returns GIET_FAT32_OK on success. Returns a negative value on error.
    172136
    173137=== __int '''_fat_remove'''( char* pathname , unsigned int should_be_dir )__ ===
    174 This function implements the giet_fat_unlink() system call, that has the same semantic as the UNIX ''unlink()'' function.
    175 It removes the file identified by the pathname argument from the File System. An error is returned if the number of references
    176 (number of open file descriptors) is not zero.
    177 All clusters allocated to this file in the DATA region are released.
    178 The FAT region is updated on the block device and the Fat-Cache is updated.
     138This function implements the ''giet_fat_unlink()'' system call, that has the same semantic as the UNIX ''unlink()'' function.
     139It removes the file or directory identified by the <pathname> argument from the File System. An error is returned if the number of references (number of open file descriptors, or number of entries for a directory) is not zero.
     140All clusters allocated to this file in the DATA region are released and the Fat-Cache is updated..
     141The FAT region and the FS-INFO sector are updated on the block device.
    179142The memory allocated to the File_Cache is released.
    180143The Inode-Tree is updated.
    181  * '''pathname''' : directory complete pathname
    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
     144
     145Returns GIET_FAT32_OK on success. Returns a negative value on error.
    191146
    192147=== __int '''_fat_rename'''( char* old_path , new_path )__ ===
    193 This function implements the giet_fat_rename() system call.
    194 It moves an existing file or directory from one node (defined by "old_path"
    195 argument) to another node (defined by "new_path" argument) in the FS tree.
     148This function implements the ''giet_fat_rename()'' system call.
     149It moves an existing file or directory in the FS tree, from one node, defined by the <old_path> argument to another node, defined by the <new_path> argument.
    196150The type (file/directory) and content are not modified.
    197151If the new_path file/dir exist, it is removed from the file system, but only 
    198152if the remove condition is respected (directory empty / file not referenced).
    199153The removed entry is only removed after the new entry is actually created.
    200  * '''old_path''' : old path-name (from root).
    201  * '''new_path''' : new path-name (from root).
    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
     154
     155Returns GIET_FAT32_OK on success. Returns a negative value on error.
    209156
    210157=== __int '''_fat_opendir'''( char* pathname )__ ===
    211 This function implements the giet_fat_opendir() system call.
    212 The semantic is similar to the UNIX opendir() function. If the specified directory does not exist, an error is returned. It allocates a file descriptor to the calling task, for the directory identified by "pathname". If several tasks try to open the same directory, each task obtains a private file descriptor. A node name cannot be larger than 31 characters.
    213  * '''pathname''' : directory complete pathname
    214 Returns a file descriptor for the directory index on success.
    215 Returns a negative value on error:
    216  * GIET_FAT32_NOT_INITIALIZED,
    217  * GIET_FAT32_NAME_TOO_LONG,
    218  * GIET_FAT32_FILE_NOT_FOUND,
    219  * GIET_FAT32_TOO_MANY_OPEN_FILES,
    220  * GIET_FAT32_NOT_A_DIRECTORY
     158This function implements the ''giet_fat_opendir()'' system call.
     159The semantic is similar to the UNIX ''opendir()'' function. If the directory specified by the <pathname> argument does not exist, an error is returned. It allocates a file descriptor to the calling task. If several tasks try to open the same directory, each task obtains a private file descriptor. A node name cannot be larger than 31 characters.
     160
     161Returns a file descriptor for the directory index on success. Returns a negative value on error.
    221162
    222163=== __int '''_fat_closedir'''( unsigned int fd_id )__ ===
    223 This function implements the "giet_fat_closedir()" system call.
     164This function implements the ''giet_fat_closedir()'' system call.
    224165Same behavior as _fat_close(), no check for directory.
    225  * '''fd_id''' : file descriptor index
    226 Returns GIET_FAT32_OK on success. Returns a negative value on error:
    227  * GIET_FAT32_NOT_INITIALIZED,
    228  * GIET_FAT32_INVALID_FD,
    229  * GIET_FAT32_NOT_OPEN,
    230  * GIET_FAT32_IO_ERROR
     166
     167Returns GIET_FAT32_OK on success. Returns a negative value on error.
    231168
    232169=== __int '''_fat_readdir'''( unsigned int fd_id, fat_dirent_t* entry )__ ===
    233 This function implements the "giet_fat_readdir()" system call.
    234 It reads one directory entry from the file descriptor opened by "giet_fat_opendir()" and writes its info to the "entry" argument. This includes the cluster, size, is_dir and name info for each entry.
    235  * '''fd_id''' : file descriptor index
    236  * '''entry''' : pointer to write
    237 Returns GIET_FAT32_OK on success. Returns a negative value on error:
    238  * GIET_FAT32_NOT_INITIALIZED,
    239  * GIET_FAT32_INVALID_FD,
    240  * GIET_FAT32_NOT_OPEN,
    241  * GIET_FAT32_NOT_A_DIRECTORY,
    242  * GIET_FAT32_IO_ERROR,
    243  * GIET_FAT32_NO_MORE_ENTRIES
    244 
    245 === __int '''_fat_read_no_cache'''( char* pathname , unsigned int buffer_vbase , unsigned int buffer_size )__ ===
    246 This function loads 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.
    247  * '''pathname''' : file complete pathname
    248  * '''buffer_vbase''' : memory buffer virtual address
    249  * '''buffer_size''' : buffer size (bytes)
    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
     170This function implements the ''giet_fat_readdir()'' system call.
     171It reads one directory entry from the directory identified by the <fd_id> argument provided by ''giet_fat_opendir()''. It returns the following attributes in the <entry> argument : cluster , size , is_dir , and name.
     172
     173Returns GIET_FAT32_OK on success. Returns a negative value on error.
     174
     175=== __int '''_fat_load_no_cache'''( char* pathname , unsigned int buffer_vbase , unsigned int buffer_size )__ ===
     176This function load a file identified by the <pathname> argument into the memory buffer defined by the <buffer_vbase> and <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 512 bytes buffer defined in the FAT descriptor.
     177
     178Returns GIET_FAT32_OK on success. Returns negative value on error.
    255179
    256180=== __int '''_get_file_cache_buffer'''( fat_node_t* indoor , unsigned int cluster_id , unsigned int writable , fat_cache_desc_t** desc )__ ===
     
    262186This function is called by the _sys_fat_mmap() function, and by other FAT functions.
    263187It does not take the FAT lock, that must be taken by the caller.
    264 It returns GIET_FAT32_OK on success, and returns a negative value on error:
    265  * GIET_FAT32_NOT_INITIALIZED
    266  * GIET_FAT32_INVALID_ARG
    267  * GIET_FAT32_IO_ERROR
     188
     189It returns GIET_FAT32_OK on success, and returns a negative value on error.
     190
     191=== __int '''_get_fat_cache_buffer'''( unsigned int cluster_id , fat_cache_desc** desc )__ ===
     192This function returns in the <desc> argument a pointer on a buffer descriptor contained in the Fat_Cache.
     193The <cluster_id> argument is the buffer index in the FAT_Cache.
     194In case of miss, a 4 Kbytes buffer and a buffer descriptor are allocated from the local heap, and the missing cluster is loaded in the Fat_Cache.
     195
     196It returns GIET_FAT32_OK on success, and returns a negative value on error.
    268197
    269198== 5) Internal functions ==