Solved

file system and keeping track of free blocks

Posted on 2009-04-08
23
341 Views
Last Modified: 2013-12-26
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
Comment
Question by:kuntilanak
  • 12
  • 11
23 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 24104125
0
 

Author Comment

by:kuntilanak
ID: 24104210
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 24104274
You need to know that this is implementation specific since the block may contain other info that also takes space.
0
 

Author Comment

by:kuntilanak
ID: 24104374
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 24105205
then, 1k block gives

1024 - 1 = 1023 bytes
1023 / 4 almost equal to 255
0
 

Author Comment

by:kuntilanak
ID: 24107332
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 24112446
there is no need to label disk blocks it is a reference from partition begin
0
 

Author Comment

by:kuntilanak
ID: 24112943
is 255 actually the number of pointers?
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24112994
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
 

Author Comment

by:kuntilanak
ID: 24113178
depending on what file size
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24113677
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:kuntilanak
ID: 24113689
I am reading the normal tanenbaum book...
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24113692
very good book, I also studied from the same book :)
0
 

Author Comment

by:kuntilanak
ID: 24113699
so are they always assuming that pointers are 4 bytes here?
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24113729
It depends on the implementation !
0
 

Author Comment

by:kuntilanak
ID: 24116043
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 24116108
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
 

Author Comment

by:kuntilanak
ID: 24116133
a block number is 32 bit... so that implies the pointer is 32 bit as well?
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24116263
yes
0
 

Author Comment

by:kuntilanak
ID: 24116339
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
 
LVL 40

Accepted Solution

by:
omarfarid earned 500 total points
ID: 24117343
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
 

Author Comment

by:kuntilanak
ID: 24117528
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 24117540
yes
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

In a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
Windows 7 does not have the best desktop search built in. This is something Windows 7 users have struggled with. You type something in, and your search results don’t always match what you are looking for, or it doesn’t actually work at all. There ar…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now