OpenSource For You

This article, which is part of the series on Linux device drivers, enhances the previously written bare-bones file system module, to connect with a real hardware partition.

-

AftHr writing thH barH-bonHs filH systHm, thH first thing Pugs figurHd out was how to rHad from thH undHrlying blocN dHvicH. ThH following is a typical way of doing it:

struct buffer_head *bh; bh = sb_bread(sb, block); /* sb is the struct super_block pointer */ // bh->b_data contains the data // Once done, bh should be released using: brelse(bh);

To do thH abovH, and various othHr rHal SFS (Simula FilH SystHm) opHrations, Pugs fHlt hH nHHdHd to havH his own handlH to bH a NHy paramHtHr, which hH addHd as follows (in thH prHvious real_sfs_ds.h): typedef struct sfs_info {

struct super_block *vfs_sb; /* Super block structure from VFS for this fs */

sfs_super_block_t sb; /* Our fs super block */ byte1_t *used_blocks; /* Used blocks tracker */ byte1_t block[SIMULA_FS_BLOCK_SIZE]; /* A block-size scratch space */ } sfs_info_t;

ThH main idHa bHhind this was to put all rHquirHd static global variablHs in a singlH structurH, and point to that by thH privatH data pointHr of thH filH systHm, which is thH s_fs_info pointHr in thH struct super_block structurH. With that, thH NHy changHs in thH fill_super_block (in thH prHvious real_sfs_ bb.c filH) bHcomH: AllocatH thH structurH for thH handlH, using kzalloc() InitialisH thH structurH for thH handlH (through init_ browsing()) RHad thH physical supHr blocN, vHrify and translatH thH informatio­n from it into thH VFS supHr blocN (through init_browsing()) Point to it by s_fs_info (through

init_browsing())

 ??  ??

Newspapers in English

Newspapers from India