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.6 earned 9245.80 around 329 assignments.
$250.00
Rated 10.0 earned 251.10 around 9 assignments.
$300.00
Rated 8.97 earned 3706.61 around 119 assignments.
$280.00
Rated 9.51 earned 9323.74 around 373 assignments.
$220.00
Rated 8.73 earned 14581.19 around 447 assignments.
$300.00
Rated 9.18 earned 45859.39 around 1494 assignments.
$200.00
Rated 9.3 earned 1997.59 around 74 assignments.
$100.00
Rated 9.58 earned 16621.66 around 628 assignments.
$250.00
Rated 8.64 earned 11911.39 around 374 assignments.
$20.00
Rated 9.21 earned 6646.16 around 236 assignments.
$20.00
Rated 9.0 earned 39717.02 around 1387 assignments.
$50.00
Rated 9.49 earned 7246.13 around 218 assignments.
$20.00
Rated 9.44 earned 10877.92 around 268 assignments.
$60.00
Rated 9.66 earned 2424.80 around 91 assignments.
$200.00
Rated 8.84 earned 28349.42 around 891 assignments.
$100.00
Rated 9.06 earned 6615.74 around 237 assignments.
$100.00
Rated 8.9 earned 4870.94 around 213 assignments.
$120.00
Rated 9.07 earned 3376.41 around 101 assignments.
$50.00
Rated 9.5 earned 1291.57 around 39 assignments.
$150.00