What designates a character special file




















It only takes a minute to sign up. Connect and share knowledge within a single location that is structured and easy to search.

How are character special files and block special files different from regular files in a Unix-like system? When a program reads or writes data from a file, the requests go to a kernel driver. If the file is a regular file, the data is handled by a filesystem driver and it is typically stored in zones on a disk or other storage media, and the data that is read from a file is what was previously written in that place.

There are other file types for which different things happen. When data is read or written to a device file, the request is handled by the driver for that device. Each device file has an associated number which identifies the driver to use. What the device does with the data is its own business. Block devices also called block special files usually behave a lot like ordinary files: they are an array of bytes, and the value that is read at a given location is the value that was last written there.

Data from block device can be cached in memory and read back from cache; writes can be buffered. Block devices are normally seekable i. Character devices also called character special files behave like pipes, serial ports, etc. Writing or reading to them is an immediate action. What the driver does with the data is its own business. Writing a byte to a character device might cause it to be displayed on screen, output on a serial port, converted into a sound, They point to a driver and can be created by [mknod][1].

Looking at its man page, it seems that block devices are buffered while character devices are unbuffered. Block devices have a "block size" that indicate the size of the blocks that are accessible. In ls -l show two comma-separated numbers for devices in the place where the size is normally found.

Those are the major and minor numbers, that point to the driver. Their type are also indicated as "c" or "b" in the permission column of the ls -l output. A device special file is an interface for a device driver that appears in a file system as if it were an ordinary file. Character-driven will send one character at the time, thus you need a small load to carry, but have to make many requests.

Analogy: Basically the same as buying soda by the bottle, or by the crate. Block-driven is useful when you know how much data you can expect, which is often the case with files on disk. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group.

Create a free Team What is Teams? Learn more. What are character special and block special files in a unix system? Asked 9 years ago. Active 4 years, 9 months ago. Viewed k times. Improve this question. Geek Geek 5, 13 13 gold badges 45 45 silver badges 65 65 bronze badges.

If you want to know how big a block is on your system, run " blockdev --getbsz device " as root , e. In this example, the block size is bytes 4 kibibytes. A character special file is similar to a block device, but data is written one character eight bits , or one byte at a time.

The type name, symbolic name, and bitmask for each Linux file type is listed below. In bash , the command " test -b file " returns an exit status of 0 if file is block special, or 1 if file is another type or does not exist. Inode , Operating system terms , Standard input stdin , Standard output stdout. Block special files Character special files Linux file types How can I tell if a file is special?



0コメント

  • 1000 / 1000