Ok....this page consists of some of my learning while writing nngfs. Below are they listed
1) Before writing modules you must know for what kernel version you are writing. There have been a lot of changes from kernel 2.4 to 2.6. Earlier fs specific data was kept in a pointer called u.generic_ip ( ... i am telling lie...read more ) while now it is kept in i_private field of struct inode.
Since I was writing the code for 2.6, but didnt have a vfs_inode info field in my incore inode. So for past sometime I am trying to figure out a way to create and allocate a new inode (http://article.gmane.org/gmane.linux.kernel.kernelnewbies/24116). What i was not able to figure out how will the default allocator provide space for my fs specific inode structure coz if you see the 2.6 inode structure you only have a pointer. However 2.4 structures have the fs specific inode info in the same union as of generic_ip. So when the inode is allocated through kernel in 2.4 it means that you already have space allocated for your fs inode too and that is why i told you that i am telling lie above. So it means that you need to have vfs_inode field in your inode info and can't do away without it in 2.6 kernels.
2) Function ext2_block_to_path(): Fills an array of offsets where data resides.
offsets is a list of fbn's (file block numbers), or indexes in the inode->i_data where you should find your data block.
eg..
for block 5
offset[0] = 5
for block = 100
offset[0] = 12
offset[1] = 88 which means you should lookup the 88th entry in the first indirect block which is the 12th block of inode.
3)Function ext2_get_branch()
This uses the offset list from above and returns a chain consisting of blocknumber, its address, and a buffer head if required since in only
in case of indirect blocks the addresses are kept in another block, so you need to read buffer before you can read the block number. For fbn's
less than 12 you don't need a buffer.
eg... if offset[0] = 5, triplet will be <inode->i_data[5], &inode->i_data[5], NULL>
if offset[0] =12, and offset[1] = 88 triplet will be consisting of indirect, so it will be:
<inode->i_data[12], &inode->i_data[12], NULL>
<value of 88th entry in inode->i_data[12],(int *)buffer_head_of(inode->i_data[12])+88,(int *)buffer_head_of(inode->i_data[12]))
For 2.6 kernels also we do the same thing , except we take a lock EXT2_I(inode)->i_meta_lock) before adding to the chain.
Comments (0)
You don't have permission to comment on this page.