Loading
Status: Live
#c The purpose of this assignment is to explore file operations, bitwise operators, and to simulate a multi-disk RAID array. More information on RAID5 is available at https://searchstorage.techtarget.com/definition/RAID-5-redundant-array-of-independent-disks While RAID5 works on a ‘block’ level, we’ll be working on a ‘character’ level. You will create a series of functions that allow a user to initialize 3 or more “disk” (to all zeros – null), represented by files, and a user can read/write to the disk using functions. For the base assignment you can use three disks, called ‘disk0.txt’, ‘disk1.txt’, and ‘disk2.txt’. disks 0 and 1 will store every other byte, disk2 will hold the parity byte Start with the sample files in uLearn. Do not modify file raid.c, instead complete functions where indicated in drive_functions.c
Date Posted: 07/11/2019
Category: Computer Science
Due Date: 12/11/2019
Willing to Pay: $20.00
Instruction
#c The purpose of this assignment is to explore file operations, bitwise operators, and to simulate a multi-disk RAID array. More information on RAID5 is available at https://searchstorage.techtarget.com/definition/RAID-5-redundant-array-of-independent-disks While RAID5 works on a ‘block’ level, we’ll be working on a ‘character’ level. You will create a series of functions that allow a user to initialize 3 or more “disk” (to all zeros – null), represented by files, and a user can read/write to the disk using functions. For the base assignment you can use three disks, called ‘disk0.txt’, ‘disk1.txt’, and ‘disk2.txt’. disks 0 and 1 will store every other byte, disk2 will hold the parity byte Start with the sample files in uLearn. Do not modify file raid.c, instead complete functions where indicated in drive_functions.c HINTS: Be aware of the difference between “char data = ‘0’;” and “char data = 0;”. It may be worth researching the use of a hex editor to inspect your data Parity must be calculated using the XOR function You can jump around in a file using fseek() You should open your files using mode ‘r+’ to allow seek operations Remember to close your files! They may not be written (buffered) otherwise Do not modify the raid.c that is supplied. Instead put all your code inside drive_functions.c raid.c // DO NOT MODIFY THIS FILE!!!!!!! // All your code should go into drive_functions.c #include #include void InitializeDrives(void); void WriteByte(int location, char data); char ReadByte(int location); void RepairDrive(int disk); #include "drive_functions_answer.c" int main(void) { int choice; char data; int address; while(1) { printf("------------------\n"); printf("Main Menu\n\n"); printf("1. Initialize Drives\n"); printf("2. Write Byte\n"); printf("3. Read Byte\n"); printf("4. Repair Drives\n"); printf("5. Run tests\n"); printf("6. Exit\n\n"); scanf("%i", &choice); switch (choice) { case 1: InitializeDrives(); break; case 2: printf("What character would you like to write? "); scanf(" %c", &data); printf("What address would you like to write to? "); scanf(" %i", &address); WriteByte(address,data); break; case 3: printf("What address would you like to read? "); scanf("%i", &address); data = ReadByte(address); printf("The value at this address is: %c\n", data); break; case 4: printf("Which disk should be repaired? "); scanf("%i", &address); RepairDrive(address); break; case 5: InitializeDrives(); FILE * fp = fopen("disk0.txt","r"); fseek(fp, 0L, SEEK_END); int size = ftell(fp); fclose(fp); if (size != 1000) { printf("Error: Incorrect disk size\n"); break; } WriteByte(0,'A'); WriteByte(1,'B'); WriteByte(998,'C'); WriteByte(999,'D'); fp = fopen("disk0.txt","r+"); fseek(fp,0,SEEK_SET); fscanf(fp,"%c", &data); fclose(fp); if (data != 'A') { printf("Error: Incorrect data stored in disk0"); break; } fp = fopen("disk1.txt","r+"); fseek(fp,0,SEEK_SET); fscanf(fp,"%c", &data); fclose(fp); if (data != 'B') { printf("Error: Incorrect data stored in disk1"); break; } data = ReadByte(0); if (data != 'A') { printf("Error: Unable to read/write address 0\n"); break; } data = ReadByte(1); if (data != 'B') { printf("Error: Unable to read/write address 1\n"); break; } data = ReadByte(998); if (data != 'C') { printf("Error: Unable to read/write address 998\n"); break; } data = ReadByte(999); if (data != 'D') { printf("Error: Unable to read/write address 999\n"); break; } fp = fopen("disk0.txt","w"); fclose(fp); RepairDrive(0); data = ReadByte(998); if (data != 'C') { printf("Error: Unable to read/write address 998 after repair\n"); break; } data = ReadByte(999); if (data != 'D') { printf("Error: Unable to read/write address 999 after repair\n"); break; } fp = fopen("disk1.txt","w"); fclose(fp); RepairDrive(1); data = ReadByte(998); if (data != 'C') { printf("Error: Unable to read/write address 998 after repair 2\n"); break; } data = ReadByte(999); if (data != 'D') { printf("Error: Unable to read/write address 999 after repair 2\n"); break; } printf("All tests completed successfully!!!!!!!!!!!!!!!!!\n"); break; case 6: exit(0); break; default: printf("That is not a valid option\n\n"); break; } } } DRIVE_FUNCTIONS.c #ifndef DRIVE_FUNCTIONS #define DRIVE_FUNCTIONS void InitializeDrives(void) { //Create three new files calle disk0.txt, disk1.txt, disk2.txt //Each file should have 1000 bytes in it that are all zeros } void WriteByte(int location, char data) { //Find a particular byte at offset "location" (zero-based offset) //And write the value "data" to it. } char ReadByte(int location) { //Find a particular byte at offset "location" (zero-based offset) //and return the value at that position return 'z'; //temporary placeholder } void RepairDrive(int disk) { //Assuming that one of the disks is damaged, overwrite it //using data from the other two disks to repair the RAID array } #endif
Attached
No File uploaded yet.
Homework Been Upload
No File uploaded yet.
Bidders
19
Average bid
$146.84
Rated 9.47 earned 5296.09 around 200 assignments.
$250.00
Rated 10.0 earned 100.38 around 3 assignments.
$300.00
Rated 8.79 earned 3103.73 around 101 assignments.
$280.00
Rated 9.51 earned 8917.37 around 357 assignments.
$220.00
Rated 8.69 earned 13973.29 around 429 assignments.
$300.00
Rated 9.17 earned 44037.40 around 1448 assignments.
$200.00
Rated 9.33 earned 1098.57 around 41 assignments.
$100.00
Rated 9.52 earned 14458.49 around 544 assignments.
$250.00
Rated 8.66 earned 11685.31 around 365 assignments.
$20.00
Rated 9.38 earned 4963.11 around 178 assignments.
$20.00
Rated 8.99 earned 38922.61 around 1358 assignments.
$50.00
Rated 9.56 earned 4192.14 around 140 assignments.
$20.00
Rated 9.42 earned 9242.99 around 244 assignments.
$60.00
Rated 9.47 earned 1766.75 around 60 assignments.
$200.00
Rated 8.81 earned 25629.66 around 833 assignments.
$100.00
Rated 9.0 earned 4126.23 around 154 assignments.
$100.00
Rated 8.95 earned 4549.40 around 200 assignments.
$120.00
Rated 9.09 earned 2618.38 around 78 assignments.
$50.00
Rated 9.33 earned 960.00 around 28 assignments.
$150.00