sofs19  0.1
FUSE based file system
mksofs

Supporting formatting functions. More...

Functions

void soComputeStructure (uint32_t ntotal, uint32_t &itotal, uint32_t &nbref)
 computes the structural division of the disk More...
 
void soFillSuperBlock (const char *name, uint32_t ntotal, uint32_t itotal, uint32_t nbref)
 Fill in the fields of the superblock. More...
 
void soFillInodeTable (uint32_t itotal, bool set_date=true)
 Fill in the blocks of the inode table. More...
 
void soFillRootDir (uint32_t itotal)
 Fill in the root directory. More...
 
void soFillReferenceDataBlocks (uint32_t ntotal, uint32_t itotal, uint32_t nbref)
 Fill in the data blocks containing references to free data blocks in a newly-formatted disk. More...
 
void soResetFreeDataBlocks (uint32_t ntotal, uint32_t itotal, uint32_t nbref)
 Fill with zeros the free data blocks of a newly-formatted disk. More...
 

Detailed Description

Supporting formatting functions.

Function Documentation

◆ soComputeStructure()

void sofs19::soComputeStructure ( uint32_t  ntotal,
uint32_t &  itotal,
uint32_t &  nbref 
)

computes the structural division of the disk

Parameters
[in]ntotalTotal number of blocks of the disk
[in,out]itotalTotal number of inodes
[out]nbrefNumber of reference data blocks in a newly-formatted disk
Remarks
  • this function does not change any block of the disk;
  • if it is zero initially, the value ntotal/16 should be used as the start value for itotal, where / stands for the integer division;
  • itotal is always lower than or equal to ntotal/8;
  • itotal is always greater than or equal to IPC;
  • itotal must be rounded up to be multiple of IPB;
  • if, after splitting data blocks between reference data blocks and free data blocks, a single data block remains, it is assigned to the inode table;

◆ soFillSuperBlock()

void sofs19::soFillSuperBlock ( const char *  name,
uint32_t  ntotal,
uint32_t  itotal,
uint32_t  nbref 
)

Fill in the fields of the superblock.

Parameters
[in]namevolume name
[in]ntotalthe total number of blocks in the device
[in]itotalthe total number of inodes
[in]nbrefNumber of reference data blocks in a newly-formatted disk
Remarks
  • the magic number is put at 0xFFFF;
  • The tail cache is left empty;
  • the head cache is left filled (totally, if possible).

◆ soFillInodeTable()

void sofs19::soFillInodeTable ( uint32_t  itotal,
bool  set_date = true 
)

Fill in the blocks of the inode table.

Parameters
[in]itotalthe total number of inodes
[in]set_dateif true current date is set; otherwise date is put at zero
Remarks
  • inode table starts on block number 1;
  • all inodes are free, except inode number 0;
  • inode 0 is filled assuming it is used by the root directory;
  • the data of inode 0 is stored in data block number 0;
  • the first free inode is inode number 1, the second inode number 2, and do forth;
  • the last free inode points to NullReference.

◆ soFillRootDir()

void sofs19::soFillRootDir ( uint32_t  itotal)

Fill in the root directory.

Parameters
[in]itotalthe total number of inodes
Remarks
  • in the newly-formatted disk the root directory occupies a single data block, the one immediately after the inode table;
  • the whole data block is formatted as an array of DPB directory entries;
  • the first two entries are filled in with "." and ".." directory entries;
  • the other slots must be cleaned: field name filled with zeros and field inode filled with NullReference.

◆ soFillReferenceDataBlocks()

void sofs19::soFillReferenceDataBlocks ( uint32_t  ntotal,
uint32_t  itotal,
uint32_t  nbref 
)

Fill in the data blocks containing references to free data blocks in a newly-formatted disk.

Parameters
[in]ntotalthe total number of blocks in the device
[in]itotalthe total number of inodes
[in]nbrefNumber of reference data blocks in a newly-formatted disk
Remarks
  • the list of free data blocks is sorted in ascending order;
  • the first references of the list are in the head cache;
  • non-used cells must be filled with pattern NullReference;
  • this function does nothing, in case all references to free data blocks fit in the head cache.

◆ soResetFreeDataBlocks()

void sofs19::soResetFreeDataBlocks ( uint32_t  ntotal,
uint32_t  itotal,
uint32_t  nbref 
)

Fill with zeros the free data blocks of a newly-formatted disk.

Parameters
[in]ntotalthe total number of blocks in the device
[in]itotalthe total number of inodes
[in]nbrefNumber of reference data blocks in a newly-formatted disk