30.07.2013 Views

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 ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

nbyte : Maximum number <strong>of</strong> bytes to read.<br />

Returns:<br />

The number <strong>of</strong> bytes actually read or -1 on error.<br />

Description:<br />

The read() function reads nbyte bytes from the file associated with fildes into the<br />

buffer pointed to by buf. The read() function returns the number <strong>of</strong> bytes<br />

actually read <strong>and</strong> placed in the buffer. This will be less than nbyte if t he<br />

number <strong>of</strong> bytes left in the file is less than nbyte.<br />

4. write() : Writes to a file.<br />

Arguments:<br />

ssize_t write(int fildes, const void *buf, unsigned int nbyte);<br />

fildes : <strong>File</strong> descriptor open <strong>for</strong> writing.<br />

buf : Pointer to the data to be written.<br />

nbyte : Number <strong>of</strong> bytes to write.<br />

Returns:<br />

The number <strong>of</strong> bytes written, or -1 to indicate an error.<br />

Description:<br />

The write() function writes nbyte bytes from the array pointed to by buf into the<br />

file associated with fildes. If nbyte is zero <strong>and</strong> the file is a regular file, the write()<br />

function returns zero <strong>and</strong> has no other effect.<br />

The write() function returns the number <strong>of</strong> bytes written. This number will be<br />

less than nbyte if there is an error. It will never be greater than nbyte.<br />

5. close() : Closes a file.<br />

Arguments:<br />

int close(int fildes);<br />

fildes : The file descriptor to close.<br />

Returns:<br />

Zero on success <strong>and</strong> -1 on failure.<br />

Description:<br />

The close() function deallocates the file descriptor named by fildes <strong>and</strong> makes it<br />

available <strong>for</strong> reuse.<br />

6. lseek() : Repositions read/write file <strong>of</strong>fset.<br />

Arguments:<br />

<strong>of</strong>f_t lseek(int fildes, <strong>of</strong>f_t <strong>of</strong>fset, int whence);<br />

fildes : <strong>File</strong> descriptor to be repositioned.<br />

<strong>of</strong>fset : New <strong>of</strong>fset.<br />

64

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!