Differences between common and block device files in Linux

Source: Internet
Author: User

1, Basic concept

Normal file (Regular files). Refers to a file in the ordinary sense, such as a data file, executable file, etc.

Device file. UNIX-like operating systems are based on the concept of files, which are information carriers formed by sequences of bytes. Based on this, the IO device can be treated as a special file called a device file, so the same system call that is used to interact with ordinary files on disk can be used directly with the IO device. Depending on the basic characteristics of the device driver, the device file can be divided into two types: block and character. The differences between the two hardware devices are not easy to divide, but we can at least assume the following differences:[1]

· Data from the block device can be accessed randomly, and from the point of view of the human user, the time required to transmit any block of data is less and substantially the same. A typical example of a block device is a hard disk, floppy disk [1]. A block device is normally a buffer.

· The data of a character device may not be accessed randomly, or it can be randomly accessed, but the time required to access random data is largely dependent on the location of the data within the device [1].

2, the difference of addressing space

A block device file is a physical addressing space for a block device, and a normal file is a virtual addressing space for a block device. an address translation mechanism that is more than one layer of file system for ordinary files than block device files.

It's probably not quite clear, just give me an example.
Let's say the cat command .
The Cat command loops through the command until it touches the end of the file, but when you cat device files, the contents of the device file are read
For example:
650) this.width=650; "src=" Http://img2.dnbcw.net/2013523/4569440.png "width=" "border=" 0 "/>

when I executed the Cat/dev/hello, I had this situation:
650) this.width=650; "src=" Http://img2.dnbcw.net/2013523/4569441.png "width=" "border=" 0 "/>
Please note that the above ^c

indicates that the device file does not have a terminating flag for the file EOF

Thank you!!!

This article is from "Dream Dreams" blog, please be sure to keep this source http://dreamy.blog.51cto.com/12471447/1911645

Differences between common and block device files in Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.