白羊跟什么星座最配| 阴道炎有什么症状| 四季豆不能和什么一起吃| 什么水果不含糖| 世界八大奇迹分别是什么| o和ab型生的孩子是什么血型| 2017年属鸡火命缺什么| 25分贝相当于什么声音| 二十年婚姻是什么婚| hpv初期有什么症状女性| 澎湃的什么| 什么是中成药| 软饮是什么意思| pin是什么意思啊| 便秘吃什么药见效快| 登革热是什么病| 肺炎可以吃什么水果| 真菌感染有什么症状| 胎盘内血池是什么| bcm是什么意思| 退休工资什么时候补发| 农历七月份是什么星座| 乙肝通过什么途径传染| 斯德哥尔摩综合症是什么意思| 命脉是什么意思| 长期喝蜂蜜有什么好处| resp是什么意思| 西洋参有什么作用| 冰丝纤维是什么面料| 拉血是什么病| 明胶是什么东西| 肾结晶有什么症状| 为什么会有痛经| 家是什么| 4.11是什么星座| 情分是什么意思| 胡桃木色是什么颜色| 无可奈何什么意思| 吃什么东西能通便| 家里适合养什么花| 乙肝两对半15阳性是什么意思| 白左什么意思| 银环蛇咬伤后什么症状| 喝什么水对身体好| 卵巢囊肿是什么原因引起的| 肠梗阻是什么意思| 六月一日什么星座| plano是什么意思| 吃柠檬是什么意思| 老花镜是什么镜| 喝酒后手麻是什么原因| 挛是什么意思| 父亲节该送什么礼物| 什么情况会染上鼠疫| 月经期间喝酒会有什么影响| 肠息肉吃什么药| 万宝龙皮带算什么档次| 头痛吃什么药好| 睡前吃什么有助于睡眠| 腰部凉凉的是什么原因| 一什么月牙| 结节3类是什么意思| 甲钴胺片有什么副作用| 费力不讨好是什么生肖| beyond是什么意思| 人乳头瘤病毒16型阳性是什么意思| 鼻息肉长什么样| 睡不着觉挂什么科| 天秤座和什么座最配| 善茬是什么意思| 老年人缺钾吃什么好| 胰腺在人体什么位置| 白蚁吃什么| 山东日照有什么好玩的| 什么是十字花科蔬菜| 梦见自己疯了什么意思| 月经期间同房有什么危害| 变性淀粉是什么| 一什么香蕉| 指甲是白色的是什么原因| 浅表性胃炎是什么意思| 爱说梦话是什么原因| 当兵什么时候体检| 鱼腥草不能和什么一起吃| vivo是什么牌子的手机| 怎么吃都不胖是什么原因| 来月经喝什么汤好| 后巩膜葡萄肿是什么意思| 芙蕖是什么意思| 尿检4个加号什么意思| 艾灸的原理是什么| 移植后屁多是什么原因| 前夕是什么意思| 二月十九是什么星座| 什么叫理疗| 温开水冲服是什么意思| vogue什么意思| 嘴巴里面起泡是什么原因引起的| 蜂鸟是什么鸟| 朕是什么时候开始用的| 大放厥词是什么意思| 百花齐放是什么生肖| 清水是什么意思| 三亚免税店什么最便宜| 嫌恶是什么意思| 韧带钙化是什么意思| 嗓子不舒服做什么检查| 囊壁钙化是什么意思| 前列腺钙化灶什么意思| 肾积水是什么原因引起的| 阴阳脸是什么意思| 胳膊困疼是什么原因| lynn是什么意思| 户口分户需要什么条件| 007最新一部叫什么| 男朋友生日送什么礼物| 牙髓炎吃什么药| 乌鱼是什么鱼| 狗狗打喷嚏流鼻涕怎么办吃什么药| 血压低压高是什么原因造成的| 压马路什么意思| 金克什么| 天团是什么意思| 脖子长疣是什么原因| 什么米叫粳米| 坏血病的症状是什么| 夕火念什么| 心率过快会有什么后果| 片反过来念什么| 皮肤黑穿什么颜色好看| 吃什么东西可以除湿气| 奶冻是什么| 什么树没有叶| 3月是什么星座| 高密度脂蛋白胆固醇偏低是什么原因| 什么材质的拖鞋不臭脚| 门子是什么意思| 长脸适合什么发型男| 什么不可什么| 肋骨骨折吃什么食物好得快| 什么叫室性早搏| 无痛人流和普通人流有什么区别| 现在最好的避孕方法是什么| 处女座上升星座是什么| 欲言又止的欲什么意思| 结婚32年是什么婚| triangle是什么意思| 怀孕去医院检查挂什么科| 什么是尿酸| 颈椎痛看什么科| 孕酮是什么| 盆腔积液是什么意思啊| 孕妇喝可乐对胎儿有什么影响| 鼻涕倒流吃什么药效果好| 五月10号是什么星座| 轻度脑萎缩是什么意思| 小舌头有什么用| 清朝是什么时候灭亡的| 12月21是什么星座| 千里共婵娟什么意思| hsg是什么检查项目| 观音菩萨代表什么生肖| 吃素是什么意思| 什么样的小船| 屮艸芔茻什么意思| 拮抗药物是什么药| 咽喉炎吃什么药最好| 女生爱出汗是什么原因| 老年人便秘吃什么药| 为什么头朝西睡觉不好| 炎帝叫什么| cc代表什么意思| cpa是什么意思| 伐木累是什么意思| 开宠物医院需要什么条件| 荞麦长什么样子| 为什么七星瓢虫是益虫| 什么水果补充维生素c| 脑血管堵塞吃什么药最好| 女人吃桃子有什么好处和坏处| 减肥晚上吃什么水果| 左眼皮跳是什么预兆| deep是什么意思| 草字头的字有什么| 双侧肾盂无分离是什么意思| 弥可保是什么药| 虎皮鹦鹉吃什么| 中二病的意思是什么| 牙齿发黄是什么原因| 尿路感染吃什么药效果最好| 产后第一次来月经是什么颜色| 流年不利什么意思| 身份证最后一位x是什么意思| 吃什么补充膝盖润滑液| 眉尾上方有痣代表什么| 喝普洱茶有什么好处| 什么门关不上| 为什么痛经| 去医院看痘痘挂什么科| 细菌性肠炎是什么原因引起的| 谷氨酰转移酶高是什么病| 天启是什么意思| 肛门痒什么原因| 最贵的玉是什么玉| 四川有什么好吃的| 传说中的狮身人面像叫什么名字| 老是拉肚子什么原因| 螳螂吃什么东西| 天可以加什么偏旁| 安瓶是什么| 办健康证挂什么科| 右后背疼是什么病| 什么叫手淫| 梦见刨红薯是什么意思| 在干什么| 县级干部是什么级别| 碰到蛇是什么征兆| 10月15号是什么星座| 细菌是什么生殖| 保险公司最怕什么投诉| 绘本是什么意思| 生气胸口疼是什么原因| 血常规血红蛋白偏高是什么原因| 针灸是什么| sanag是什么牌子| 观音菩萨的坐骑是什么| 小儿电解质补给液有什么作用| 场所是什么意思| 为什么尿黄| 械字号产品是什么意思| nicole是什么意思| 什么叫开门见床头| 女性分泌物少是什么原因| 网络用语是什么意思| 长水痘可以吃什么菜| 不均质脂肪肝是什么意思| 肝五行属什么| 捆是什么意思| 宫颈锥切后需要注意什么| 呼吸胸口疼是什么原因| 蓝风铃香水什么味道| 子宫内膜息肉样增生是什么意思| 什么的红枣| 为什么会有| 饴糖是什么糖| 什么是消炎药| 二级警监是什么级别| 孕妇缺铁性贫血对胎儿有什么影响| 肝功能看什么科室| 轶事是什么意思| 信天翁是什么鸟| 10.1什么星座| 心里紧张吃什么药缓解| 端坐呼吸常见于什么病| 辐射对人体有什么伤害| 南屏晚钟什么意思| 心脏右束支传导阻滞是什么意思| swell是什么牌子| 牙髓炎是什么原因引起的| 妇科炎症用什么药| 谷草转氨酶是指什么| 海尔洗衣机e3是什么故障| 头发五行属什么| 唐僧被封为什么佛| 百度Jump to content

