sofs19  0.1
FUSE based file system
fileblocks

Functions to manage file blocks. More...

Functions

uint32_t soGetFileBlock (int ih, uint32_t fbn)
 Get the data block number corresponding to the given file block. More...
 
uint32_t soAllocFileBlock (int ih, uint32_t fbn)
 Associate a data block to the given file block position. More...
 
void soFreeFileBlocks (int ih, uint32_t ffbn)
 Free all file blocks from the given position on. More...
 
void soReadFileBlock (int ih, uint32_t fbn, void *buf)
 Read a file block. More...
 
void soWriteFileBlock (int ih, uint32_t fbn, void *buf)
 Write a file block. More...
 

Detailed Description

Functions to manage file blocks.

Remarks
In case an error occurs, every function throws an SOException

Function Documentation

◆ soGetFileBlock()

uint32_t sofs19::soGetFileBlock ( int  ih,
uint32_t  fbn 
)

Get the data block number corresponding to the given file block.

Parameters
ihinode handler
fbnfile block number
Remarks
  • 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
ihinode handler
fbnfile block number
Remarks
  • 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
ihinode handler
ffbnfirst file block number
Remarks
  • 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
ihinode handler
fbnfile block number
bufpointer to the buffer where data must be read into
Remarks
  • 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
ihinode handler
fbnfile block number
bufpointer to the buffer containing data to be written
Remarks
  • 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.