辅导CMPSC311、 写作Programming编程

” 辅导CMPSC311、 写作Programming编程Assignment #2 mdadm Linear Device (Basic Functionality)CMPSC311 – Introduction to Systems ProgrammingCheckpoint: February 26, 2021 (11:59 PM) ESTDue date: March 5, 2021 (11:59 PM) ESTCheckpoint 1: You should pass the first three tests, test mount unmount(), test read before mount(), andtest read invalid parameters(), by February 26, 11:59 PM EST. Otherwise you will get 50% penalty even if youpass all tests by the due date.You will need to install libssl-dev by running sudo apt install libssl-dev.Today is the first day of your summer internship at a cryptocurrency startup. Before you join, the marketingteam decided that they Want to differentiate their product by emphasizing on security. On the same day thatyou join the company, the shipment of 16 military-grade, nuclear bomb-proof hard disks arrives. They aresupposed to replace the existing commercial-grade hard disks and will be used to store the most critical userdatacryptocurrency wallets. However, the disk company focuses on physical security and doesnt investmuch in software. They provide their disks as a JBOD (Just a Bunch of Disks), which is a storage architectureconsisting of numerous disks inside of a single storage enclosure. They also provide a user manual along withthe shipment:Bits Width Field Description26-31 6 Command This is the command to be Executed by JBOD.22-25 4 DiskID This is the ID of the disk to perform operation on8-21 14 Reserved Unused bits (for now)0-7 8 BlockID Block address within the diskTable 1: JBOD operation formatThank you for purchasing our military-grade, nuclear bomb-proof hard disks, built with patented NASAtechnologies. Each of the disks in front of you consists of 256 blocks, and each block has 256 bytes, comingto a total of 256 256 = 65,536 bytes per disk. Since you bought 16 disks, the combined capacity is 16 65,536 = 1,048,576 bytes = 1 MB. We provide you with a device driver with a single function that you can useto control the disks.int jbod_operation(uint32_t op, uint8_t *block);This function returns 0 on success and -1 on failure. It accepts an operation through the op parameter,the format of which is described in Table 1, and a pointer to a buffer. The command field can be one of thefollowing commands, which are declared as a C enum type in the header that we have provide to you:1. JBOD_MOUNT: mount all disks in the JBOD and make them ready to serve commands. This is the firstcommand that should be called on the JBOD before issuing any other commands; all commands beforeit will fail. When the command field of op is set to this command, all other fields in op are ignored bythe JBOD driver. Similarly, the block argument passed to jbod_operation can be NULL.2. JBOD_UNMOUNT: unmount all disks in the JBOD. This is the last command that should be called onthe JBOD; all commands after it will fail. When the command field of op is set to this command, allother fields in op are ignored by the JBOD driver. Similarly, the block argument passed to jbod_-operation can be NULL.13. JBOD_SEEK_TO_DISK: seeks to a specific disk. JBOD internally maintains an I/O position, a tupleconsisting of {CurrentDiskID, CurrentBlockID}, which determines where the next I/O operation willhappen. This command seeks to the beginning of Disk specified DiskID field in op. In other words, itmodifies I/O position: it sets CurrentDiskID to DiskID specified in op and it sets CurrentBlockID to 0.When the command field of op is set to this command, the BlockID field in op is ignored by the JBODdriver. Similarly, the block argument passed to jbod_operation can be NULL.4. JBOD_SEEK_TO_BLOCK: seeks to a specific block in current disk. This command sets the CurrentBlockIDin I/O position to the block specified in BlockID field in op. When the command field of opis set to this command, the DiskID field in op is ignored by the JBOD driver. Similarly, the blockargument passed to jbod_operation can be NULL.5. JBOD_READ_BLOCK: reads the block in current I/O position into the buffer specified by the blockargument to jbod_operation. The buffer pointed by block must be of block size, that is 256 bytes.More importantly, after this operation completes, the CurrentBlockID in I/O position is incrementedby 1; that is, the next I/O operation will happen on the next block of the current disk.When the command field of op is set to this command, all other fields in op are ignored by the JBODdriver.6. JBOD_WRITE_BLOCK: writes the data in the block buffer into the block in the current I/O position.The buffer pointed by block must be of Block size, that is 256 bytes. More importantly, after thisoperation completes, the CurrentBlockID in I/O position is incremented by 1; that is, the next I/Ooperation will happen on the next block of the current disk. When the command field of op is set tothis command, all other fields in op are ignored by the JBOD driver.After you finished your onboarding session with HR and enjoyed the free lunch with your new colleagues,you received an email from the manager of the team.Welcome, to the team! Heres your task for the next two weeks. You will be working on integratingJBOD into our existing storage system. Specifically, you will implement one of the functionalities ofthe mdadm utility in Linux. Mdadm stands for multiple disk and device administration, and it is a toolfor doing cool tricks with multiple disks. You will implement one of such tricks supported by mdadm,called linear device. A linear device makes multiple disks appear as a one large disk to the operatingsystem. In our case, we will use your program to configure 16 disks of size 64 KB as a single 1 MBdisk. Below are the functions you need to implement.int mdadm_mount(void): Mount the linear device; now mdadm user can run read and operationson the linear address space that combines all disks. It should return 1 on success and -1 onfailure. Calling this function the second time without calling mdadm_unmount in between, should fail.int mdadm_unmount(void): Unmount the linear device; now all commands to the lineardevice should fail. It should Return 1 on success and -1 on failure. Calling this function the second timewithout calling mdadm_mount in between, should fail.int mdadm_read(uint32_t addr, uint32_t len, uint8_t *buf): Read lenbytes into buf starting at addr. Read from an out-of-bound linear address should fail. A read largerthan 1,024 bytes should fail; in other words, len can be 1,024 at most. There are a few more restrictionsthat you will find out as you Try to pass the tests.Good luck with your task!2Now you are all pumped up and ready to make an impact in the new company. You spend the afternoonwith your mentor, who goes through the directory structure and the development procedure with you:1. jbod.h: The interface of JBOD. You will use the constants defined here in your implementation.2. jbod.o: The object file containing the JBOD driver.3. mdadm.h: A header file that lists the functions you should implement.4. mdadm.c: Your implementation of mdadm functions.5. tester.h: Tester header file.6. tester.c: Unit tests for the functions that you will implement. This file will compile into an executable,tester, which you will run to see if you pass the unit tests.7. util.h: Utility functions used by JBOD implementation and the tester.8. util.c: Implementation of utility functions.9. Makefile: instructions for compiling and building tester used by the make utility.You workflow will consist of (1) implementing functions by modifying mdadm.c, (2) typing make to buildthe tester, and (3) running tester to see if you pass the unit tests, and repeating these three steps until youpass all the tests. Although you only need to edit mdadm.c for successfully completing the assignment, youcan modify any file you want if it helps you in some way. When testing your submission, however, we will usethe original forms of all files Except mdadm.c and mdadm.h.3如有需要,请加QQ:99515681 或WX:codehelp

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导