Question: Asume that an operating system exposes system calls for file access through three API functions. Using only the read, write, and seek functions declared below,
Asume that an operating system exposes system calls for file access through three API functions. Using only the read, write, and seek functions declared below, implement a C function, copy, to copy data from one file to another. [2 points]
/* data : a buffer in main memory
* size : the number of bytes in one chunk of data
* count : the number of chunks to be read or written
* f : the file to be read to or written from
*/
void read(void *data, int size, int count, file f);
void write(void *data, int size, int count, file f);
/* offset : the amount to move the read/write head relative to the origin
* origin : position from which the head is offset {F_CUR, F_BEGIN, F_END}
* f : the file for which the head will be repositioned
*/
void seek(int offset, enum f_orig origin, file f);
Use the function header:
void copy(file f1, int start1, int length, file f2, int start2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
