• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

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?
0
kuntilanak
Asked:
kuntilanak
  • 12
  • 11
1 Solution
 
kuntilanakAuthor Commented:
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?
0
 
omarfaridCommented:
You need to know that this is implementation specific since the block may contain other info that also takes space.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
kuntilanakAuthor Commented:
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..
0
 
omarfaridCommented:
then, 1k block gives

1024 - 1 = 1023 bytes
1023 / 4 almost equal to 255
0
 
kuntilanakAuthor Commented:
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?
0
 
omarfaridCommented:
there is no need to label disk blocks it is a reference from partition begin
0
 
kuntilanakAuthor Commented:
is 255 actually the number of pointers?
0
 
omarfaridCommented:
yes, but these could be pointing to other blocks which in turn have the pointers to the file blocks depending on the file size
0
 
kuntilanakAuthor Commented:
depending on what file size
0
 
omarfaridCommented:
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.
0
 
kuntilanakAuthor Commented:
I am reading the normal tanenbaum book...
0
 
omarfaridCommented:
very good book, I also studied from the same book :)
0
 
kuntilanakAuthor Commented:
so are they always assuming that pointers are 4 bytes here?
0
 
omarfaridCommented:
It depends on the implementation !
0
 
kuntilanakAuthor Commented:
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
0
 
omarfaridCommented:
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
0
 
kuntilanakAuthor Commented:
a block number is 32 bit... so that implies the pointer is 32 bit as well?
0
 
omarfaridCommented:
yes
0
 
kuntilanakAuthor Commented:
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?
0
 
omarfaridCommented:
see, when you partition a disk, you set in the partition table where the partition physically starts on the disk and its size. Then when you create a file system on it you reserve some blocks for i-nodes and rest for files data blocks. the references to blocks within this partition, is relative to the starting block of the partition. The disk driver will take care of the mapping between the relative block number and the physical block number.

One more difference I would like to highlight is that the disk blocks are 512 bytes (1 sector which is 512 bytes) and the file system block could be 1k , 2k, 4k, 8k, etc. hence you will not get one to one mapping
0
 
kuntilanakAuthor Commented:
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...
0
 
omarfaridCommented:
yes
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 12
  • 11
Tackle projects and never again get stuck behind a technical roadblock.
Join Now