Go to the documentation of this file.
30 char *buff = (
char *)
malloc(128);
43 if (!strftime(buff, 128,
"%F %T", tm))
54 printf(
"usage: %s FILE [OPTIONS...]\r\n"
55 "Displays information of a Linnenbank Filesystem\r\n"
57 "-h Show this help message.\r\n",
61 int main(
int argc,
char **argv)
65 float percentFreeBlocks = 0, percentFreeInodes = 0, megabytes = 0;
75 for (
int i = 0; i < argc - 2; i++)
78 if (!
strcmp(argv[i + 2],
"-h"))
85 printf(
"%s: unknown option `%s'\r\n",
86 argv[0], argv[i + 2]);
91 printf(
"%s: failed to fopen() `%s': %s\n",
98 printf(
"%s: failed to fseek() to %x in `%s': %s\n",
103 if (
fread(&super,
sizeof(super), 1, fp) != 1)
105 printf(
"%s: failed to fread() superblock from `%s': %s\n",
106 argv[0], argv[1], ferror(fp) ?
strerror(
errno) :
"End of file");
113 printf(
"%s: `%s' is not a LinnFS filesystem (magic mismatch)\n",
132 printf(
"LinnSuperBlock\n"
136 " majorRevision = %u\n"
137 " minorRevision = %u\n"
140 " blocksPerGroup = %u\n"
141 " inodesPerGroup = %u\n"
142 " inodesCount = %u\n"
143 " blocksCount = %u (%.2fMB)\n"
144 " freeBlocksCount = %u (%.2f%%)\n"
145 " freeInodesCount = %u (%.2f%%)\n"
146 " creationTime = %s\n"
150 " groupsTable = %u\n"
166 printf(
"%s: failed to seek to LinnGroup table in `%s': %s\n",
174 if (
fread(&group,
sizeof(group), 1, fp) != 1)
176 printf(
"%s: failed to fread() group from `%s': %s\n",
177 argv[0], argv[1], ferror(fp) ?
strerror(
errno) :
"End of file");
181 printf(
"LinnGroup #%u (blocks %u - %u)\n"
183 " freeBlocksCount = %u\n"
184 " freeInodesCount = %u\n"
185 " blockMap = %u - %lu\n"
186 " inodeMap = %u - %lu\n"
187 " inodeTable = %u - %lu\n"
#define EXIT_FAILURE
Unsuccessful termination.
le16 state
Describes the current status.
le32 lastCheck
Timestamp of the last check.
le32 freeInodesCount
Free inodes remaining.
#define LINN_GROUP_NUM_INODETAB(sb)
Calculate the number of blocks needed for the inodes table.
le16 majorRevision
Filesystem major revision level.
#define LINN_GROUP_NUM_BLOCKMAP(sb)
Calculate the number of blocks needed for the blocks bitmap.
unsigned long ulong
Unsigned long number.
C int errno
The lvalue errno is used by many functions to return error values.
le32 magic0
Allows detection of valid superblocks.
FILE * fopen(const char *filename, const char *mode)
Open a stream.
u64 timestamp()
Reads the CPU's timestamp counter.
le32 magic1
Allows detection of valid superblocks.
le32 mountTime
Last time we where mounted (seconds since 1970).
Structure of a group descriptor.
le32 inodesCount
Total number of inodes.
le32 blocksPerGroup
Number of blocks per group.
le32 blockMap
Block bitmap.
C void * malloc(size_t size)
A memory allocator.
#define LINN_GROUP_NUM_INODEMAP(sb)
Calculate the number of blocks needed for the inodes bitmap.
int main(int argc, char **argv)
Program entry point.
le32 inodeTable
Inode table contains pre-allocated inodes.
u64 time_t
Used for time in seconds.
le32 freeBlocksCount
Number of free data blocks.
char * strdup(const char *str)
Duplicate a string.
le32 freeBlocksCount
The number of free blocks in this group.
int printf(const char *format,...)
Output a formatted string to standard output.
#define LINN_SUPER_OFFSET
Fixed offset in storage of the superblock.
Linnenbank Filesystem (LinnFS) super block.
#define LINN_SUPER_MAGIC1
Second magic number (randomly chosen bytes).
#define LINN_SUPER_MAGIC0
First magic number ('Linn').
int strcmp(const char *dest, const char *src)
Compare two strings.
char * strerror(int errnum)
The strerror function maps the number in errnum to a message string.
#define NULL
NULL means zero.
unsigned int u32
Unsigned 32-bit number.
unsigned int Size
Any sane size indicator cannot go negative.
le32 groupsTable
Block address of the LinnGroup table.
#define LINN_GROUP_COUNT(sb)
Calculate the number of LinnGroups in a filesystem.
le32 creationTime
Time when the filesystem was created.
#define EXIT_SUCCESS
Successful termination.
#define SEEK_SET
Seek relative to start-of-file.
le32 freeInodesCount
Number of free inodes in this group.
char * timeString(u32 timestamp)
le32 blocksCount
Total number of data blocks.
le32 blockSize
Size of each data block.
le16 mountCount
Number of times we where mounted.
le16 minorRevision
Filesystem minor revision level.
size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream)
Binary input.
A structure containing information about a file.
int fclose(FILE *stream)
Close a stream.
le32 inodeMap
Inode bitmap.
le32 inodesPerGroup
Number of inodes per group.