2. In the Unix OS, there is a class Inode which has the following privatee funct
ID: 3903429 • Letter: 2
Question
2. In the Unix OS, there is a class Inode which has the following privatee function and data structures: vector getindirectblock(int blockid); vector blocks int indirect1 int indirect2; addresses of the first blocks in the block address of a single indirect block address of a double indirect accepts a block address "blockid" and store at "blockid" The vector "blocks" contains the file. The integer "indirect1" is the block. The integer "indirect2" is the block. The function getindirectblock returns the vector of block addresses Add a function "blockls" that uses the above functions to return a vector list of ALL the blocks in a file.Explanation / Answer
vector<int> blockls(){
vector<int> f;
for (int i = 0; i<blocks.size(); i++)
f.push_back(blocks[i];
vector<int> a = getindirectblock(indirect1);
for (int i = 0; i<a.size(); i++)
f.push_back(a[i];
vector<in> b = getindirectblock(indirect2);
for (int i = 0; i<b.size(); i++){
vector<int> d = getindirecbloc(b[i]);
for (int j = 0; j<d.size(); j++)
f.push_back(d[j]);
}
return f;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.