Description
This page describes the FileSystem interface which provides access to file systems.
Each file system is responsible for access synchronization, check user permissions, etc.
Every device to be mounted must implement BlockDev interface.
0x00 - Close
Syntax
void FileSystem_Close(FileSystem_Handle *fd);
Properties
Description
This function closes fd.
fd is a pointer to a structure created with Open.
Return value
Nothing.
0x0e - Lookup
Syntax
int FileSystem_Lookup(FSManager_Dentry *parent, FSManager_Dentry *newDentry);
Properties
Description
This function searchs directory parent for entry newDentry.
Who calls this function must make sure that only one thread calls this function with the same parent.
Field name of newDentry has the name to be found.
If newDentry is found fields mode and fsData of newDentry must be filled.
Field mode has the same format of field mode of EntryStatus. Field fsdata are file system specific data.
Return value
- E_OK - Success
- E_BAD_VALUE - Invalid argument
- E_NOT_FOUND - newDentry does not exist
- E_NO_MEMORY - Not enough memory available
- E_IO_ERROR - I/O error
- E_CORRUPTED_FS - Corrupted file system
- E_FILE_ERROR - Undefined error
0x02 - Mount
Syntax
int FileSystem_Mount(const char *devImp, unsigned int unit, int prop, const char *data, FSManager_Dentry *dentry);
Properties
Description
This function mounts unit from device devImp with properties prop.
data is specific to each file system.
This function can only be called one time for each pair devImp, unit.
Who calls this function must make sure that only one thread is executing this function simultaneously.
In case of success, field fsData of dentry must be filled. fsdata are file system specific data.
prop must be 0 or the sum of:
- 0x01 - FSManager_MOUNT_RO - Mount read only
Return value
- E_OK - Success
- E_BAD_VALUE - Invalid argument
- E_MODULE - Error getting devImp module's functions
- E_CORRUPTED_FS - Corrupted file system
- E_READ_ONLY_FS - Read only file system
- E_BAD_TYPE - Invalid file system in devImp
- E_NO_MEMORY - Not enough memory available
- E_IN_USE - Unit in use
- E_IO_ERROR - I/O error
- E_FILE_ERROR - Undefined error
0x03 - Open
Syntax
int FileSystem_Open(FSManager_Dentry *dentry, int prop, FileSystem_Handle **fd);
Properties
Description
This function opens dentry with properties prop.
fd is where a file descriptor structure pointer will be stored.
prop must be the sum of:
- 0x01 - FSManager_READ - Open for read
- 0x02 - FSManager_WRITE - Open for write
- 0x04 - FSManager_CREATE - Create file if it doesn't exist
- 0x08 - FSManager_EXCLUSIVE - Used with FSManager_CREATE to return an error if file exists
- 0x10 - FSManager_TRUNCATE - If file already exists it will be truncated
- 0x20 - FSManager_APPEND - Open in append mode
FSManager_READ or FSManager_WRITE must be set, others can be added. (FSManager_WRITE + FSManager_CREATE, for instance).
In case prop has FSManager_CREATE, prop can have the follow values too (in octal):
- 070000000 - FSManager_O_USER_RWX - file owner has read, write and execute permission
- 040000000 - FSManager_O_USER_READ - file owner has read permission
- 020000000 - FSManager_O_USER_WRITE - file owner has write permission
- 010000000 - FSManager_O_USER_EXEC - file owner has execute permission
- 007000000 - FSManager_O_GROUP_RWX - group has read, write and execute permission
- 004000000 - FSManager_O_GROUP_READ - group has read permission
- 002000000 - FSManager_O_GROUP_WRITE - group has write permission
- 001000000 - FSManager_O_GROUP_EXEC - group has execute permission
- 000700000 - FSManager_O_OTHERS_RWX - others have read, write and execute permission
- 000400000 - FSManager_O_OTHERS_READ - others have read permission
- 000200000 - FSManager_O_OTHERS_WRITE - others have write permission
- 000100000 - FSManager_O_OTHERS_EXEC - others have execute permission
These values are only used if the file system support them.
The file offset is set to the beginning of the file.
Return value
- E_OK - Success
- E_BAD_VALUE - Invalid argument
- E_TOO_MANY_OPEN_FILES - Too many open files
- E_READ_ONLY_FS - Read only file system
- E_NO_MEMORY - Not enough memory available
- E_FS_FULL - File system is full
- E_IO_ERROR - I/O error
- E_FILE_ERROR - Undefined error
0x05 - Read
Syntax
int FileSystem_Read(FSManager_FDIO *request);
Properties
Description
This function processes read request.
In case of success, field size of request will contain how many bytes were read and file position is advanced by this number.
Return value
- E_OK - Success
- E_BAD_VALUE - Invalid argument
- E_END_REACHED - End of file reached
- E_FAULT - buf points outside task's accessible address space
- E_IO_ERROR - I/O error
- E_CORRUPTED_FS - Corrupted file system
- E_FILE_ERROR - Undefined error
0x0f - ReadLink
Syntax
int FileSystem_ReadLink(FSManager_Dentry *dentry, char *buf, unsigned int size, int prop);
Properties
Description
This function reads symbolic link dentry contents and put it in buf that has size bytes.
prop can be:
- 0x01 - FSManager_USER_BUF_IO - buf is a buffer in user memory space
Return value
- E_OK - Success
- E_BAD_VALUE - Invalid argument
- E_TOO_BIG - buf is too small
- E_FAULT - buf points outside task's accessible address space
- E_IO_ERROR - I/O error
- E_FILE_ERROR - Undefined error
0x07 - Remove
Syntax
int FileSystem_Remove(FSManager_Dentry *dentry);
Properties
Description
This function removes dentry.
dentry can be been used. Who is using it can continue to use, but won't be possible to open, list, etc.
A directory with files can't be removed.
Return value
- E_OK - Success
- E_BAD_VALUE - Invalid argument
- E_READ_ONLY_FS - Read only file system
- E_NO_MEMORY - Not enough memory available
- E_IO_ERROR - I/O error
- E_NOT_EMPTY - Directory is not empty
- E_FILE_ERROR - Undefined error
0x09 - RewindDir
Syntax
int FileSystem_RewindDir(FileSystem_Handle *fd);
Properties
Description
This function repositions fd read offset to the beginning.
Return value
- E_OK - Success
- E_BAD_VALUE - Invalid argument
- E_NOT_A_DIRECTORY - fd is not a directory
0x0a - Seek
Syntax
int FileSystem_Seek(FileSystem_Handle *fd, int count, int prop, int *newPos);
Properties
Description
This functions repositions fd read/write offset to count bytes according to prop.
prop must be:
- 0x01 - FSManager_SEEK_START - relative to the beginning of file
- 0x02 - FSManager_SEEK_CURRENT - relative to current position
- 0x04 - FSManager_SEEK_END - relative to the end of file
In case of success, newPos, if different than NULL, will contain the new position.
Return value
- E_OK - Success
- E_BAD_VALUE - Invalid argument
- E_TOO_BIG - Final position is bigger than maximum allowed
- E_NOT_ALLOWED - Operation not allowed
- E_IS_A_DIRECTORY - fd is a directory
- E_FILE_ERROR - Undefined error
0x0b - Status
Syntax
int FileSystem_Status(FSManager_Dentry *dentry, FSManager_EntryStatus *buf, int prop);
Properties
Description
This function gets informations about dentry and puts them in buf.
prop can be:
- 0x80 - FSManager_USER_BUF - buf is a buffer in user memory space
Return value
- E_OK - Success
- E_BAD_VALUE - Invalid argument
- E_NO_MEMORY - Not enough memory available
- E_FAULT - buf points outside task's accessible address space
- E_IO_ERROR - I/O error
- E_FILE_ERROR - Undefined error
0x01 - StatusFD
Syntax
int FileSystem_StatusFD(FileSystem_Handle *fd, FSManager_EntryStatus *buf, int prop);
Properties
Description
This function gets informations about fd and puts them in buf.
prop can be:
- 0x80 - FSManager_USER_BUF - buf is a buffer in user memory space
Return value
- E_OK - Success
- E_BAD_VALUE - Invalid argument
- E_NO_MEMORY - Not enough memory available
- E_FAULT - buf points outside task's accessible address space
- E_IO_ERROR - I/O error
- E_FILE_ERROR - Undefined error
0x0c - Unmount
Syntax
int FileSystem_Unmount(FSManager_Dentry *dentry, int prop);
Properties
Description
This function unmounts the file system mounted in dentry.
prop can be 0 or the sum of:
- 0x01 - FSManager_FORCE_UNMOUNT - force file system unmount
Return value
- E_OK - Success
- E_BAD_VALUE - Invalid argument
- E_IN_USE - File system in use
- E_NO_MEMORY - Not enough memory available
- E_IO_ERROR - I/O error
- E_FILE_ERROR - Undefined error
0x0d - Write
Syntax
int FileSystem_Write(FSManager_FDIO *request);
Properties
Description
This function processes write request.
In case of success, field count of request will contain how many bytes were written and file position is advanced by this number.
Return value
- E_OK - Success
- E_BAD_VALUE - Invalid argument
- E_FS_FULL - File system is full
- E_READ_ONLY_FS - Read only file system
- E_FAULT - buf points outside task's accessible address space
- E_IS_A_DIRECTORY - fd is a directory
- E_IO_ERROR - I/O error
- E_FILE_ERROR - Undefined error