Changes between Version 80 and Version 81 of library_stdio


Ignore:
Timestamp:
Jun 11, 2015, 7:52:02 PM (9 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • library_stdio

    v80 v81  
    165165 ==  __File system related system calls__ ==
    166166
    167 The Giet-VM supports a FAT32 file system.
    168 
    169  === 1) int '''giet_fat_open'''( const char* pathname, unsigned int flags ) ===
    170 This function open a file identified by the ''pathname'' argument. The read/write ''flags''  are not supported yet: no effect. Return -1 in case or error.
    171 
    172  === 2) void '''giet_fat_read'''( unsigned int fd, void* buffer, unsigned int count, unsigned int offset ) ===
    173 Read ''count'' sectors from a file identified by the ''fd'' argument, skipping ''offset'' sectors in file, and writing into the user memory ''buffer''. The user buffer base address should be 64 bytes aligned.
    174 In case or error, it makes a giet_exit().
    175 
    176  === 3) void '''giet_fat_write'''( unsigned int fd, void* buffer, unsigned int count, unsigned int offset ) ===
    177 Write ''count'' sectors into a file identified by the ''fd'' argument, skipping ''offset'' sectors in file, and reading from the user memory ''buffer''. The user buffer base address should be 64 bytes aligned.
    178 In case or error, it makes a giet_exit().
    179 
    180  === 4) void '''giet_fat_close'''( unsigned int fd ) ===
    181 Close a file identified by the ''fd'' file descriptor.
    182 
     167The Giet-VM supports a FAT32 file system, and uses distributed data structures to access the file system:
     168 * The Inode-Tree (distributed on all clusters) is the internal representation of the File System tree.
     169 * The Fat-Cache (distributed on all clusters) is used to cache the FAT region of the block device.
     170 * The Fat-Cache (distributed on all clusters / one cache per open file) is used to cache the DATA region of the block device.
     171 * The File-Descriptor-Array (in cluster[0,0]) contains the open files descriptors.
     172 * The Fat-Descriptor (in cluster[0,0] contains the FAT32 general information.
     173
     174=== 1) int '''giet_fat_open'''( char* pathname ) ===
     175This function allocates a file descriptor to the calling task, for the file identified by its absolute "pathname".
     176If several tasks try to open the same file, each task obtains a private file descriptor.
     177The semantic is similar to the UNIX open() function, but the UNIX oflags and the UNIX access rights are not supported.
     178If the file does not exist in the specified directory, it is created.
     179If the specified directory does not exist, an error is returned.
     180
     181WARNING: A node name (file or directory) cannot be larger than 30 characters.
     182
     183Returns the file descriptor index if success
     184Returns  -1 if error.
     185
     186=== 2)  '''void giet_fat_close'''( unsigned int fd_id ) ===
     187Close a file identified by the ''fd_id'' file descriptor.
     188It decrements the reference count in the inode associated to the file, and release the fd_id entry in the file descriptors array.
     189If the reference count is zero, it writes all dirty clusters on block device, and releases the memory allocated to the file_cache.
     190
     191=== 3) '''void get_fat_file_info'''( unsigned int fd_id , unsigned int* size , unsigned int* offset ) ===
     192This function returns the "size" and the current "offset" value for a file identified  by the "fd_id" argument.
     193
     194=== 4) int '''giet_fat_read'''( unsigned int fd_id , void* buffer , unsigned int count ) ===
     195This function has the same semantic as the UNIX "read()" function. It transfers "count" bytes from the kernel File_Cache associated to the file identified by "fd_id", to the user "buffer", starting from the current file offset. The offset value is incremented by count.
     196In case of miss in the File_Cache, it loads all involved clusters into cache.
     197
     198Returns number of bytes actually transferred if success.
     199Returns 0 if (offset + count) is larger than the file size.
     200Returns -1 if error.
     201
     202 === 5) int '''giet_fat_write'''( unsigned int fd_id , void* buffer, unsigned int count ) ===
     203This function has the same semantic as the UNIX "write()" function. It transfers "count" bytes from the user "buffer" to the kernel File_Cache associated to the file identified by "fd_id", starting from the current file offset. The offset value is incremented by count. It increases the file size and allocate new clusters if (count + offset) is larger than the current file size. Then it loads and updates all involved clusters in the cache.
     204The FAT region on block device is updated if new clusters are allocated, but the block device DATA region is NOT updated.
     205
     206Returns number of bytes actually transferred if success.
     207Returns -1 if error.
     208
     209=== int '''giet_fat_lseek'''( unsigned int fd_id , unsigned int offset , unsigned int whence ) ===
     210This function has the same semantic as the UNIX lseek() function.
     211It repositions the offset in the file descriptor "fd_id", according to the "offset" and "whence" arguments.
     212The two accepted values for the whence argument are SEEK_SET (new_offset <= offset), and SEEK_CUR (new_offset <= current_offset + offset).
     213
     214Returns new offset value (bytes) if success.
     215Returns -1 if error.
     216
     217=== int '''giet_fat_rm'''( char* pathname ) ===
     218This function has the same semantic as the UNIX unlink() function.
     219It deletes a file identified by the absolute "pathname" argument from the sile system.
     220AN error is reported if the references count (number of open file descriptor) is not zero.
     221All clusters allocated to this file in the block device DATA region are released.
     222The Inode-Tree is updated.
     223the Fat-Cache is updated, and the FAT region is updated on the block device.
     224The memory allocated for the associated File_Cache is released.
     225
     226Returns 0 if success.
     227Returns -1 if error.
     228
     229=== int '''get_fat_mkdir( char* pathname ) ===
     230This function has the same semantic as the UNIX mkdir() function.
     231It creates in the file system the directory specified by the absolute "pathname" argument. 
     232The Inode-Tree is updated.
     233One cluster is allocated to the new directory, containing the "." and ".." entries.
     234The associated File-Cache is created.
     235The Fat-Cache is updated, and the FAT region on block device is updated.
     236The DATA region on block device is updated.
     237
     238Returns 0 if success.
     239Returns -1 if error.
     240
     241=== void '''get_fat_rmdir'''( char* pathname ) ===
     242This function has the same semantic as the UNIX mkdir() function.
     243It deletes the directory specified by the absolute "pathname" argument from the file system.
     244The Fat-Cache is updated, and the FAT region on block device is updated.
     245The Inode-Tree is updated.
     246The memory allocated to the File-Cache is released.
     247
     248Returns 0 if success.
     249Returns -1 if error.
    183250
    184251 == __Network related system call__ ==