FreeNOS
LinnCreate.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009 Niek Linnenbank
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include <BitArray.h>
19#include <List.h>
20#include <ListIterator.h>
21#include <String.h>
22#include <Types.h>
23#include <Macros.h>
24#include <FileSystem.h>
25#include "LinnCreate.h"
26#include "LinnSuperBlock.h"
27#include "LinnGroup.h"
28#include "LinnInode.h"
29#include "LinnDirectoryEntry.h"
30#include <stdio.h>
31#include <stdlib.h>
32#include <dirent.h>
33#include <time.h>
34#include <string.h>
35#include <errno.h>
36#include <libgen.h>
37#include <unistd.h>
38#include <fcntl.h>
39#include <sys/types.h>
40#include <sys/stat.h>
41
43{
44 prog = ZERO;
45 image = ZERO;
46 super = ZERO;
47 input = ZERO;
48 verbose = false;
49}
50
53{
54 LinnGroup *group;
55 LinnInode *inode;
56 BitArray inodeMap(super->inodesPerGroup);
57
58 // Point to the correct group
60 group += inodeNum / super->inodesPerGroup;
61
62 // Use it to find the inode
63 inode = BLOCKPTR(LinnInode, group->inodeTable);
64 inode += inodeNum % super->inodesPerGroup;
65
66 // Initialize the inode
67 inode->type = type;
68 inode->mode = mode;
69 inode->uid = uid;
70 inode->gid = gid;
71 inode->size = ZERO;
72 inode->accessTime = ZERO;
73 inode->createTime = time(ZERO);
74 inode->modifyTime = inode->createTime;
75 inode->changeTime = inode->createTime;
76 inode->links = 1;
77
78 // Update inode BitArray, if needed
79 inodeMap.setArray(BLOCKPTR(u8, group->inodeMap),
81 inodeMap.set(inodeNum % super->inodesPerGroup);
82
83 // Update superblock
85 group->freeInodesCount--;
86
87 // Done
88 return inode;
89}
90
91le32 LinnCreate::createInode(char *inputFile, struct stat *st)
92{
93 LinnGroup *group;
94 LinnInode *inode;
95 BitArray inodeMap(super->inodesPerGroup);
96 u32 gn, in;
97
98 // Loop all available LinnGroups
99 for (gn = 0; gn < LINN_GROUP_COUNT(super); gn++)
100 {
101 // Point to the correct LinnGroup
102 group = BLOCKPTR(LinnGroup, super->groupsTable) + gn;
103
104 // Does it have any free inodes?
105 if (!group->freeInodesCount)
106 {
107 group = ZERO;
108 continue;
109 }
110 else
111 break;
112 }
113
114 // Did we find an appropriate group?
115 if (!group)
116 {
117 printf("%s: no free inode available for `%s'\n",
118 prog, inputFile);
120 }
121
122 // Find an empty inode number
123 inodeMap.setArray(BLOCKPTR(u8, group->inodeMap),
125 inodeMap.setNext(&in);
126
127 // Instantiate the inode
128 inode = createInode(in, FILETYPE_FROM_ST(st),
129 FILEMODE_FROM_ST(st), st->st_uid, st->st_gid);
130
131 // Insert file contents
132 if (S_ISREG(st->st_mode))
133 {
134 insertFile(inputFile, inode, st);
135 }
136
137 // Debug out
138 if (verbose)
139 {
140 printf("%s inode=%u size=%u\n", inputFile, in, inode->size);
141 }
142 return in;
143}
144
145le32 LinnCreate::insertIndirect(le32 *ptr, const le32 blockIndexNumber, const Size depth)
146{
147 Size remain = 1;
148
149 // Does the block map itself have a block?
150 if (!*ptr)
151 {
152 *ptr = BLOCK(super);
153 }
154
155 // Point to the block map
156 ptr = BLOCKPTR(u32, *ptr);
157
158 // Calculate the number of blocks remaining per entry
159 for (Size i = 0; i < depth - 1; i++)
160 {
161 remain *= LINN_SUPER_NUM_PTRS(super);
162 }
163
164 // More indirection?
165 if (remain == 1)
166 {
167 const le32 blockValue = BLOCK(super);
168 ptr[blockIndexNumber % LINN_SUPER_NUM_PTRS(super)] = blockValue;
169 return blockValue;
170 }
171 // Traverse indirection
172 else
173 {
174 return insertIndirect(&ptr[blockIndexNumber / remain],
175 blockIndexNumber, depth - 1);
176 }
177}
178
179void LinnCreate::insertFile(char *inputFile, LinnInode *inode,
180 struct stat *st)
181{
182 int fd, bytes;
183 le32 blockNr;
184
185 // Open the local file
186 if ((fd = open(inputFile, O_RDONLY)) < 0)
187 {
188 printf("%s: failed to fopen() `%s': %s\n",
189 prog, inputFile, strerror(errno));
191 }
192
193 // Read blocks from the file
194 while (inode->size < st->st_size)
195 {
196 // Insert the block (direct)
197 if (LINN_INODE_NUM_BLOCKS(super, inode) <
199 {
200 blockNr = BLOCK(super);
201 inode->block[LINN_INODE_NUM_BLOCKS(super,inode)] = blockNr;
202 }
203 // Insert the block (indirect)
204 else if (LINN_INODE_NUM_BLOCKS(super, inode) <
206 {
207 blockNr = insertIndirect(&inode->block[LINN_INODE_IND_BLOCKS-1],
210 }
211 // Insert the block (double indirect)
212 else if (LINN_INODE_NUM_BLOCKS(super, inode) <
215 {
216 blockNr = insertIndirect(&inode->block[LINN_INODE_DIND_BLOCKS-1],
219 }
220 // Insert the blck (triple indirect)
221 else if (LINN_INODE_NUM_BLOCKS(super, inode) <
225 {
226 blockNr = insertIndirect(&inode->block[LINN_INODE_TIND_BLOCKS-1],
229 }
230 // Maximum file capacity reached
231 else
232 {
233 printf("%s: maximum file size reached for `%s'\n",
234 prog, inputFile);
235 break;
236 }
237
238 // Read block contents
239 if ((bytes = read(fd, BLOCKPTR(u8, blockNr), super->blockSize)) < 0)
240 {
241 printf("%s: failed to read() `%s': %s\n",
242 prog, inputFile, strerror(errno));
244 }
245
246 // Increment size appropriately
247 inode->size += bytes;
248 }
249 // Cleanup
250 close(fd);
251}
252
253void LinnCreate::insertEntry(le32 dirInode, le32 entryInode,
254 const char *name, FileSystem::FileType type)
255{
256 LinnGroup *group;
257 LinnInode *inode;
259 le32 entryNum, blockNum;
260
261 // Point to the correct group
263 if (dirInode != ZERO)
264 {
265 group += (dirInode / super->inodesPerGroup);
266 }
267 // Fetch inode
268 inode = BLOCKPTR(LinnInode, group->inodeTable) +
269 (dirInode % super->inodesPerGroup);
270
271 // Calculate entry and block number
272 entryNum = inode->size / sizeof(LinnDirectoryEntry);
273 blockNum = (entryNum * sizeof(LinnDirectoryEntry)) /
275
276 // Direct block
277 if (blockNum < LINN_INODE_DIR_BLOCKS)
278 {
279 // Allocate a new block, if needed
280 if (!inode->block[blockNum])
281 {
282 inode->block[blockNum] = BLOCK(super);
283 }
284 // Point to the fresh entry
285 entry = BLOCKPTR(LinnDirectoryEntry, inode->block[blockNum]) +
286 (entryNum % super->blockSize);
287 // Fill it
288 entry->inode = entryInode;
289 entry->type = type;
290 strncpy(entry->name, name, LINN_DIRENT_NAME_LEN);
291 entry->name[LINN_DIRENT_NAME_LEN - 1] = ZERO;
292 }
293 // Indirect block
294 else
295 {
296 printf("%s: indirect blocks not (yet) supported for directories\n",
297 prog);
299 }
300 // Increment directory size
301 inode->size += sizeof(LinnDirectoryEntry);
302}
303
304void LinnCreate::insertDirectory(char *inputDir, le32 inodeNum, le32 parentNum)
305{
306 struct dirent *ent;
307 struct stat st;
308 DIR *dir;
309 char path[255];
310 le32 child;
311 bool skip = false;
312
313 // Create '.' and '..'
314 insertEntry(inodeNum, inodeNum, ".", FileSystem::DirectoryFile);
315 insertEntry(inodeNum, parentNum, "..", FileSystem::DirectoryFile);
316
317 // Open the input directory
318 if ((dir = opendir(inputDir)) == NULL)
319 {
320 printf("%s: failed to opendir() `%s': %s\n",
321 prog, inputDir, strerror(errno));
323 }
324 // Read all it's entries
325 while ((ent = readdir(dir)))
326 {
327 // Hidden files
328 skip = ent->d_name[0] == '.';
329
330 // Excluded files
331 for (ListIterator<String *> e(&excludes); e.hasCurrent(); e++)
332 {
333 String dent = (const char *) ent->d_name;
334
335 if (dent.match(**e.current()))
336 {
337 skip = true;
338 break;
339 }
340 }
341 // Skip file?
342 if (skip) continue;
343
344 // Construct local path
345 snprintf(path, sizeof(path), "%s/%s",
346 inputDir, ent->d_name);
347
348 // Stat the file
349 if (stat(path, &st) != 0)
350 {
351 printf("%s: failed to stat() `%s': %s\n",
352 prog, path, strerror(errno));
354 }
355 // Create an inode for the child
356 child = createInode(path, &st);
357
358 // Insert directory entry
359 insertEntry(inodeNum, child, ent->d_name,
360 FILETYPE_FROM_ST(&st));
361
362 // Traverse down
363 if (S_ISDIR(st.st_mode))
364 {
365 insertDirectory(path, child, inodeNum);
366 }
367 }
368 // All done
369 closedir(dir);
370}
371
372int LinnCreate::create(Size blockSize, Size blockNum, Size inodeNum)
373{
374 LinnGroup *group;
375 BitArray map(128);
376
377 assert(image != ZERO);
378 assert(prog != ZERO);
379 assert(blockNum >= 2);
380 assert(inodeNum > 0);
381
382 // Allocate blocks
383 blocks = new u8[blockSize * blockNum];
384 memset(blocks, 0, blockSize * blockNum);
385
386 // Create a superblock
393 super->blockSize = blockSize;
395 super->inodesCount = inodeNum;
396 super->blocksCount = blockNum;
399 super->freeBlocksCount = blockNum - 3;
400 super->creationTime = time(ZERO);
404 super->groupsTable = 2;
405
406 // Allocate LinnGroups
407 for (Size i = 0; i < LINN_GROUP_COUNT(super); i++)
408 {
409 // Point to the correct LinnGroup
410 group = BLOCKPTR(LinnGroup, 2) + i;
411
412 // Fill the group
418 }
419
420 // Create special inodes
423
424 // Insert into directory contents, if set
425 if (input)
426 {
429 }
430 // Mark blocks used
431 for (le32 block = 0; block < super->freeBlocksCount; block++)
432 {
433 // Point to group
435 (block / super->blocksPerGroup);
436 group->freeBlocksCount--;
437
438 // Mark the block used
439 map.setArray(BLOCKPTR(u8, group->blockMap),
441 map.set(block % super->blocksPerGroup);
442 }
443 // Write the final image
444 return writeImage();
445}
446
448{
449 FILE *fp;
450
451 // Open output image
452 if ((fp = fopen(image, "w")) == NULL)
453 {
454 printf("%s: failed to fopen() `%s' for writing: %s\r\n",
456 return EXIT_FAILURE;
457 }
458
459 // Write all blocks at once
461 (super->blocksCount - super->freeBlocksCount), 1, fp) != 1)
462 {
463 printf("%s: failed to fwrite() `%s': %s\r\n",
465 fclose(fp);
466 return EXIT_FAILURE;
467 }
468 // All done
469 fclose(fp);
470 return EXIT_SUCCESS;
471}
472
473void LinnCreate::setProgram(char *progName)
474{
475 this->prog = progName;
476}
477
478void LinnCreate::setImage(char *imageName)
479{
480 this->image = imageName;
481}
482
483void LinnCreate::setInput(char *inputName)
484{
485 this->input = inputName;
486}
487
488void LinnCreate::setExclude(char *pattern)
489{
490 this->excludes.append(new String(pattern));
491}
492
493void LinnCreate::setVerbose(bool newVerbose)
494{
495 this->verbose = newVerbose;
496}
497
498int main(int argc, char **argv)
499{
500 LinnCreate fs;
501 Size blockSize = LINN_CREATE_BLOCK_SIZE;
502 Size blockNum = LINN_CREATE_BLOCK_NUM;
503 Size inodeNum = LINN_CREATE_INODE_NUM;
504
505 // Verify command-line arguments
506 if (argc < 2)
507 {
508 printf("usage: %s IMAGE [OPTIONS...]\r\n"
509 "Creates a new Linnenbank FileSystem\r\n"
510 "\r\n"
511 " -h Show this help message.\r\n"
512 " -v Output verbose messages.\r\n"
513 " -d DIRECTORY Insert files from the given directory into the image\r\n"
514 " -e PATTERN Exclude matching files from the created filesystem\r\n"
515 " -b SIZE Specifies the blocksize in bytes.\r\n"
516 " -n COUNT Specifies the maximum number of blocks.\r\n"
517 " -i COUNT Specifies the number of inodes to allocate.\r\n",
518 argv[0]);
519 return EXIT_FAILURE;
520 }
521 // Process command-line arguments
522 fs.setProgram(argv[0]);
523 fs.setImage(argv[1]);
524
525 // Process command-line options
526 for (int i = 0; i < argc - 2; i++)
527 {
528 // Exclude files matching the given pattern
529 if (!strcmp(argv[i + 2], "-e") && i < argc - 3)
530 {
531 fs.setExclude(argv[i + 3]);
532 i++;
533 }
534 // Verbose output
535 else if (!strcmp(argv[i + 2], "-v"))
536 {
537 fs.setVerbose(true);
538 }
539 // Input directory
540 else if (!strcmp(argv[i + 2], "-d") && i < argc - 3)
541 {
542 fs.setInput(argv[i + 3]);
543 i++;
544 }
545 // Block size
546 else if (!strcmp(argv[i + 2], "-b") && i < argc - 3)
547 {
548 blockSize = atoi(argv[i + 3]);
549 i++;
550 }
551 // Maximum block count
552 else if (!strcmp(argv[i + 2], "-n") && i < argc - 3)
553 {
554 if ((blockNum = atoi(argv[i + 3])) < 2)
555 {
556 printf("%s: block count must be >= 2\r\n",
557 argv[0]);
558 return EXIT_FAILURE;
559 }
560 i++;
561 }
562 // Inode count
563 else if (!strcmp(argv[i + 2], "-i") && i < argc - 3)
564 {
565 if ((inodeNum = atoi(argv[i + 3])) < 1)
566 {
567 printf("%s: inode count must be >= 1\r\n",
568 argv[0]);
569 return EXIT_FAILURE;
570 };
571 i++;
572 }
573 // Unknown argument
574 else
575 {
576 printf("%s: unknown option `%s'\r\n",
577 argv[0], argv[i + 2]);
578 return EXIT_FAILURE;
579 }
580 }
581 // Create a new Linnenbank FileSystem
582 return fs.create(blockSize, blockNum, inodeNum);
583}
u64 fp
Definition ARM64Control.h:3
u8 type
Definition IntelACPI.h:0
u32 entry[]
Definition IntelACPI.h:1
Represents an array of bits.
Definition BitArray.h:37
void setArray(u8 *array, const Size bitCount=ZERO)
Use the given pointer as the BitArray buffer.
Definition BitArray.cpp:170
void set(const Size bit, const bool value=true)
Sets the given bit to the given value.
Definition BitArray.cpp:50
Result setNext(Size *bit, const Size count=1, const Size offset=0, const Size boundary=1)
Sets the next unset bit(s).
Definition BitArray.cpp:97
Class for creating new Linnenbank FileSystems.
Definition LinnCreate.h:133
void setImage(char *imageName)
Set the output image file name.
LinnSuperBlock * super
Pointer to the superblock.
Definition LinnCreate.h:282
LinnCreate()
Class constructor.
u8 * blocks
Array of blocks available in the filesystem.
Definition LinnCreate.h:285
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.
Definition LinnCreate.h:270
char * prog
Program name we are invoked with.
Definition LinnCreate.h:267
bool verbose
Output verbose messages.
Definition LinnCreate.h:276
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.
Definition LinnCreate.h:279
void setExclude(char *pattern)
Exclude files matching the given pattern from the image.
char * input
Path to the input directory.
Definition LinnCreate.h:273
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.
Iterate through a List.
virtual bool hasCurrent() const
Check if there is a current item on the List.
void append(T t)
Insert an item at the end of the list.
Definition List.h:139
Abstraction of strings.
Definition String.h:42
bool match(const char *mask) const
Matches the String against a mask.
Definition String.cpp:267
C int atoi(const char *nptr)
Convert a string to an integer.
Definition atoi.cpp:21
C int open(const char *path, int oflag,...)
Open file relative to directory file descriptor.
Definition open.cpp:26
C struct dirent * readdir(DIR *dirp)
Read a directory.
Definition readdir.cpp:21
C char * strerror(int errnum)
The strerror function maps the number in errnum to a message string.
Definition strerror.cpp:20
C size_t fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream)
The fwrite() function shall write, from the array pointed to by ptr, up to nitems elements whose size...
Definition fwrite.cpp:24
C int close(int fildes)
Close a file descriptor.
Definition close.cpp:22
C int errno
The lvalue errno is used by many functions to return error values.
C void exit(int status)
Terminate a process.
Definition exit.cpp:21
C void * memset(void *dest, int ch, size_t count)
Fill memory with a constant byte.
Definition memset.cpp:20
#define EXIT_SUCCESS
Successful termination.
Definition stdlib.h:33
C int strcmp(const char *dest, const char *src)
Compare two strings.
Definition strcmp.cpp:20
#define assert(exp)
Insert program diagnostics.
Definition assert.h:60
#define S_ISDIR(m)
Test for a directory.
Definition stat.h:155
#define EXIT_FAILURE
Unsuccessful termination.
Definition stdlib.h:36
#define O_RDONLY
Open for reading only.
Definition fcntl.h:81
C int printf(const char *format,...)
Output a formatted string to standard output.
Definition printf.cpp:22
C int fclose(FILE *stream)
Close a stream.
Definition fclose.cpp:23
C ssize_t read(int fildes, void *buf, size_t nbyte)
Read from a file.
Definition read.cpp:22
C int strncpy(char *dest, const char *src, size_t sz)
Copy a string, given a maximum number of bytes.
Definition strncpy.cpp:20
#define S_ISREG(m)
Test for a regular file.
Definition stat.h:161
C DIR * opendir(const char *dirname)
Open directory associated with file descriptor.
Definition opendir.cpp:27
C FILE * fopen(const char *filename, const char *mode)
Open a stream.
Definition fopen.cpp:24
C int snprintf(char *buffer, unsigned int size, const char *fmt,...)
Write a formatted string into a buffer.
Definition snprintf.cpp:22
C int closedir(DIR *dirp)
Close a directory stream.
Definition closedir.cpp:22
int main(int argc, char **argv)
Program entry point.
#define NULL
NULL means zero.
Definition Macros.h:39
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned short UserID
User Identity.
Definition Types.h:134
u32 BITWISE le32
Unsigned 32-bit little endian number.
Definition Types.h:106
unsigned short GroupID
Group Identity.
Definition Types.h:137
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
#define ZERO
Zero value.
Definition Macros.h:43
unsigned char u8
Unsigned 8-bit number.
Definition Types.h:59
#define BLOCK(sb)
Retrieve one free block.
Definition LinnCreate.h:91
#define BLOCKPTR(type, nr)
Returns a pointer to the correct in-memory block.
Definition LinnCreate.h:62
#define FILETYPE_FROM_ST(st)
Convert from a (host system's) POSIX struct stat into a FileType.
Definition LinnCreate.h:101
#define FILEMODE_FROM_ST(st)
Converts an (host system's) POSIX struct st into a FileMode.
Definition LinnCreate.h:126
#define LINN_CREATE_INODE_NUM
Default number of inodes to allocate.
Definition LinnCreate.h:49
#define BLOCKS(sb, count)
Retrieve a given number of free contiguous blocks.
Definition LinnCreate.h:72
#define LINN_CREATE_BLOCK_NUM
Default number of blocks to allocate.
Definition LinnCreate.h:43
#define LINN_CREATE_BLOCK_SIZE
Default block size.
Definition LinnCreate.h:40
#define LINN_CREATE_BLOCKS_PER_GROUP
Default number of data blocks per group descriptor.
Definition LinnCreate.h:46
#define LINN_SUPER_MAGIC1
Second magic number (randomly chosen bytes).
#define LINN_SUPER_MAGIC0
First magic number ('Linn').
#define LINN_GROUP_NUM_BLOCKMAP(sb)
Calculate the number of blocks needed for the blocks bitmap.
Definition LinnGroup.h:75
#define LINN_INODE_DIR_BLOCKS
Direct blocks.
Definition LinnInode.h:49
#define LINN_INODE_DIND_BLOCKS
Double indirect blocks.
Definition LinnInode.h:55
#define LINN_SUPER_MAJOR
Current major revision number.
#define LINN_GROUP_COUNT(sb)
Calculate the number of LinnGroups in a filesystem.
Definition LinnGroup.h:64
#define LINN_GROUP_NUM_INODEMAP(sb)
Calculate the number of blocks needed for the inodes bitmap.
Definition LinnGroup.h:86
#define LINN_SUPER_OFFSET
Fixed offset in storage of the superblock.
#define LINN_INODE_TIND_BLOCKS
Triple indirect blocks.
Definition LinnInode.h:58
#define LINN_INODE_ROOT
Root inode.
Definition LinnInode.h:37
#define LINN_SUPER_NUM_PTRS(sb)
Calculate the number of block address pointers fitting in one block.
#define LINN_DIRENT_NAME_LEN
Length of the name field in an directory entry.
#define LINN_GROUP_NUM_INODETAB(sb)
Calculate the number of blocks needed for the inodes table.
Definition LinnGroup.h:97
#define LINN_SUPER_VALID
Filesystem is consistent.
#define LINN_INODE_NUM_BLOCKS(super, inode)
Calculate the number of blocks used in an LinnInode.
Definition LinnInode.h:80
#define LINN_SUPER_MINOR
Current minor revision number.
#define LINN_INODE_IND_BLOCKS
Indirect blocks.
Definition LinnInode.h:52
FileType
All possible filetypes.
Definition FileSystem.h:71
u16 FileModes
Multiple FileMode values combined.
Definition FileSystem.h:108
A type representing a directory stream.
Definition dirent.h:95
A structure containing information about a file.
Definition stdio.h:61
Struct of an directory entry in LinnFS.
Structure of a group descriptor.
Definition LinnGroup.h:130
le32 inodeMap
Inode bitmap.
Definition LinnGroup.h:141
le32 freeBlocksCount
The number of free blocks in this group.
Definition LinnGroup.h:132
le32 inodeTable
Inode table contains pre-allocated inodes.
Definition LinnGroup.h:144
le32 freeInodesCount
Number of free inodes in this group.
Definition LinnGroup.h:135
le32 blockMap
Block bitmap.
Definition LinnGroup.h:138
Structure of an inode on the disk in the LinnFS filesystem.
Definition LinnInode.h:93
le16 mode
Access permissions, as an FileMode.
Definition LinnInode.h:95
le32 size
Size in bytes.
Definition LinnInode.h:98
le16 links
Links count.
Definition LinnInode.h:103
le32 accessTime
Access time.
Definition LinnInode.h:99
le32 block[LINN_INODE_BLOCKS]
Pointers to blocks.
Definition LinnInode.h:104
le32 changeTime
Status change timestamp.
Definition LinnInode.h:102
le32 createTime
Creation time.
Definition LinnInode.h:100
le16 uid
User Identity.
Definition LinnInode.h:96
le32 modifyTime
Modification time.
Definition LinnInode.h:101
le16 gid
Group Identity.
Definition LinnInode.h:97
le16 type
Type of file, as an FileType.
Definition LinnInode.h:94
Linnenbank Filesystem (LinnFS) super block.
le16 mountCount
Number of times we where mounted.
le32 creationTime
Time when the filesystem was created.
le32 groupsTable
Block address of the LinnGroup table.
le32 inodesCount
Total number of inodes.
le32 magic0
Allows detection of valid superblocks.
le32 freeInodesCount
Free inodes remaining.
le32 blockSize
Size of each data block.
le32 mountTime
Last time we where mounted (seconds since 1970).
le32 magic1
Allows detection of valid superblocks.
le16 minorRevision
Filesystem minor revision level.
le16 majorRevision
Filesystem major revision level.
le32 inodesPerGroup
Number of inodes per group.
le32 lastCheck
Timestamp of the last check.
le32 blocksCount
Total number of data blocks.
le32 freeBlocksCount
Number of free data blocks.
le32 blocksPerGroup
Number of blocks per group.
le16 state
Describes the current status.
Represents a directory entry.
Definition dirent.h:65
char d_name[DIRLEN]
Name of entry.
Definition dirent.h:67
The <sys/stat.h> header shall define the stat structure.
Definition stat.h:177
off_t st_size
For regular files, the file size in bytes.
Definition stat.h:226
uid_t st_uid
User ID of file.
Definition stat.h:209
mode_t st_mode
Mode of file.
Definition stat.h:203
gid_t st_gid
Group ID of file.
Definition stat.h:212