- 打开文件
int open(char *pathname, int flags, mode_t mode)
返回fd或-1 error
fd是 file descriptor
- 关闭文件
int close(int fd)
返回0或-1 error
- 读取文件
size_t read(int fd, void *buf, size_t size)
返回读取的字节数或-1 error
- 在offset处写入
size_t write(int fd, void *buf, size_t size)
返回读取的字节数或-1 error
- set file position
off_t lseek(int fd, off_t, int startpos)
start pos=
-0: 从文件头开始 -1: 从目前位置开始 -2: 从文件末尾开始(offset<=0)