MentOS  0.8.0
The Mentoring Operating System
Functions
read_write.c File Reference

Read and write functions. More...

Functions

ssize_t sys_read (int fd, void *buf, size_t nbytes)
 Read data from a file descriptor. More...
 
ssize_t sys_write (int fd, const void *buf, size_t nbytes)
 Write data into a file descriptor. More...
 
off_t sys_lseek (int fd, off_t offset, int whence)
 Repositions the file offset inside a file. More...
 

Detailed Description

Read and write functions.

Function Documentation

◆ sys_lseek()

off_t sys_lseek ( int  fd,
off_t  offset,
int  whence 
)

Repositions the file offset inside a file.

Parameters
fdThe file descriptor of the file.
offsetThe offest to use for the operation.
whenceThe type of operation.
Returns
Upon successful completion, returns the resulting offset location as measured in bytes from the beginning of the file. On error, the value (off_t) -1 is returned and errno is set to indicate the error.

◆ sys_read()

ssize_t sys_read ( int  fd,
void *  buf,
size_t  nbytes 
)

Read data from a file descriptor.

Parameters
fdThe file descriptor.
bufThe buffer.
nbytesThe number of bytes to read.
Returns
The number of read characters.

◆ sys_write()

ssize_t sys_write ( int  fd,
const void *  buf,
size_t  nbytes 
)

Write data into a file descriptor.

Parameters
fdThe file descriptor.
bufThe buffer collecting data to written.
nbytesThe number of bytes to write.
Returns
The number of written bytes.