1.1k views
5 votes
Only the additional elements compared to the given P2 are described below. Add these appropriately to the test script. Our path name syntax is the same as Unix path names. Obviously, not every arbitrary string is a valid path or name. Also, the dot and the dot-dot are not permissible as arguments in some contexts below. Nevertheless these commands must be robust. In the following, all meta-variable names that end in pnm are pathnames that are either relative to the current directory or are full/absolute pathnames. fs33% mkdir dnm creates a new empty directory named dnm in the current directory, and prints its i-node number. If a file or directory named dnm already exists in the current directory, it creates nothing new and returns 0. The i-node now needs to have a field that indicates that it is or is not a directory. Assume that dnm does not contain slashes. fs33% rmdir dnm If the directory dnm is empty, deletes it. If dnm is non-empty, no change is made in the file system. In either case, it prints the number of directory entries in dnm (not counting the dot and dot-dot). fs33% mv da db The da is either a normal file or a directory. If da does not exist, return 0 and nothing is altered in the file volume. If db does not exist in the current directory, da is renamed as db. If db is an existing directory in the current directory, the da is moved (along with all its contents) inside db as a subdirectory of db. If db is an existing but ordinary file, return 0. Carefully consider if da and db can be pathnames. fs33% chdir pnm changes the current directory to pnm. If it begins with slash, it is an absolute path name. and the new current directory is pnm. If pnm does not begin with a slash, the new current directory is pnm relative to the present current directory. In either case, print the absolute full path name of the new current directory. Current directory is initially established as the root of a newly created/ found file volume. fs33% pwd prints the full path name of current directory. fs33% ls pnm prints the contents of directory pnm in the "long" format as in Unix ls -l. fs33% inode myfile.txt is an overload of the above command. It first discovers the i-number of file myfile.txt located in the current directory of the current volume and then invokes the inode command above.

1 Answer

2 votes

Final answer:

The commands described are used in a Unix-like file system and include mkdir, rmdir, mv, chdir, pwd, ls, and inode.

Step-by-step explanation:

These instructions describe additional elements to be added to a test script. The commands mentioned are used in a Unix-like file system. Let's go through each command and its functionality:

  1. mkdir dnm: This command creates a new empty directory named 'dnm' in the current directory and prints its i-node number. If 'dnm' already exists, nothing new is created.
  2. rmdir dnm: If the directory 'dnm' is empty, it gets deleted. Otherwise, no changes are made in the file system. The command also prints the number of directory entries in 'dnm'.
  3. mv da db: This command renames 'da' as 'db' if 'da' exists and 'db' doesn't. If 'db' is an existing directory in the current directory, 'da' and its contents are moved inside 'db' as a subdirectory. If 'db' is an ordinary file, nothing happens.
  4. chdir pnm: This command changes the current directory to 'pnm'. If 'pnm' begins with a slash, it is treated as an absolute path name. Otherwise, it is treated as a relative path name. The full absolute path name of the new current directory is printed.
  5. pwd: This command prints the full path name of the current directory.
  6. ls pnm: This command prints the contents of directory 'pnm' in the 'long' format, similar to 'ls -l' in Unix.
  7. inode myfile.txt: This command discovers the i-number of 'myfile.txt' located in the current directory and invokes the 'inode' command above.

User Jim Fred
by
8.4k points