Question: Part B. Use existing system calls open/close/write to build your own library to handle buffered IO in xv6. You should define struct FILE and consider

Part B. Use existing system calls open/close/write to build your own library to handle buffered IO in xv6. You should define struct FILE and consider fully buffered mode.

Interface:

FILE *myfopen(const char *path, char mode) void myfclose(FILE *fp)

void myfprintf(FILE *fp, const char* s, )

Requirements:

In myfopen(), mode 'r' is for reading and mode 'w' is for writing.

myfclose() should flush its buffer.

myfprintf works like printf() implemented in xv6. It can handle %d, %x, %p, and %s. However, it is buffered, and it works with file pointer instead of file descriptor.

The interface should be defined in mystdio.h.

The implementation should be provided in mystdio.c.

You should define BUFF_SIZE in your header file.

FILE *mystdout should be pre-defined and implicitly opened upon the execution of any user program that includes your header file.

You should also provide a user program mystdiotest.c that uses and tests your library code.

You can assume that the user programs always explicitly close all open streams upon termination.

You are not allowed to modify any existing xv6 source file except for Makefile.

You need to provide a readme file (in PDF format) to

(i) answer the questions in Part A;

(ii) list the names of the xv6 files that you want to remove, if any;

(iii) explain how to use your library code and how your test program works.

Submission: files

mystdio.h

mystdio.c

mystdiotest.c

Makefile

readme.pdf

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!