*
* 函数名 用法 备注
*
*1. int open(const char *pathname, int flags); open and possibly create a file or device flags 必须包含O_RDONLY, O_WRONLY, or O_RDWR中的任何一个
*
*2. int open(const char *pathname, int flags, mode_t mode); UP mode只是在flags中包含O_CREAT时才有效
*
*3. int fsync(int fd); synchronize a file's in-core state with storage device 写完数据close前必须先同步,以防意外
*
*4. off_t lseek(int fd, off_t offset, int whence); 定位文件位置 第三个参数可以为SEEK_SET SEEK_CUR SEEK_END
*
*5. ssize_t read(int fildes, void *buf, size_t nbyte); UP 文件位置会随读取的字节数移动
*
*6. ssize_t write(int fildes, const void *buf, size_t nbyte); UP UP
*
*7. int close(int fd); UP UP
*
*8. void *mmap(void *addr, size_t length, int prot, int flags, 内存映射 先用fstat得到文件大小,然后使用该函数将文件内容映射到内存中,然后就可以
int fd, off_t offset); 直接调用字符串函数操作。
*
*9. int munmap(void *addr, size_t length); 释放内存 UP
*
*10. int ftruncate(int fd, off_t length); truncate a file to a specified length 在新建文件时,如果用到内存映射,那么就需要先调用该函数给文件预置一个大小,否则会出错
*
*11. int fstat(int fd, struct stat *buf); 获得文件的基本信息 具体参数见man,可以查到文件的大小、修改日期等
*