码迷,mamicode.com
首页 > 其他好文 > 详细

一切皆文件-文件是对IO的最简抽象

时间:2019-01-04 18:43:32      阅读:307      评论:0      收藏:0      [点我收藏+]

标签:用户   answer   [1]   out   resource   .com   unix   简化   linux   

引用《Linux Kernel Development》原书里面的一句话

in Unix, everything is a file.This simplifies the manipulation of data and devices into a set of core system calls: open(), read(), write(), lseek(), and close().

 

“UNIX文件本质上就是一大袋字节。” —— 《UNIX编程艺术》

说穿了,文件是对IO的最简抽象。

 

文件就是字节序列,系统中所有的输入输出其实都是通过UNIX I/O函数调用读写文件来实现的。

----深入理解计算机系统

 

https://www.zhihu.com/question/21040222/answer/96976318

 

在Unix中,任何可读/写也就是有I/O的设备,无论是文件,socket,驱动,在打开设备之后都有一个对应的文件描述符。Unix将对这些设备的读写简化在read/write中。

换言之,你只需要把打开的文件描述符传给这两个函数,操作系统内核知道如何根据这个文件描述符得到具体设备信息,内部隐藏了对各种设备进行读写的细节,所有这些对用户都是透明的,你只需要打开它,得到fd,再进行相应的操作就够了。

 

that a wide range of input/output resources  are simple streams of bytes exposed through the filesystem name space.[1]

https://www.cnblogs.com/feng9exe/p/8191921.html

一切皆文件-文件是对IO的最简抽象

标签:用户   answer   [1]   out   resource   .com   unix   简化   linux   

原文地址:https://www.cnblogs.com/feng9exe/p/10221729.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!