FreeNOS
|
Class for creating new Linnenbank FileSystems. More...
#include <LinnCreate.h>
Public Member Functions | |
LinnCreate () | |
Class constructor. More... | |
int | create (Size blockSize, Size blockNum, Size inodeNum) |
Creates the LinnFS FileSystem. More... | |
void | setProgram (char *progName) |
Set the program name we are invoked with. More... | |
void | setImage (char *imageName) |
Set the output image file name. More... | |
void | setInput (char *inputName) |
Set the input directory name. More... | |
void | setExclude (char *pattern) |
Exclude files matching the given pattern from the image. More... | |
void | setVerbose (bool newVerbose) |
Output verbose messages during the construction. More... | |
Private Member Functions | |
LinnInode * | createInode (le32 inodeNum, FileSystem::FileType type, FileSystem::FileModes mode, UserID uid=ZERO, GroupID gid=ZERO) |
Creates an empty LinnInode. More... | |
le32 | createInode (char *inputFile, struct stat *st) |
Copies a local file contents into an LinnInode. More... | |
void | insertEntry (le32 dirInode, le32 entryInode, const char *name, FileSystem::FileType type) |
Inserts an LinnDirectoryEntry to the given directory inode. More... | |
void | insertDirectory (char *inputFile, le32 inodeNum, le32 parentNum) |
Inserts the given directory and it's childs to the filesystem image. More... | |
void | insertFile (char *inputFile, LinnInode *inode, struct stat *st) |
Inserts the contents of a local file into an LinnInode. More... | |
le32 | insertIndirect (le32 *ptr, const le32 blockIndexNumber, const Size depth) |
Inserts an indirect block address. More... | |
int | writeImage () |
Writes the final image to disk. More... | |
Private Attributes | |
char * | prog |
Program name we are invoked with. More... | |
char * | image |
Path to the output image. More... | |
char * | input |
Path to the input directory. More... | |
bool | verbose |
Output verbose messages. More... | |
List< String * > | excludes |
List of file patterns to ignore. More... | |
LinnSuperBlock * | super |
Pointer to the superblock. More... | |
u8 * | blocks |
Array of blocks available in the filesystem. More... | |
Class for creating new Linnenbank FileSystems.
Definition at line 132 of file LinnCreate.h.
LinnCreate::LinnCreate | ( | ) |
Creates the LinnFS FileSystem.
blockSize | The size of each block in the new filesystem. |
blockNum | The maximum number of blocks in the new filesystem. |
inodeNum | Number of inodes to allocate. |
Definition at line 372 of file LinnCreate.cpp.
References assert, LinnGroup::blockMap, BLOCKPTR, BLOCKS, blocks, LinnSuperBlock::blocksCount, LinnSuperBlock::blockSize, LinnSuperBlock::blocksPerGroup, createInode(), LinnSuperBlock::creationTime, FileSystem::DirectoryFile, LinnSuperBlock::freeBlocksCount, LinnGroup::freeBlocksCount, LinnSuperBlock::freeInodesCount, LinnGroup::freeInodesCount, FileSystem::GroupRX, LinnSuperBlock::groupsTable, image, LinnGroup::inodeMap, LinnSuperBlock::inodesCount, LinnSuperBlock::inodesPerGroup, LinnGroup::inodeTable, input, insertDirectory(), LinnSuperBlock::lastCheck, LINN_CREATE_BLOCKS_PER_GROUP, LINN_GROUP_COUNT, LINN_GROUP_NUM_BLOCKMAP, LINN_GROUP_NUM_INODEMAP, LINN_GROUP_NUM_INODETAB, LINN_INODE_ROOT, LINN_SUPER_MAGIC0, LINN_SUPER_MAGIC1, LINN_SUPER_MAJOR, LINN_SUPER_MINOR, LINN_SUPER_OFFSET, LINN_SUPER_VALID, LinnSuperBlock::magic0, LinnSuperBlock::magic1, LinnSuperBlock::majorRevision, memset(), LinnSuperBlock::minorRevision, LinnSuperBlock::mountCount, LinnSuperBlock::mountTime, FileSystem::OtherRX, FileSystem::OwnerRWX, prog, BitArray::set(), BitArray::setArray(), LinnSuperBlock::state, super, writeImage(), and ZERO.
Referenced by main().
Copies a local file contents into an LinnInode.
inputFile | Path to the local file to insert. |
st | POSIX stat pointer for the local file. |
Definition at line 91 of file LinnCreate.cpp.
References BLOCKPTR, createInode(), exit(), EXIT_FAILURE, FILEMODE_FROM_ST, FILETYPE_FROM_ST, LinnGroup::freeInodesCount, LinnSuperBlock::groupsTable, LinnGroup::inodeMap, LinnSuperBlock::inodesPerGroup, insertFile(), LINN_GROUP_COUNT, printf(), prog, S_ISREG, BitArray::setArray(), BitArray::setNext(), LinnInode::size, stat::st_gid, stat::st_mode, stat::st_uid, super, verbose, and ZERO.
|
private |
Creates an empty LinnInode.
inodeNum | Inode number. |
type | Type of file. |
mode | Access permissions. |
uid | User identity. |
gid | Group identity. |
Definition at line 51 of file LinnCreate.cpp.
References LinnInode::accessTime, BLOCKPTR, LinnInode::changeTime, LinnInode::createTime, LinnSuperBlock::freeInodesCount, LinnGroup::freeInodesCount, LinnInode::gid, LinnSuperBlock::groupsTable, LinnGroup::inodeMap, LinnSuperBlock::inodesPerGroup, LinnGroup::inodeTable, LinnInode::links, LinnInode::mode, LinnInode::modifyTime, BitArray::set(), BitArray::setArray(), LinnInode::size, super, type, LinnInode::type, LinnInode::uid, and ZERO.
Referenced by create(), createInode(), and insertDirectory().
Inserts the given directory and it's childs to the filesystem image.
inputFile | Path to a local directory. |
inodeNum | Inode number for the input directory. |
parentNum | Inode number of our parent. |
Definition at line 304 of file LinnCreate.cpp.
References closedir(), createInode(), dirent::d_name, FileSystem::DirectoryFile, errno, excludes, exit(), EXIT_FAILURE, FILETYPE_FROM_ST, ListIterator< T >::hasCurrent(), insertEntry(), String::match(), NULL, opendir(), printf(), prog, readdir(), S_ISDIR, snprintf(), stat::st_mode, stat(), and strerror().
Referenced by create().
|
private |
Inserts an LinnDirectoryEntry to the given directory inode.
dirInode | Inode number of the directory. |
entryInode | Inode number of the entry to create. |
name | Unique name (inside this directory) for the entry. |
type | FileType for the entry to insert. |
Definition at line 253 of file LinnCreate.cpp.
References BLOCK, LinnInode::block, BLOCKPTR, LinnSuperBlock::blockSize, entry, exit(), EXIT_FAILURE, LinnSuperBlock::groupsTable, LinnSuperBlock::inodesPerGroup, LinnGroup::inodeTable, LINN_DIRENT_NAME_LEN, LINN_INODE_DIR_BLOCKS, printf(), prog, LinnInode::size, strncpy(), super, type, and ZERO.
Referenced by insertDirectory().
Inserts the contents of a local file into an LinnInode.
inputFile | Path to the local file. |
inode | Pointer to the inode to fill. |
st | POSIX stats structure of inputFile. |
Definition at line 179 of file LinnCreate.cpp.
References BLOCK, LinnInode::block, BLOCKPTR, LinnSuperBlock::blockSize, close(), errno, exit(), EXIT_FAILURE, insertIndirect(), LINN_INODE_DIND_BLOCKS, LINN_INODE_DIR_BLOCKS, LINN_INODE_IND_BLOCKS, LINN_INODE_NUM_BLOCKS, LINN_INODE_TIND_BLOCKS, LINN_SUPER_NUM_PTRS, O_RDONLY, open(), printf(), prog, read(), LinnInode::size, stat::st_size, strerror(), and super.
Referenced by createInode().
|
private |
Inserts an indirect block address.
ptr | Buffer containing block addresses. |
blockIndexNumber | Block index number to insert in the buffer, minus LINN_INODE_DIR_BLOCKS |
depth | Level of indirection. |
Definition at line 145 of file LinnCreate.cpp.
References BLOCK, BLOCKPTR, LINN_SUPER_NUM_PTRS, and super.
Referenced by insertFile().
void LinnCreate::setExclude | ( | char * | pattern | ) |
Exclude files matching the given pattern from the image.
pattern | Pattern to match against. |
Definition at line 488 of file LinnCreate.cpp.
References List< T >::append(), and excludes.
Referenced by main().
void LinnCreate::setImage | ( | char * | imageName | ) |
Set the output image file name.
imageName | Image name to use. |
Definition at line 478 of file LinnCreate.cpp.
References image.
Referenced by main().
void LinnCreate::setInput | ( | char * | inputName | ) |
Set the input directory name.
inputName | Input directory to use. |
Definition at line 483 of file LinnCreate.cpp.
References input.
Referenced by main().
void LinnCreate::setProgram | ( | char * | progName | ) |
Set the program name we are invoked with.
progName | program name. |
Definition at line 473 of file LinnCreate.cpp.
References prog.
Referenced by main().
void LinnCreate::setVerbose | ( | bool | newVerbose | ) |
Output verbose messages during the construction.
newVerbose | True to turn on, false to turn off verbose messages. |
Definition at line 493 of file LinnCreate.cpp.
References verbose.
Referenced by main().
|
private |
Writes the final image to disk.
Definition at line 447 of file LinnCreate.cpp.
References blocks, LinnSuperBlock::blocksCount, LinnSuperBlock::blockSize, errno, EXIT_FAILURE, EXIT_SUCCESS, fclose(), fopen(), LinnSuperBlock::freeBlocksCount, fwrite(), image, NULL, printf(), prog, strerror(), and super.
Referenced by create().
|
private |
Array of blocks available in the filesystem.
Definition at line 285 of file LinnCreate.h.
Referenced by create(), and writeImage().
List of file patterns to ignore.
Definition at line 279 of file LinnCreate.h.
Referenced by insertDirectory(), and setExclude().
|
private |
Path to the output image.
Definition at line 270 of file LinnCreate.h.
Referenced by create(), LinnCreate(), setImage(), and writeImage().
|
private |
Path to the input directory.
Definition at line 273 of file LinnCreate.h.
Referenced by create(), LinnCreate(), and setInput().
|
private |
Program name we are invoked with.
Definition at line 267 of file LinnCreate.h.
Referenced by create(), createInode(), insertDirectory(), insertEntry(), insertFile(), LinnCreate(), setProgram(), and writeImage().
|
private |
Pointer to the superblock.
Definition at line 282 of file LinnCreate.h.
Referenced by create(), createInode(), insertEntry(), insertFile(), insertIndirect(), LinnCreate(), and writeImage().
|
private |
Output verbose messages.
Definition at line 276 of file LinnCreate.h.
Referenced by createInode(), LinnCreate(), and setVerbose().