Functions to manage file blocks.
More...
Functions to manage file blocks.
◆ soGetFileBlock()
uint32_t sofs19::soGetFileBlock |
( |
int |
ih, |
|
|
uint32_t |
fbn |
|
) |
| |
Get the data block number corresponding to the given file block.
- Parameters
-
ih | inode handler |
fbn | file block number |
- Assumes
ih
is a valid handler of an inode in use opened;
- Error
EINVAL
is thrown if fbn
is not valid;
- when calling a function of any layer, the version with prefix
so
is used.
- Returns
- the number of the corresponding block
◆ soAllocFileBlock()
uint32_t sofs19::soAllocFileBlock |
( |
int |
ih, |
|
|
uint32_t |
fbn |
|
) |
| |
Associate a data block to the given file block position.
- Parameters
-
ih | inode handler |
fbn | file block number |
- Assumes
ih
is a valid handler of an inode in use opened;
- Error
EINVAL
is thrown if fbn
is not valid;
- depending on the situation, 1, 2, or 3 data blocks are allocated;
- when calling a function of any layer, the version with prefix
so
is used.
- Returns
- the number of the allocated block
◆ soFreeFileBlocks()
void sofs19::soFreeFileBlocks |
( |
int |
ih, |
|
|
uint32_t |
ffbn |
|
) |
| |
Free all file blocks from the given position on.
- Parameters
-
ih | inode handler |
ffbn | first file block number |
- Assumes
ih
is a valid handler of an inode in use opened;
- data blocks used to store references that become empty are also freed;
- when calling a function of any layer, the version with prefix
so
is used.
◆ soReadFileBlock()
void sofs19::soReadFileBlock |
( |
int |
ih, |
|
|
uint32_t |
fbn, |
|
|
void * |
buf |
|
) |
| |
Read a file block.
Data is read from a specific data block which is supposed to belong to an inode associated to a file (a regular file, a directory or a symbolic link).
- Parameters
-
ih | inode handler |
fbn | file block number |
buf | pointer to the buffer where data must be read into |
- Assumes
ih
is a valid handler of an inode in use opened;
- If the referred file block has not been allocated yet, the returned data will consist of a byte stream filled with the null character (ascii code 0);
- when calling a function of any layer, the version with prefix
so
is used.
◆ soWriteFileBlock()
void sofs19::soWriteFileBlock |
( |
int |
ih, |
|
|
uint32_t |
fbn, |
|
|
void * |
buf |
|
) |
| |
Write a file block.
Data is written into a specific data block which is supposed to belong to an inode associated to a file (a regular file, a directory or a symbolic link).
- Parameters
-
ih | inode handler |
fbn | file block number |
buf | pointer to the buffer containing data to be written |
- Assumes
ih
is a valid handler of an inode in use opened;
- If the referred block has not been allocated yet, it should be allocated now so that the data can be stored as its contents;
- when calling a function of any layer, the version with prefix
so
is used.