Many people think that files are some of the data stored on disk, but Linux uses a more abstract approach. Abstract the device into a file. A device file has the same file name, another inode number, a file owner, a set of permission bits, and the most recent modification time, just like a normal file. Everything that is normally understood about the file will be applied to the terminal and other devices.
Ordinary files, that is, commonly used disk files are composed of bytes, and the number of bytes in the disk file is the file size. The device file is a link, not a container. The keyboard and mouse do not store clicks:) The i-node of the device file stores a pointer to a subroutine of the kernel, not the file size and storage list. A subroutine that transfers device data in the kernel is called a device driver.
The difference in file type is reflected on the i-node:
The i-node of the disk file contains a list of pointers to the data block.
The i-node of the device file contains a pointer to the kernel. Device Driver Pointers
Disk Connections and Device Connections
Connections to disk files usually contain a kernel buffer, a property such as a disk connection with a buffer. The connection to the terminal is different, and the process needs to transfer the data as soon as possible.
In other words, the connection properties of the two are different. For a specific file and device connection, you can think about: 1. What properties are connected? 2. How to detect the current attribute? 3. How to change the current attribute?
The answer to 2 and 3 is to use the system call fcntl, the attribute of the file descriptor is encoded in an integer bit. Fcntl controls the file descriptor by reading and writing the integer bits.
For example:
#include<fcntl.h>
int s;
s = fcntl(fd, F_GETFL);
s |
= OSYNC;
result = fcntl(fd, F_SETFL, s);
Read settings from the kernel to variables, modify the value of the variable, return the settings to the kernel, read in Linux and A typical way to modify connection properties.
fcntl is not the only way to set file descriptor properties. Usually when you open a file, you should know what settings you need. The properties of the file descriptor can be set by the system calling a part of the second parameter of open.
Such as: fd = open(FILE, OWRONLY |
O_APPEND |
O_SYNC );
For all organizations and companies, data is the most important to them, and even for e-com
The companys network environment is a bit complicated, and the damn secure policy requires
using direct-lvm storage method Recently played docker on Bluemix virtual machine, but found that t
Ubuntu does not connect to the Internet how to do
Vim common commands and configurations
The use of the Linux primary command useradd and detailed
Twemproxy installation and configuration
Dynamic routing network infrastructure of linux
Linux pipeline and redirection
Linux modified hostname two ways
Example of saving iptables firewall rules in Ubuntu