李沧石沟幼儿园规划方案调整 增面积扩招学生

From Wikipedia, the free encyclopedia
(Redirected from File handle)
百度 各省、自治区、直辖市及副省级城市国土资源主管部门,新疆生产建设兵团国土资源局,中央军委后勤保障部军事设施建设局,国家海洋局、国家测绘地理信息局,中国地质调查局及部其他直属单位,各派驻地方的国家土地督察局,部机关各司局:为提升不动产登记工作的社会影响力和认知度,方便群众识别,接受社会监督,强化不动产登记工作人员作风建设,经广泛征集、专家遴选、方案综合、征求意见、网上投票等,部确定了不动产登记标识,决定在全国不动产登记机构和登记窗口使用。

In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a process-unique identifier (handle) for a file or other input/output resource, such as a pipe or network socket.

File descriptors typically have non-negative integer values, with negative values being reserved to indicate "no value" or error conditions.

File descriptors are a part of the POSIX API. Each Unix process (except perhaps daemons) should have three standard POSIX file descriptors, corresponding to the three standard streams:

Integer value Name <unistd.h> symbolic constant[1] <stdio.h> file stream[2]
0 Standard input STDIN_FILENO stdin
1 Standard output STDOUT_FILENO stdout
2 Standard error STDERR_FILENO stderr

