Link to home
Start Free TrialLog in
Avatar of kuntilanak
kuntilanakFlag for United States of America

asked on

file system and keeping track of free blocks

I just read from a book that we can use a linked list to keep track of free blocks, however I don't quite understand how it works.. can someone please help me to explain this?
Avatar of kuntilanak

ASKER

the part that I don't quite understand is that say that the size of each block is 1k and a block number is 32 bit.. so therefore I can represent 256 free block number in 1 block.. is this correct? or am I seeing this the wrong way?
You need to know that this is implementation specific since the block may contain other info that also takes space.
well.. for the sake of argument lets assume that the free block list reserves one byte for the pointer to the next block and everything else is for the block number..
then, 1k block gives

1024 - 1 = 1023 bytes
1023 / 4 almost equal to 255
ok if one block can list 255 free block numbers... this is where I got confused... how do they map these block number to the actual place on the disk?? is the disk also labelled with block number as well?
there is no need to label disk blocks it is a reference from partition begin
is 255 actually the number of pointers?
yes, but these could be pointing to other blocks which in turn have the pointers to the file blocks depending on the file size
depending on what file size
the file that a user may create on the file system. Which book by the way are you reading from? There are many books that discuss file systems in general like the operating systems design book or specific file system implementations like unix / linux operating systems design.
I am reading the normal tanenbaum book...
very good book, I also studied from the same book :)
so are they always assuming that pointers are 4 bytes here?
It depends on the implementation !
I know.. in a 64 bit machine pointers can also not be 4 bytes.. but then why did you do this:
1023 / 4

1023 is the number of bytes right and 4 is the number of bytes per pointer
As I understood from your question and later comments, the block size for the free blocks list is 1024 and that one byte is reserved for pointing to the next block, and that the pointer to the free block is 4 bytes in size, hence

(1024 - 1) / 4
a block number is 32 bit... so that implies the pointer is 32 bit as well?
so a block number is not the same as the actual physical address of the disk? if it isn't then what's the size of the actual physical address of the disK?
ASKER CERTIFIED SOLUTION
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hmmm...so therefore if I have 1K disk block then it is actually 2 sectors?? when you mean the relative block number, does this mean the 32 bit number that we're talking about...