FreeNOS
Data Structures | Macros
linncreate

The LinnCreate program can create a new LinnFS filesystem. More...

Data Structures

class  LinnCreate
 Class for creating new Linnenbank FileSystems. More...
 

Macros

#define LINN_CREATE_BLOCK_SIZE   2048
 Default block size. More...
 
#define LINN_CREATE_BLOCK_NUM   8192
 Default number of blocks to allocate. More...
 
#define LINN_CREATE_BLOCKS_PER_GROUP   8192
 Default number of data blocks per group descriptor. More...
 
#define LINN_CREATE_INODE_NUM   1024
 Default number of inodes to allocate. More...
 
#define LINN_CREATE_INODES_PER_GROUP   1024
 Default number of inodes per group descriptor. More...
 
#define BLOCKPTR(type, nr)   (type *)(blocks + (super->blockSize * (nr)))
 Returns a pointer to the correct in-memory block. More...
 
#define BLOCKS(sb, count)
 Retrieve a given number of free contiguous blocks. More...
 
#define BLOCK(sb)   BLOCKS(sb, (ulong)1)
 Retrieve one free block. More...
 
#define FILETYPE_FROM_ST(st)
 Convert from a (host system's) POSIX struct stat into a FileType. More...
 
#define FILEMODE_FROM_ST(st)   (FileSystem::FileMode)((st)->st_mode & 0777)
 Converts an (host system's) POSIX struct st into a FileMode. More...
 

Detailed Description

The LinnCreate program can create a new LinnFS filesystem.

Macro Definition Documentation

◆ BLOCK

#define BLOCK (   sb)    BLOCKS(sb, (ulong)1)

Retrieve one free block.

Parameters
sbLinnSuperBlock pointer.
Returns
Block number of a free block.

Definition at line 91 of file LinnCreate.h.

◆ BLOCKPTR

#define BLOCKPTR (   type,
  nr 
)    (type *)(blocks + (super->blockSize * (nr)))

Returns a pointer to the correct in-memory block.

Parameters
typeData type to return a pointer for.
nrBlock number.
Returns
A pointer of the given type.

Definition at line 62 of file LinnCreate.h.

◆ BLOCKS

#define BLOCKS (   sb,
  count 
)
Value:
({ \
if ((sb)->freeBlocksCount < (count)) \
{ \
printf("%s: not enough free blocks remaining (%lu needed)\n", \
prog, (ulong)(count)); \
exit(EXIT_FAILURE); \
} \
(sb)->freeBlocksCount -= (count); \
((sb)->blocksCount - (sb)->freeBlocksCount - (count)); \
})

Retrieve a given number of free contiguous blocks.

Parameters
sbLinnSuperBlock pointer.
countNumber of blocks
Returns
Block number of the first block in the contiguous array of blocks.

Definition at line 72 of file LinnCreate.h.

◆ FILEMODE_FROM_ST

#define FILEMODE_FROM_ST (   st)    (FileSystem::FileMode)((st)->st_mode & 0777)

Converts an (host system's) POSIX struct st into a FileMode.

Parameters
ststruct st pointer.
Returns
FileMode value.

Definition at line 126 of file LinnCreate.h.

◆ FILETYPE_FROM_ST

#define FILETYPE_FROM_ST (   st)
Value:
({ \
\
switch ((st)->st_mode & S_IFMT) \
{ \
case S_IFIFO: t = FileSystem::FIFOFile; break; \
case S_IFREG: t = FileSystem::RegularFile; break; \
case S_IFDIR: t = FileSystem::DirectoryFile; break; \
case S_IFLNK: t = FileSystem::SymlinkFile; break; \
case S_IFSOCK: t = FileSystem::SocketFile; break; \
default: break; \
} \
t; \
})

Convert from a (host system's) POSIX struct stat into a FileType.

Parameters
ststruct stat pointer.
Returns
FileType value.

Definition at line 101 of file LinnCreate.h.

◆ LINN_CREATE_BLOCK_NUM

#define LINN_CREATE_BLOCK_NUM   8192

Default number of blocks to allocate.

Definition at line 43 of file LinnCreate.h.

◆ LINN_CREATE_BLOCK_SIZE

#define LINN_CREATE_BLOCK_SIZE   2048

Default block size.

Definition at line 40 of file LinnCreate.h.

◆ LINN_CREATE_BLOCKS_PER_GROUP

#define LINN_CREATE_BLOCKS_PER_GROUP   8192

Default number of data blocks per group descriptor.

Definition at line 46 of file LinnCreate.h.

◆ LINN_CREATE_INODE_NUM

#define LINN_CREATE_INODE_NUM   1024

Default number of inodes to allocate.

Definition at line 49 of file LinnCreate.h.

◆ LINN_CREATE_INODES_PER_GROUP

#define LINN_CREATE_INODES_PER_GROUP   1024

Default number of inodes per group descriptor.

Definition at line 52 of file LinnCreate.h.

EXIT_FAILURE
#define EXIT_FAILURE
Unsuccessful termination.
Definition: stdlib.h:36
S_IFDIR
#define S_IFDIR
Directory.
Definition: stat.h:73
S_IFLNK
#define S_IFLNK
Symbolic link.
Definition: stat.h:76
FileSystem::UnknownFile
@ UnknownFile
Definition: FileSystem.h:79
ulong
unsigned long ulong
Unsigned long number.
Definition: Types.h:47
FileSystem::FileType
FileType
All possible filetypes.
Definition: FileSystem.h:70
FileSystem::SymlinkFile
@ SymlinkFile
Definition: FileSystem.h:76
S_IFCHR
#define S_IFCHR
Character special.
Definition: stat.h:64
FileSystem::SocketFile
@ SocketFile
Definition: FileSystem.h:78
S_IFSOCK
#define S_IFSOCK
Socket.
Definition: stat.h:79
FileSystem::RegularFile
@ RegularFile
Definition: FileSystem.h:72
S_IFIFO
#define S_IFIFO
FIFO special.
Definition: stat.h:67
FileSystem::DirectoryFile
@ DirectoryFile
Definition: FileSystem.h:73
FileSystem::CharacterDeviceFile
@ CharacterDeviceFile
Definition: FileSystem.h:75
FileSystem::FIFOFile
@ FIFOFile
Definition: FileSystem.h:77
FileSystem::BlockDeviceFile
@ BlockDeviceFile
Definition: FileSystem.h:74
S_IFBLK
#define S_IFBLK
Block special.
Definition: stat.h:61
S_IFMT
#define S_IFMT
Type of file.
Definition: stat.h:58
S_IFREG
#define S_IFREG
Regular.
Definition: stat.h:70