Overview

[edit]
File descriptors for a single process, file table and inode table. Note that multiple file descriptors can refer to the same file table entry (e.g., as a result of the dup system call[3]:?104?) and that multiple file table entries can in turn refer to the same inode (if it has been opened multiple times; the table is still simplified because it represents inodes by file names, even though an inode can have multiple names). File descriptor 3 does not refer to anything in the file table, signifying that it has been closed.

In the traditional implementation of Unix, file descriptors index into a per-process file descriptor table maintained by the kernel, that in turn indexes into a system-wide table of files opened by all processes, called the file table. This table records the mode with which the file (or other resource) has been opened: for reading, writing, appending, and possibly other modes. It also indexes into a third table called the inode table that describes the actual underlying files.[3] To perform input or output, the process passes the file descriptor to the kernel through a system call, and the kernel will access the file on behalf of the process. The process does not have direct access to the file or inode tables.

On Linux, the set of file descriptors open in a process can be accessed under the path /proc/PID/fd/, where PID is the process identifier. File descriptor /proc/PID/fd/0 is stdin, /proc/PID/fd/1 is stdout, and /proc/PID/fd/2 is stderr. As a shortcut to these, any running process can also access its own file descriptors through the folders /proc/self/fd and /dev/fd.[4]

In Unix-like systems, file descriptors can refer to any Unix file type named in a file system. As well as regular files, this includes directories, block and character devices (also called "special files"), Unix domain sockets, and named pipes. File descriptors can also refer to other objects that do not normally exist in the file system, such as anonymous pipes and network sockets.

The FILE data structure in the C standard I/O library usually includes a low level file descriptor for the object in question on Unix-like systems. The overall data structure provides additional abstraction and is instead known as a file handle.

Operations on file descriptors

[edit]

The following lists typical operations on file descriptors on modern Unix-like systems. Most of these functions are declared in the <unistd.h> header, but some are in the <fcntl.h> header instead.

Creating file descriptors

