Earn Higher Grades With Instant Assignment Help.Ask Question!

C Programming
(5/5)

LcFHandle lcopen (const char *path) this function will open a file (named path, e.g.,) in the filesystem.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Must be on Ubuntu 19.10

LcFHandle lcopen (const char *path); - This function will open a file(named path, e.g.,) in the filesystem. . If the file does not exist, it should be created and set to zero length. If it does exist, it should be opened, and its read/write position should be

set to the first byte. Note that there are no subdirectories in the filesystem, just files (so you can treat the path as a filename). The function should return a unique filehandle used for subsequent operations or -1 if a failure occurs.

int lcclose(LcFHandle fh ); -This function closes the file referenced by the file handle that was previously open. The function should fail (and return -1) if the file handle is bad or the file was not previously open.

 

int lcread(LcFHandle fh, char *buf, size_t len); -This function

should read count bytes from the file referenced by the file handle at the current position.

Note that if there are not enough bytes left in the file, the function should read to the end

of the file and return the number of bytes read. If there are enough bytes to fulfill the

read, the function should return count. The function should fail (and return -1) if the file

handle is bad or the file was not previously open.

 

int lcwrite(LcFHandle fh, char *buf, size_t len); -The function

should write count bytes into the file referenced by the file handle. If the write goes

beyond the end of the file the size should be increased. The function should always return

the number of bytes written, e.g., count. The function should fail (and return -1) if the file

handle is bad or the file was not previously open.

 

int lcseek(LcFHandle fh, size_t off ); -The function should set the

current position into the file to loc, where 0 is the first byte in the file. The function should

fail (and return -1) if the loc is beyond the end of the file, the file handle is bad or the file

was not previously open.

 

int lcshutdown(void ); --The function should shut down the system, including

powering off the devices and closing all files

 

The Lion Cloud Device Cluster (LionCloud)

You will implement your driver on top of the Lion Cloud device cluster, which is a collection of virtual storage devices that communicate over a kind of virtual bus/network connection. You will begin by powering on the bus, probing to find out how many devices are available (there are a maximum of 16), then allocating space on the devices as the application creates and writes file data to the devices. Each device is uniquely identified by is device Id (whose type is LcDeviceId) which is discovered during the probe process. Each device has a two-level addressing scheme, where it has a number of sectors (s) containing blocks (b); therefore each device has s*b total blocks. A block is a region of memory of LC_DEVICE_BLOCK_SIZE bytes, as declared in the (see lcloud_controller.h header file.

 

  • You communicate with the devices system by sending requests and receiving responses through a set of packed registers. These registers are set within a 64-bit value to encode the opcode and arguments to the hardware device. The opcode is laid out as follows:
  • Bits Register
  • ------ --------------------------------------------------
  • 0-3 B0 - first 4 bit register
  • 4-7 B1 - second 4 bit register
  • 8-15 C0 - first 8 bit register
  • 16-23 C1 - second 8 bit register
  • 24-31 C2 - third 8 bit register
  • 32-47 D0 - first 16 bit register
  • 48-63 D1 - second 16 bit register

To execute an opcode, create a 64 bit value (LCloudRegisterFrame) and pass it any needed buffers to the bus function defined in cart_controller.h:

LCloudRegisterFrame lcloud_io_bus( LCloudRegisterFrame frm, void *xfer );

All messages use the following registers:

Register Request Value Response Value
b0 0 when message sent to devices 1 when message sent from devices
b1 0 when sending to devices 1 is acknowledge/success from device, any other value represents failure code from device
c0 always the operation code (see LcOperationCode type in lcloud_controller.h) The same code as sent.

The operation code (LcOperationCode) indicates what operation is being requested (when sending) or completed (when receiving from the device). The following operations are available:

Operation Description Remaining register use
LC_POWER_ON Initialize interface to the device cluster All other registers (c1, c2, d0, d1) should be 0 on both send and receive  
LC_DEVPROBE Probe the bus to see what devices are All other registers should be 0 on both send. On receive, d0 contains a bit mask of present devices, where device there are a possible 16 devices, where the bit 2^x=1 indicates that device ID x is present. For example if the 2^4 (16) is present, then you know a device with ID 4 is on the bus.  
LC_BLOCK_XFER Transfer a block to the device o    c1 - the device ID for the device to read fromo    c2 - LC_XFER_WRITE for write, LC_XFER_READ for reado    d0 - sector to read/write fromo    d1 - block to read/write from  
LC_POWER_OFF Power off the device All other registers should be 0 on both send and receive  

 

 

  1. Install some libraries you will need for the assignment. Run the following command in your terminal window.

sudo apt-get install libcurl4-gnutls-dev libgcrypt-dev

  1. You are to complete the cfunctions defined above. Note that you may need to create additional supporting functions within the same file. Include functional prototypes for these functions at the top of the file.
  2. Add comments to all of your files stating what the code is doing. Fill out the comment function header for each function you are defining in the code. A sample header you can copy for this purpose is provided for the main function in the code.
  3. To test your program (after running make) with these provided workload files, run the code specifying a workload file as follows:

./lcloud_sim -v cmpsc311-assign2-manifest.txt cmpsc311-assign2-workload.txt

Attachments:
(5/5)

Related Questions

CSI 1420 Introduction to C Programming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two majorconstructs of the C programming language – Fu

The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Assignment To Be Done By Our ExpertsGet A+ Grade Solution Guaranteed

expert
joyComputer science
(4/5)
12 Answers Hire Me
expert
Robert DLaw
(4.8/5)
942 Answers Hire Me
expert
Dr Samuel BarberaStatistics
(5/5)
661 Answers Hire Me
expert
Tutor For YouEconomics
(5/5)
667 Answers Hire Me