University : McGill University UniLearnO is not sponsored or endorsed by this college or university.
Subject Code : COMP310
Assignment Task:

Task:

Problem 1: Open Command 

Change the provided codebase so that you cannot read or write to a file unless you initially open the file. Trying to read or write to a file without first opening the file will generate an error message. The syntax of your open command is:

open_EXAM <file_ID_in_active_file_table> filename
• The file_ID_in_active_file_table parameter is an integer that corresponds to the array cell index in the active file table where the user wishes to open the file.
• The filename parameter is the name of the file that will be opened by the open_EXAM command.

You will also need to adjust change the read and write commands. Do not modify the read and write commands that were given to you. Instead, add the following 2 commands: read_EXAM <file_ID_in_active_file_table> var

• The file_ID_in_active_file_table parameter is an integer that corresponds to the array cell index in the active file table where the file has been opened.
• The var parameter is a shell variable into which the contents of the file will be read. write_EXAM <file_ID_in_active_file_table> [alphanumeric strings separated by spaces]
• The file_ID_in_active_file_table parameter is an integer that corresponds to the array cell index in the active file table where the file has been opened.
• The [] square brackets, as before, contain alphanumeric strings separated by spaces. The contents inside the brackets will be written to the file.

Code hooks in the codebase

You were provided with three function templates in interpreter.c called openCommandEXAM(), readCommandEXAM(), and writeCommandEXAM(). You have also been provided with two empty files, DISK_driver_problem1.c (and .h). Use these three places to implement the open_EXAM, read_EXAM, and write_EXAM functionality. Feel free to expose other functions and data structures already existent in the codebase to your DISK_driver_problem1 files. You should be able to complete your implementation by only modifying these three locations. However, if you absolutely need to make modifications elsewhere in the codebase, make a note in the README file, explaining why.

Implementation details

• The open_EXAM command is used to setup the data structures in the OS and locate the file in the partition.
• When a file is opened the pointer to the file is initialized to point to the beginning of the file.
• To make things easy, the open_EXAM command has an index number that refers to the cell of the active file table.


• The read_EXAM and write_EXAM commands will reference that index number to know which file to access. If the file is not opened, read_EXAM and write_EXAM will show the error message “ERROR: Open the file first.”
• The read_EXAM and write_EXAM commands must not look for the file in the partition, instead they use the data structures in the operating system that were initialized by open_EXAM.
• Once a cell has been used to open a file, that call cannot be used again. An error will be generated, “ERROR: Index number in use.”, if the script attempts to open the same cell number.
• Apart from these points, the read_EXAM and write_EXAM commands will behave in the same way as the given read and write commands.

Testing the code
Test your code with the following test file (also available in TESTFILE_PROB1.txt).
1. mount partition1 10 5
2. write_EXAM 0 [hello]
3. open_EXAM 0 file1
4. write_EXAM 0 [hello world test]
5. open_EXAM 0 file2
6. open_EXAM 1 file2
7. read_EXAM 0 var
8. print var
9. quit
The command on line 2 should display: ERROR: Open the file first.
The command on line 5 should display: ERROR: Index number in use.
The command on line 8 should display: hello world test

 

This COMP 310: IT Assignment has been solved by our IT experts at UniLearnO. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.

Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.

Eureka! You've stumped our genius minds (for now)! This exciting new question has our experts buzzing with curiosity. We can't wait to craft a fresh solution just for you!

  • Uploaded By : Pearl
  • Posted on : April 14th, 2019

Whatsapp Tap to ChatGet instant assistance