[edit]
  • open()
  • creat()[5]
  • socket()
  • accept()
  • socketpair()
  • pipe()
  • epoll_create() (Linux)
  • signalfd() (Linux)
  • eventfd() (Linux)
  • timerfd_create() (Linux)
  • memfd_create() (Linux)
  • userfaultfd() (Linux)
  • fanotify_init() (Linux)
  • inotify_init() (Linux)
  • clone() (with flag CLONE_PIDFD, Linux)
  • pidfd_open() (Linux)
  • open_by_handle_at() (Linux)
  • kqueue() (BSD)
  • pdfork() (kFreeBSD)

Deriving file descriptors

[edit]
  • dirfd()
  • fileno()

Operations on a single file descriptor

[edit]
  • read(), write()
  • readv(), writev()
  • pread(), pwrite()
  • recv(), send()
  • recvfrom(), sendto()
  • recvmsg(), sendmsg() (also used for sending FDs to other processes over a Unix domain socket)
  • recvmmsg(), sendmmsg()
  • lseek(), llseek()
  • fstat()
  • fstatvfs()
  • fchmod()
  • fchown()
  • ftruncate()
  • fsync()
  • fdatasync()
  • fdopendir()
  • fgetxattr(), fsetxattr() (Linux)
  • flistxattr(), fremovexattr() (Linux)
  • statx (Linux)
  • setns (Linux)
  • vmsplice() (Linux)
  • pidfd_send_signal() (Linux)
  • pdkill() (kFreeBSD)
  • waitid() (with P_PIDFD ID type, Linux)
  • fdopen() (stdio function:converts file descriptor to FILE*)
  • dprintf() (stdio function: prints to file descriptor)

Operations on multiple file descriptors

[edit]
  • select(), pselect()
  • poll(), ppoll()
  • epoll_wait(), epoll_pwait(), epoll_pwait2() (Linux, takes a single epoll filedescriptor to wait on many other file descriptors)
  • epoll_ctl() (for Linux)
  • kqueue() (for BSD-based systems).
  • sendfile()
  • splice(), tee() (for Linux)
  • copy_file_range() (for Linux)

Operations on the file descriptor table

[edit]

The fcntl() function is used to perform various operations on a file descriptor, depending on the command argument passed to it. There are commands to get and set attributes associated with a file descriptor, including F_GETFD, F_SETFD, F_GETFL and F_SETFL.

  • close()
  • closefrom() (BSD and Solaris only; deletes all file descriptors greater than or equal to specified number)
  • close_range() (for Linux)[6]
  • dup() (duplicates an existing file descriptor guaranteeing to be the lowest number available file descriptor)
  • dup2(), dup3() (Close fd1 if necessary, and make file descriptor fd1 point to the open file of fd2)
  • fcntl (F_DUPFD)

Operations that modify process state

