现在的位置: 首页 > 综合 > 正文

Learning Linux(7): Linux File

2014年03月21日 ⁄ 综合 ⁄ 共 1130字 ⁄ 字号 评论关闭

The properties are stored in the file’s inode, a special
block of data in the file system that also contains the length of the file and where on the disk it’s stored.
A directory is a file that holds the inode numbers and names of other files.

At the heart of the operating system, the kernel, are a number of device drivers.
To provide a similar interface, device drivers encapsulate all of the hardware-dependent features.
System calls are therefore expensive compared to function calls because Linux has to switch from running your program code to executing its own kernel code and back again.

There are 3 different file descriptors: 0 1 2
Questions:
what are they for? Where are they stored?
It is a little like file handle in windows .
If a device is represented with a FILE, then, in concept, we can write some data to this FILE, but this will cause some problems.
For example, does it make sense to write data to a mouse device?
Does it make sense to get the FILE size of the mouse device?
In such a way, representing device with the concept of file is a little bit unappropriate.
My opinion: we should devide them into different categories.
Another important question: what are the advantages we can get from representing device with file?

Open() call return a file descriptor that can be read or written.

Create file:
open (“myfile”, O_CREAT, S_IRUSR|S_IXOTH);

抱歉!评论已关闭.