(i): creat system Call: System call to create file
Call Method:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int creat (const char* path,mode_t mode);
Where path is the file descriptor, mode is the file's permission.
completely equivalent to the modern open () call
FD = open (file,o_wronly| O_creat| O_trunc,mode);
(b): Read system call: If the file is opened with the o_rdonly or O_RDWR flag
# include <sys/types.h>
# include <unistd.h>
int read (int fd,void *buf,size_t nbytes);
Where FD is the file descriptor that you want to read, BUF is a pointer to the memory block, and Nbytes is the number to read
(c); Write system call:
# include <sys/types.h>
# include <unistd.h>
int write (int fd,void *buf,size_t nbytes);
Note: Write writes not a disk but a memory buffer. Write cannot be written directly to disk.
FD = open (file,o_wronly| O_sync);
O_sync the effect of this flag is to make the system call to a specific file descriptor write ()
and the corresponding actual write disk is synchronized, in fact, until the actual write disk is completed, the write () system call is returned.
Linux Summary application of four system call functions