[edit]
  • fchdir() (sets the process's current working directory based on a directory file descriptor)
  • mmap() (maps ranges of a file into the process's address space)

File locking

[edit]
  • flock()
  • fcntl() (F_GETLK, F_SETLK and F_SETLKW)
  • lockf()

Sockets

[edit]
  • connect()
  • bind()
  • listen()
  • accept() (creates a new file descriptor for an incoming connection)
  • getsockname()
  • getpeername()
  • getsockopt()
  • setsockopt()
  • shutdown() (shuts down one or both halves of a full duplex connection)

Miscellaneous

[edit]
  • ioctl() (a large collection of miscellaneous operations on a single file descriptor, often associated with a device)

at suffix operations

[edit]

A series of new operations has been added to many modern Unix-like systems, as well as numerous C libraries, to be standardized in a future version of POSIX.[7] The at suffix signifies that the function takes an additional first argument supplying a file descriptor from which relative paths are resolved, the forms lacking the at suffix thus becoming equivalent to passing a file descriptor corresponding to the current working directory. The purpose of these new operations is to defend against a certain class of TOCTOU attacks.

  • openat()
  • faccessat()
  • fchmodat()
  • fchownat()
  • fstatat()
  • futimesat()
  • linkat()
  • mkdirat()
  • mknodat()
  • readlinkat()
  • renameat()
  • symlinkat()
  • unlinkat()
  • mkfifoat()
  • fdopendir()

File descriptors as capabilities

[edit]

Unix file descriptors behave in many ways as capabilities. They can be passed between processes across Unix domain sockets using the sendmsg() system call. Note, however, that what is actually passed is a reference to an "open file description" that has mutable state (the file offset, and the file status and access flags). This complicates the secure use of file descriptors as capabilities, since when programs share access to the same open file description, they can interfere with each other's use of it by changing its offset or whether it is blocking or non-blocking, for example.[8][9] In operating systems that are specifically designed as capability systems, there is very rarely any mutable state associated with a capability itself.

A Unix process' file descriptor table is an example of a C-list.

See also

[edit]

References

[edit]
  1. ^ The Open Group. "The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008, 2016 Edition". Retrieved 2025-08-07.
  2. ^ The Open Group. "The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008, 2016 Edition". <stdio.h>. Retrieved 2025-08-07.
  3. ^ a b Bach, Maurice J. (1986). The Design of the UNIX Operating System (8 ed.). Prentice-Hall. pp. 92–96. ISBN 9780132017992.
  4. ^ "Devices - What does the output of 'll /Proc/Self/Fd/' (From 'll /Dev/Fd') mean?".
  5. ^ The Open Group. "The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008, 2018 Edition – creat". Retrieved 2025-08-07.
  6. ^ Stephen Kitt, Michael Kerrisk. "close_range(2) — Linux manual page". Retrieved 2025-08-07.
  7. ^ Extended API Set, Part 2. The Open Group. October 2006. ISBN 1931624674.
  8. ^ Brinkmann, Marcus (2025-08-07). "Building a bridge: library API's and file descriptors?". cap-talk. Archived from the original on 2025-08-07. Retrieved 2025-08-07.
  9. ^ de Boyne Pollard, Jonathan (2007). "Don't set shared file descriptors to non-blocking I/O mode". Retrieved 2025-08-07.
什么补血效果最好最快 天乙是什么意思 阳萎是什么 三庭五眼是什么意思 什么的小花
球蛋白有什么作用和功效 年少轻狂是什么意思 什么预警停课 胃消化不良吃什么药 通便吃什么最快排便
精力旺盛是什么意思 这是什么树 腰扭伤了挂什么科 鹅蛋吃了有什么好处 右手长痣代表什么
兰花是什么颜色 梦见自己拉粑粑是什么意思 偶发房性早搏是什么意思 双鱼男喜欢什么样的女生 双侧肾盂无分离是什么意思
郎才女貌是什么意思hcv8jop8ns7r.cn 回族不吃什么hcv8jop9ns0r.cn 金银花长什么样子图片huizhijixie.com 蛋花样大便是什么原因hcv8jop4ns7r.cn 月字旁的字与什么有关hcv8jop6ns9r.cn
脸上痒是什么原因chuanglingweilai.com 手抖是什么原因hcv8jop3ns3r.cn 血脂异常是什么意思hcv9jop5ns5r.cn 心管是什么部位hcv8jop0ns8r.cn 双肾泥沙样结石是什么意思hcv8jop6ns2r.cn
脚底脱皮用什么药520myf.com 反复呕吐是什么病症hcv8jop2ns1r.cn 见红是什么意思hcv7jop6ns6r.cn 肺热吃什么药hcv9jop1ns8r.cn 女人什么眉毛最有福气hcv9jop5ns8r.cn
腺样体是什么hcv8jop8ns3r.cn 回民不能吃什么hcv7jop9ns3r.cn 2月什么星座的hcv9jop5ns1r.cn 蛋白低是什么原因hcv8jop6ns3r.cn 得糖尿病的原因是什么hcv9jop1ns7r.cn
百度