Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose you are given the inode structure as shown below. Assume that our inode

ID: 3585281 • Letter: S

Question

Suppose you are given the inode structure as shown below. Assume that our inode structure has 10 direct pointers, and Block size is 8K bytes and pointers are 4 bytes. Write a function int count ti (struct inode *myinode, char *word); which counts the number of blocks containing the given string word only in triple indirect blocks. b. [7 points] mode owners (2 timestamps (3 size block count Note that triple indirect level might be partially filled with blocks! So if there is no more block or level the corresponding pointer will contain NULL. Please take that into account! db data direct blocks Also assume that a data block contains a string text. Thus, if needed, you can use strcmp () or any other functions from the standard libraries (suppose they are included here) data data S snge indirect double indirect iple indirect data ti data Space for problem 4 (b) [7pt] int count di (struct inode *myinode, char *word) ( int i, j, k; int count 0 int num blk 8 * 1024 / 4;

Explanation / Answer

struct blk{

struct blk * ptr[2000];

};

int count_di(struct inode * myinode, char * word){

int count=0;

struct blk * firstindirect=myinode -> ti; //First indirect   

for(int i=0;i<2000;i++){

struct blk * secondindirect= firstindirect->ptr[i]; //Second indirect

for(int j=0;j<2000;j++){

  struct blk * thirdindirect= secondindirect->ptr[j]; // Third indirect

for(int k=0;k<2000;k++){

struct blk* blkptr= thirdindirect->ptr[k];

for(int l=0;l<8000-strlen(word);l++){

if(!strcmp((char*)blkptr+l,word)count++;

}

}

}   

}

return count;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote