Question
Implement the following commands that will run on your file system mkdir command You run the mkdir command in the following way: usage: mkdir >
Implement the following commands that will run on your file system
mkdir command You run the mkdir command in the following way: usage: mkdir
Psuedo-code for mkdir command: 1. Get a free inode number 2. Get a free datablock number 3. Create two entries dot (.) and dotdot(..) 4. Create an inode structure for the new directory 5. Modify the super block (inode and data bitmap) 6. Write the inode structure to its location in I-Table 7. Write the entries (. and ..) into the data block 8. Add this directory as an entry in the current directory
Explanation of the steps: 1. Locate the first bit that 0 (zero) and return its bit number. Say, bit 12 is zero, that is, all bits 0 through 11 are 1's, then return 12. I would write a function that returns the first 0 (zero) bit. And also a function that sets a certain bit to zero or one. 2. Similarly for the data block (similar to (1)). The same functions for the databitmap. 3. We did create two entries dot and dotdot in the file meta data creation so follow those steps. The inode number in dot should the new inode number we just obtained for the directory. The inode number for the dotdot should be the inode number of the current directory (we have a global variable that contains the inode number of the current directory). 4. This is exactly the way we did with the / (root) directory creation. What is the data block number that you assign into data_block_indices[0]? Remember that inode structure has an array that contains the datablocks used (their indices). The data block number obtained at step 2 will be assigned to data_block_indices[0]. 5. The inode number and datablock number bits are set to 1 in the inode and databitmap respectively. 6. Jump to the beginning of the right spot in the inode table to write the inode structure just created. 7. Similarly jump to the beginning of the right datablock to write . and .. entries in it. 8. Find the datablock that the current directory is using (if more than one block is used, find the last one) and add the new directory name in it. What is the inode number of this new directory? Each data block is 512 bytes. That means, you can have 512/32 entries in a data block assuming that the data block is used for a directory. (512/32 = 16). The inode number is the one you obtained in (1).
You will create another command called mkfile. Make file works exactly like mkdir except for: 1. No dot and dot entries. Instead put your name and a short biography of yours in the file. 2. The rest is the same as mkdir command.
Cd command: The cd command works as follows, but first its usage: cd
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started