Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 > mkdir anddoga will create a directory in the current directory (wherever you are in the file system) with the name antdoga.

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 cd antdoga should change the current directory to antdoga. Pseudo-code for cd: 1. Use the current directory (global variable that holds the inode number of the currrent directory) inode number to grab the last data block used by the current directory to get the entries in the current directory. Jump to the I-table using the current directory inode number (which is stored in the global variable). From the inode structure read the indices of the datablocks used and search those data blocks (reading an entry at a time) trying to find antdoga in it. If you find it, make sure it is a directory (not a regular file, type?). If found and directory, then get its inode number and put it in the global variable current_directory_inode_number. If not found, print no such directory or file or print not a directory if antdoga exists but it is a regular file. Do not forget that cd works with . And .. directories where the former makes you stay in the current directory and the latter moves you up in the file system (to the parent directory). Pseudo-code for Recursive lsrec Recurse into the subfolders printing the whole file system. For example, after the file system is create with a single directory called the root (/), mkdir antdoga directory in the current (root) directory. Then cd into antdoga and create another directory in it called fatihbatur .If you run lsrec command it will print the following to the terminal: /. .. antdoga . .. fatihbatur . ..

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions

Question

=+j Enabling a productive global workforce.

Answered: 1 week ago

Question

=+ Are you interested in creating or

Answered: 1 week ago

Question

=+working on a micro-multinational?

Answered: 1 week ago