LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Calculating file sizes from indoors and blocks (https://www.linuxquestions.org/questions/linux-newbie-8/calculating-file-sizes-from-indoors-and-blocks-4175539586/)

ubuntuLearner 04-13-2015 11:30 AM

Calculating file sizes from indoors and blocks
 
Hello I have this problem, but I just ant to know if I am on right track:

Quote:

i_addr is an array of 15 pointers which hold the addresses of a direct data blocks and single indirect, double indirect or triple indirect block.
The first 12 elements of the array refer to addresses of blocks on the disk, which actually contain the files data. When a file requires more than 12 direct blocks, the file system must use disk blocks to hold the addresses of the remaining data blocks needed. These are called indirect blocks. In this particular file system the inode holds the addresses of three indirect data blocks in addition to the 12 direct data blocks discussed. There are single, double and triple indirect data blocks. There is one of each. (in total there are 15 references in the inode). A single indirect block (referenced by element 12 of the inode array) holds the addresses of 2048 disk blocks.
If the file consumes more blocks then can be referenced by a single indirect block then the file system uses a double indirect block. (referenced by element 13 of the inode array). A double indirect block can hold the addresses of 2048 indirect blocks.
If the file consumes more blocks then can be reference by direct, single and double indirect data blocks then the last element of the inode array is used to hold a triple indirect block which effectively references a number of double and single indirect block (ultimately the data).
The Questions I attempted

Quote:

Given the block size of the file system is 8192 bytes answer the following questions:
1. Whatisthemaximumpossiblefilesizethatcanberepresentedviadirectdatablocks?
2. What is the file size if each element of an indirect data blocks references a data block and all direct blocks are used?
3. Whatistherangeoffilesizesthatwouldrequiretheuseofadoubleindirectblock?
4. Whatisthemaximumfilesizeinthisfilesystem?
5. How much overhead is incurred by the file system to store a file of 8437760 bytes.
Overhead is size in bytes of the number of blocks needed to reference this object i.e. indirect blocks etc.
My answers:

Quote:

Answer 1) we know 1 block=8192 bytes, and there are 12 direct data blocks so the max. size is (12*8192) bytes = 98304 bytes.

Answer 2) file size will be = file size in direct data blocks + (2048*8192) = approximately 17 MB

Answer 3) The starting range is > 17 MB. The maximum range will be (2048*8192) + (2048*8192) =

Answer 4) Max size of file in this file system is = 98304+(2048*8192)+(2048*8192)*2+(2048*8192)*3=84.33 MB

Answer 5) We know first 12 blocks have 98304 bytes. The single indirect block has 2048*8192 bytes. Given 8437760 bytes of file size we have an overhead of (2048*8192)/(8437760-98304)= 2 bytes
Please correct me and why am I wrong.

Thanks


All times are GMT -5. The time now is 10:43 PM.