0

I'm working on building a simple file system that can handle up to 2GB. My block sizes will be 1KB each and the maximum size file I will take in is 200MB. It will also store up to 10,000 files so I'm trying to lay out how many inode blocks and bitmap blocks to reserve, but I came up with a rough outline. This is how many I of each I plan on having:

Block 0: superblock
block 1: root inode block
blocks 3-182: bitmap blocks
blocks 183-1091: inode blocks
blocks 1092-10000: data blocks for storing files

But again this is an estimate. From the documents I've read about building a simple file system, they never mention specifics such as how many of each you will need. Could someone point me in the right direction? Edit: this is my current inode structure and directory entry structure:

struct inode{
    unsigned long num; //inode number
    unsigned long parent_inode; //parent inode number
    unsigned long zonelist[10]; //pointers: 7 direct, 1 indirect, 1 dub. ind, 1 trip. ind
    char padding[(BLOCKSIZE - (sizeof(long)*14 + sizeof(char) * MAX_FILE_NAME_LENGTH))]; //padding for a BLOCKSIZE inode struct
};

struct dir_entry{
    char name[MAX_FILE_NAME_LENGTH]; //name of file or directory
    int fileinode[100]; //inode pointer
    unsigned long isdir; //0 = file, 1 = directory
    unsigned long size; //file size in bytes
    int num_of_files; //file counter
};
donut juice
  • 257
  • 6
  • 19
  • Depending on your inode structure, you might need *two* bitmaps: One for the data blocks, and one for the inode table. – Some programmer dude Apr 23 '16 at 02:02
  • I will edit my post with my current inode table. @JoachimPileborg – donut juice Apr 23 '16 at 02:04
  • As for the sizes... You know the number of data blocks, which means you know the number of bits needed in the bitmap. Round up to an even multiple of `8` and divide by `8` to get the number of bytes needed, divide by the block-size to get the number of blocks (and add rounding). – Some programmer dude Apr 23 '16 at 02:06
  • @JoachimPileborg should I assume 1 data block per file? i.e. 10,000 data blocks (minus superblock, etc) edit: er, should I have 1 data block per file? – donut juice Apr 23 '16 at 02:09
  • The bitmap should just be a simple table saying which blocks are used or not. When a file is created it is empty, and doesn't use any data blocks, so no bits in the data-block bitmap should be seat on file creation. When data is written to a file, one or more data blocks must be used, and you set the corresponding bits in the data-block bitmap. – Some programmer dude Apr 23 '16 at 02:13
  • And it seems from your structures that you need two bitmaps, one for the data blocks, and one for the inodes. The data-block bitmap stored free/used data blocks, the inode bitmap stores free/used inodes. – Some programmer dude Apr 23 '16 at 02:14
  • I think we are talking about different things... You have a fixed-sized file-system, where the number of inodes and number of data blocks is fixed at creation of the file-system. Since the numbers of inodes and data blocks is fixed, you can then easily calculate the number of bits needed for the bitmaps, and from that the number of blocks on disk needed for the bitmaps. That's it, that's all you need to begin with. – Some programmer dude Apr 23 '16 at 02:27

0 Answers0