What are the Unix system calls for I/O?
- creat(name, permissions) – Used to create a file with the name and mode specified. Here, permission would be a number. 0666 means read write permissions.
- open(name, mode) – Used to open a file name in the mode (read or write) specified.0 is for opening in read mode, 1 for writing and 2 for both.
- close(fd) – Close a opened file.
- unlink(fd) – Delete a file.
- read(fd, buffer, n_to_read) – Read data from a file.
- write(fd, buffer, n_to_write) - write data from to a file.
- lseek(fd, offest, whence) - Move the read/write pointer to the specified location.
What are the UNIX system calls for I/O?
The following are the UNIX system calls for I/O:- Open: to open a file.
Syntax:open (pathname, flag, and mode).
- Create: To create a file.
Syntax:create (pathname, mode).
- Close: To close a file.
Syntax:close (filedes).
- Read: To read data from a file that is opened.
Syntax:read (filedes, buffer, bytes)
- Write: To write data to a file that is opened.
Syntax:write (filedes, buffer, bytes)
- Lseek: To position the file pointer at given location in the file.
Syntax:lseek (filedes, offset, from).
- Dup: To make a duplicate copy of an existing file descriptor.
Syntax:dup (filedes).
- Fcntl: To make the changes to the properties of an open file.
Syntax:fcntl (filedes, cmd, arg).