18#ifndef __FILESYSTEM_LINN_CREATE_H
19#define __FILESYSTEM_LINN_CREATE_H
40#define LINN_CREATE_BLOCK_SIZE 2048
43#define LINN_CREATE_BLOCK_NUM 8192
46#define LINN_CREATE_BLOCKS_PER_GROUP 8192
49#define LINN_CREATE_INODE_NUM 1024
52#define LINN_CREATE_INODES_PER_GROUP 1024
62#define BLOCKPTR(type,nr) (type *)(blocks + (super->blockSize * (nr)))
72#define BLOCKS(sb,count) \
74 if ((sb)->freeBlocksCount < (count)) \
76 printf("%s: not enough free blocks remaining (%lu needed)\n", \
77 prog, (ulong)(count)); \
80 (sb)->freeBlocksCount -= (count); \
81 ((sb)->blocksCount - (sb)->freeBlocksCount - (count)); \
101#define FILETYPE_FROM_ST(st) \
103 FileSystem::FileType t = FileSystem::UnknownFile; \
105 switch ((st)->st_mode & S_IFMT) \
107 case S_IFBLK: t = FileSystem::BlockDeviceFile; break; \
108 case S_IFCHR: t = FileSystem::CharacterDeviceFile; break; \
109 case S_IFIFO: t = FileSystem::FIFOFile; break; \
110 case S_IFREG: t = FileSystem::RegularFile; break; \
111 case S_IFDIR: t = FileSystem::DirectoryFile; break; \
112 case S_IFLNK: t = FileSystem::SymlinkFile; break; \
113 case S_IFSOCK: t = FileSystem::SocketFile; break; \
126#define FILEMODE_FROM_ST(st) \
127 (FileSystem::FileMode)((st)->st_mode & 0777)
Class for creating new Linnenbank FileSystems.
void setImage(char *imageName)
Set the output image file name.
LinnSuperBlock * super
Pointer to the superblock.
LinnCreate()
Class constructor.
u8 * blocks
Array of blocks available in the filesystem.
void insertEntry(le32 dirInode, le32 entryInode, const char *name, FileSystem::FileType type)
Inserts an LinnDirectoryEntry to the given directory inode.
void setProgram(char *progName)
Set the program name we are invoked with.
char * image
Path to the output image.
char * prog
Program name we are invoked with.
bool verbose
Output verbose messages.
void setVerbose(bool newVerbose)
Output verbose messages during the construction.
le32 insertIndirect(le32 *ptr, const le32 blockIndexNumber, const Size depth)
Inserts an indirect block address.
int writeImage()
Writes the final image to disk.
List< String * > excludes
List of file patterns to ignore.
void setExclude(char *pattern)
Exclude files matching the given pattern from the image.
char * input
Path to the input directory.
void insertDirectory(char *inputFile, le32 inodeNum, le32 parentNum)
Inserts the given directory and it's childs to the filesystem image.
void setInput(char *inputName)
Set the input directory name.
int create(Size blockSize, Size blockNum, Size inodeNum)
Creates the LinnFS FileSystem.
void insertFile(char *inputFile, LinnInode *inode, struct stat *st)
Inserts the contents of a local file into an LinnInode.
LinnInode * createInode(le32 inodeNum, FileSystem::FileType type, FileSystem::FileModes mode, UserID uid=ZERO, GroupID gid=ZERO)
Creates an empty LinnInode.
Simple linked list template class.
unsigned short UserID
User Identity.
u32 BITWISE le32
Unsigned 32-bit little endian number.
unsigned short GroupID
Group Identity.
unsigned int Size
Any sane size indicator cannot go negative.
unsigned char u8
Unsigned 8-bit number.
FileType
All possible filetypes.
u16 FileModes
Multiple FileMode values combined.
Structure of an inode on the disk in the LinnFS filesystem.
Linnenbank Filesystem (LinnFS) super block.
The <sys/stat.h> header shall define the stat structure.