Development and Implementation of a File System for Gannet Virtual ...
Development and Implementation of a File System for Gannet Virtual ...
Development and Implementation of a File System for Gannet Virtual ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
B. <strong>File</strong> <strong>System</strong> API<br />
Application Program Interfaces listed below, taken from POSIX st<strong>and</strong>ard interface<br />
(Lewine 1991).<br />
1. open() : Opens a file if the file exists or creates a new file does not exist.<br />
Arguments:<br />
int open(const char *path, mode_t <strong>of</strong>lag);<br />
Path : Pointer to path <strong>of</strong> the file to open.<br />
<strong>of</strong>lag : Symbolic flags (Permission bits if a file is created)<br />
Returns:<br />
A file descriptor or -1 on error.<br />
Description:<br />
The open() function establishes a connection between a file <strong>and</strong> a file descriptor.<br />
The file descriptor is a small integer that is used by I/O functions to reference<br />
the file. The path argument points to the pathname <strong>for</strong> the file. The <strong>of</strong>lag<br />
argument is the bitwise inclusive OR <strong>of</strong> the values <strong>of</strong> symbolic constants. The<br />
programmer must specify exactly one <strong>of</strong> the following three symbols:<br />
O_RDONLY : Open <strong>for</strong> reading only.<br />
O_WRONLY : Open <strong>for</strong> writing only.<br />
2. creat()—Creates a new file or rewrites an existing one.<br />
Arguments:<br />
int creat(const char *path, mode_t mode);<br />
path : Pointer to path <strong>of</strong> the file to be created.<br />
mode : Permission bits <strong>for</strong> the new file.<br />
Returns:<br />
A file descriptor or -1 on error.<br />
Description:<br />
It opens a file <strong>for</strong> writing. If the file does not exist, it is created with the<br />
permission bits set from mode <strong>and</strong> the owner <strong>and</strong> group IDs are set from the<br />
effective user <strong>and</strong> group ID <strong>of</strong> the calling process. The file descriptor returned by<br />
creat() may be used only <strong>for</strong> writing.<br />
3. read() : Reads from a file.<br />
Arguments:<br />
size_t read(int fildes, void *buf, unsigned int nbyte);<br />
fildes :<strong>File</strong> descriptor open <strong>for</strong> reading.<br />
buf : Pointer to the place where the data should be read.<br />
63