file descriptor(文件描述符) & file descriptor flags(文件描述符标志) & file status flags(文件状态标志)
2015-09-22 18:47
1001 查看
在阅读Stevens的大作<<Advanced Programming in the UNIX® Environment>> ,简称为<<APUE>>时,在第三章中出现了三个英文词,file descriptor,file descriptor flags,file status flags,即所谓的”文件描述符“,"文件描述符标志", "file status flags",这三个概念在使用fcntl函数时必须要区别清楚。下面就从字面上来解释下:
1)file descriptor(文件描述符):是文件的一个标识,常使用整数标识。内核使用该标识跟踪你在程序中打开的文件;
2)file descriptor flags(文件描述符标志):从字面上来理解,就是描述符的一个标志,目前Unix,Unix-like和Linux中只有一个值:close-on-exec,用FD_CLOEXEC来表示。
3)file status flags(文件状态标志):从字面上来理解,就是用来描述文件状态的一个标志,根据理解,我把此类标志分为三个部分:
a)文件访问性状态标志:O_RDONLY,O_WRONLY,O_RDWR;
b)文件创建性状态标志:O_CREAT,O_EXCL, O_NOCTTY,O_TRUNC,O_APPEND;
c)文件异步/同步标志:O_NONBLOCK, O_SYNC, O_DSYNC, O_RSYNC, O_FSYNC, and O_ASYNC
在<<APUE>>中,使用三种数据结构来描述打开的文件:
1)进程表项,是一个进程表的一行。文件描述符和文件描述符标志存在于这个结构中。
2)文件表,文件状态标志存在于这个结构中。
3)i-node/v-node节点
下面给出具体的英文描述和一张图表:
The kernel uses three data structures to represent an open file, and the relationships among them determine the effect one process has on another with regard to file sharing.
1)Every process has an entry in the process table. Within each process table entry is a table of open file descriptors, which we can think of as a vector, with one entry per descriptor. Associated with each file descriptor are
a)The file descriptor flags.
b)A pointer to a file table entry.
2)The kernel maintains a file table for all open files. Each file table entry contains
a)The file status flags for the file, such as read, write, append, sync, and nonblocking.
b)The current file offset.
c)A pointer to the v-node table entry for the file.
3)Each open file (or device) has a v-node structure that contains information about the type of file and pointers to functions that operate on the file. For most files, the v-node also contains the i-node for the file. This information is read from disk
when the file is opened, so that all the pertinent information about the file is readily available. For example, the i-node contains the owner of the file, the size of the file, pointers to where the actual data blocks for the file are located on
disk, and so on.
1)file descriptor(文件描述符):是文件的一个标识,常使用整数标识。内核使用该标识跟踪你在程序中打开的文件;
2)file descriptor flags(文件描述符标志):从字面上来理解,就是描述符的一个标志,目前Unix,Unix-like和Linux中只有一个值:close-on-exec,用FD_CLOEXEC来表示。
3)file status flags(文件状态标志):从字面上来理解,就是用来描述文件状态的一个标志,根据理解,我把此类标志分为三个部分:
a)文件访问性状态标志:O_RDONLY,O_WRONLY,O_RDWR;
b)文件创建性状态标志:O_CREAT,O_EXCL, O_NOCTTY,O_TRUNC,O_APPEND;
c)文件异步/同步标志:O_NONBLOCK, O_SYNC, O_DSYNC, O_RSYNC, O_FSYNC, and O_ASYNC
在<<APUE>>中,使用三种数据结构来描述打开的文件:
1)进程表项,是一个进程表的一行。文件描述符和文件描述符标志存在于这个结构中。
2)文件表,文件状态标志存在于这个结构中。
3)i-node/v-node节点
下面给出具体的英文描述和一张图表:
The kernel uses three data structures to represent an open file, and the relationships among them determine the effect one process has on another with regard to file sharing.
1)Every process has an entry in the process table. Within each process table entry is a table of open file descriptors, which we can think of as a vector, with one entry per descriptor. Associated with each file descriptor are
a)The file descriptor flags.
b)A pointer to a file table entry.
2)The kernel maintains a file table for all open files. Each file table entry contains
a)The file status flags for the file, such as read, write, append, sync, and nonblocking.
b)The current file offset.
c)A pointer to the v-node table entry for the file.
3)Each open file (or device) has a v-node structure that contains information about the type of file and pointers to functions that operate on the file. For most files, the v-node also contains the i-node for the file. This information is read from disk
when the file is opened, so that all the pertinent information about the file is readily available. For example, the i-node contains the owner of the file, the size of the file, pointers to where the actual data blocks for the file are located on
disk, and so on.
相关文章推荐
- struts2开发-validate-表单验证案例1
- 揆首:以极客的思维做云诺
- 脑洞门大开思维工具:六顶思考帽
- myEclipse Could not create the view: An unexpected exception was thrown.
- BZOJ3616 : War
- jqmobi(appframework) 小技巧记录
- 并发和并行
- Android系统启动流程
- UVA 10870 Recurrences
- QT中QTimer的使用方法介绍
- atexit http://www.cnblogs.com/wanghetao/archive/2012/04/03/2431256.html
- 树莓派调整sd卡分区大小
- unity3d 学习笔记(七) 类的基本函数学习
- Linux下的常用shell命令
- segmentedControl与swipe联合控制页面
- jqMobi指南系列教程是《 jqMobi Javascript Frameworks Cheat Sheet》 的中文版现在改名为app framework
- 第二次作业——结对项目之需求分析与原型模型设计
- Texlive 更新命令
- POJ 1308 HDU 1358 Is It A Tree? 并查集 (好多WA点)
- Ubuntu-Python2.7安装 scipy,numpy,matplotlib