In Unix-likeoperating systems, a device file, device node, or special file is an interface to a device driver that appears in a file system as if it were an ordinary file. There are also special files in DOS, OS/2, and Windows. These special files allow an application program to interact with a device by using its device driver via standard input/outputsystem calls. Using standard system calls simplifies many programming tasks, and leads to consistent user-space I/O mechanisms regardless of device features and functions.
Overview
Device files usually provide simple interfaces to standard devices (such as printers and serial ports), but can also be used to access specific unique resources on those devices, such as disk partitions. Additionally, device files are useful for accessing system resources that have no connection with any actual device, such as data sinks and random number generators.
There are two general kinds of device files in Unix-like operating systems, known as character special files and block special files. The difference between them lies in how much data is read and written by the operating system and hardware. These together can be called device special files in contrast to named pipes, which are not connected to a device but are not ordinary files either.
MS-DOS borrowed the concept of special files from Unix but renamed them devices.[1] Because early versions of MS-DOS did not support a directory hierarchy, devices were distinguished from regular files by making their names reserved words that cannot be used as folder or file names; for example: the word CON is a reserved word. These were chosen for a degree of compatibility with CP/M and are still present in modern Windows for backwards compatibility. Names are not case-sensitive, so "con", "Con", and "CON" are all invalid names.
In Windows XP, entering "Con" into the Run command returns the error message, "This file does not have a program associated with it for performing this action. Create an association in the Folder Options control panel." Attempting to rename any file or folder using a reserved name silently reverts the object to its previous name (or "New Folder", "New Text Document", etc.), with no notification or error message.[2] In Windows Vista and later, attempting to use a reserved name for a file or folder brings up an error message saying, "The specified device name is invalid."[2]
In some Unix-like systems, most device files are managed as part of a virtual file system traditionally mounted at /dev, possibly associated with a controlling daemon, which monitors hardware addition and removal at run time, making corresponding changes to the device file system if that's not automatically done by the kernel, and possibly invoking scripts in system or user space to handle special device needs. The FreeBSD, DragonFly BSD and Darwin have a dedicated file system devfs; device nodes are managed automatically by this file system, in kernel space. Linux used to have a similar devfs implementation, but it was abandoned later, and then removed since version 2.6.17;[3] Linux now primarily uses a user space implementation known as udev, but there are many variants.
In Unix systems which support chroot process isolation, such as Solaris Containers, typically each chroot environment needs its own /dev; these mount points will be visible on the host OS at various nodes in the global file system tree. By restricting the device nodes populated into chroot instances of /dev, hardware isolation can be enforced by the chroot environment (a program can not meddle with hardware that it can neither see nor name—an even stronger form of access control than Unix file system permissions).
MS-DOS managed hardware device contention (see terminate-and-stay-resident program) by making each device file exclusive open. An application attempting to access a device already in use would discover itself unable to open the device file node. A variety of device driver semantics are implemented in Unix and Linux concerning concurrent access.[4]
Unix and Unix-like systems
Device nodes correspond to resources that an operating system's kernel has already allocated. Unix identifies those resources by a major number and a minor number,[5] both stored as part of the structure of a node. The assignment of these numbers occurs uniquely in different operating systems and on different computer platforms. Generally, the major number identifies the device driver and the minor number identifies a particular device (possibly out of many) that the driver controls:[6] in this case, the system may pass the minor number to a driver. However, in the presence of dynamic number allocation, this may not be the case (e.g. on FreeBSD 5 and up).
As with other special file types, the computer system accesses device nodes using standard system calls and treats them like regular computer files. Two standard types of device files exist; unfortunately their names are rather counter-intuitive for historical reasons, and explanations of the difference between the two are often incorrect as a result.
Character devices
Character special files or character devices provide unbuffered, direct access to the hardware device. They do not necessarily allow programs to read or write single characters at a time; that is up to the device in question. The character device for a hard disk, for example, will normally require that all reads and writes be aligned to block boundaries and most certainly will not allow reading a single byte.
Character devices are sometimes known as raw devices to avoid the confusion surrounding the fact that a character device for a piece of block-based hardware will typically require programs to read and write aligned blocks.
Block devices
Block special files or block devices provide buffered access to hardware devices, and provide some abstraction from their specifics.[7] Unlike character devices, block devices will always allow the programmer to read or write a block of any size (including single characters/bytes) and any alignment. The downside is that because block devices are buffered, the programmer does not know how long it will take before written data is passed from the kernel's buffers to the actual device, or indeed in what order two separate writes will arrive at the physical device. Additionally, if the same hardware exposes both character and block devices, there is a risk of data corruption due to clients using the character device being unaware of changes made in the buffers of the block device.
Most systems create both block and character devices to represent hardware like hard disks. FreeBSD and Linux notably do not; the former has removed support for block devices,[8] while the latter creates only block devices. To get the effect of a character device from a block device on Linux, one must open the device with the Linux-specific O_DIRECT flag.
Pseudo-devices
Device nodes on Unix-like systems do not necessarily have to correspond to physical devices. Nodes that lack this correspondence are called pseudo-devices. They provide various functions handled by the operating system. Some of the most commonly used (character-based) pseudo-devices include:
/dev/null – accepts and discards all input written to it; provides an end-of-file indication when read from.
/dev/zero – accepts and discards all input written to it; produces a continuous stream of null characters (zero-value bytes) as output when read from.
/dev/full – produces a continuous stream of null characters (zero-value bytes) as output when read from, and generates an ENOSPC ("disk full") error when attempting to write to it.
Nodes are created by the mknodsystem call. The command-line program for creating nodes is also called mknod. Nodes can be moved or deleted by the usual filesystem system calls (rename, unlink) and commands (mv, rm).
Some Unix versions include a script named makedev or MAKEDEV to create all necessary devices in the directory /dev. It only makes sense on systems whose devices are statically assigned major numbers (e.g., by means of hardcoding it in their kernel module).
Some other Unix systems such as FreeBSD use kernel-based device node management via devfs only and do not support manual node creation. mknod(2) system call and mknod(8) command exist to keep compatibility with POSIX, but manually created device nodes outside devfs will not function at all.[10]
Naming conventions
The following prefixes are used for the names of some devices in the /dev hierarchy, to identify the type of device:
The canonical list of the prefixes used in Linux can be found in the Linux Device List, the official registry of allocated device numbers and /dev directory nodes for the Linux operating system.[11]
For most devices, this prefix is followed by a number uniquely identifying the particular device. For hard drives, a letter is used to identify devices and is followed by a number to identify partitions. Thus a file system may "know" an area on a disk as /dev/sda3, for example, or "see" a networked terminal session as associated with /dev/pts/14.
On disks using the typical PC master boot record, the device numbers of primary and the optional extended partition are numbered 1 through 4, while the indexes of any logical partitions are 5 and onwards, regardless of the layout of the former partitions (their parent extended partition does not need to be the fourth partition on the disk, nor do all four primary partitions have to exist).
Device names are usually not portable between different Unix-like system variants, for example, on some BSD systems, the IDE devices are named /dev/wd0, /dev/wd1, etc.
devfs
devfs is a specific implementation of a device file system on Unix-like operating systems, used for presenting device files. The underlying mechanism of implementation may vary, depending on the OS.
Maintaining these special files on a physically-implemented file system such as a hard drive is inconvenient, and as it needs kernel assistance anyway, the idea arose of a special-purpose logical file system that is not physically stored.
Defining when devices are ready to appear is not trivial. The devfs approach is for the device driver to request creation and deletion of devfs entries related to the devices it enables and disables.
PC DOS, TOS, OS/2, and Windows
A device file is a reserved keyword used in PC DOS, TOS, OS/2, and Windows systems to allow access to certain ports and devices.
MS-DOS borrowed the concept of special files from Unix but renamed them devices.[1] Because early versions of MS-DOS did not support a directory hierarchy, devices were distinguished from regular files by making their names reserved words. This means that certain file names were reserved for devices, and should not be used to name new files or directories.[12]
The reserved names themselves were chosen to be compatible with "special files" handling of PIP command in CP/M. There were two kinds of devices in DOS: Block Devices (used for disk drives) and Character Devices (generally all other devices, including COM and PRN devices).[13]
DOS uses device files for accessing printers and ports. Most versions of Windows also contain this support, which can cause confusion when trying to make files and folders of certain names, as they cannot have these names.[14] Versions 2.x of MS-DOS provide the AVAILDEVCONFIG.SYS parameter that, if set to FALSE, makes these special names only active if prefixed with \DEV\, thus allowing ordinary files to be created with these names.[15]
GEMDOS, the DOS-like part of Atari TOS, supported similar device names to DOS, but unlike DOS it required a trailing ":" character (on DOS, this is optional) to identify them as devices as opposed to normal filenames (thus "CON:" would work on both DOS and TOS, but "CON" would name an ordinary file on TOS but the console device on DOS). In MiNT and MagiC, a special UNIX-like unified filesystem view accessed via the "U:" drive letter also placed device files in "U:\DEV".
Using shell redirection and pipes, data can be sent to or received from a device. For example, typing the following will send the file c:\data.txt to the printer:
TYPE c:\data.txt > PRN
PIPE, MAILSLOT, and MUP are other standard Windows devices.[21]
IOCS
The 8-bit operating system of Sharppocket computers like the PC-E500, PC-E500S etc. consists of a BASIC interpreter, a DOS 2-like File Control System (FCS) implementing a rudimentary 12-bit FAT-like filesystem, and a BIOS-like Input/Output Control System (IOCS) implementing a number of standard character and block device drivers as well as special file devices including STDO:/SCRN: (display), STDI:/KYBD: (keyboard), COM: (serial I/O), STDL:/PRN: (printer), CAS: (cassette tape), E:/F:/G: (memory file), S1:/S2:/S3: (memory card), X:/Y: (floppy), SYSTM: (system), and NIL: (function).[22]
Implemented fully in the kernel, with optional daemon devfsd to handle device node events in user space.[24] Obsolete – users are encouraged to migrate to udev and/or devtmpfs.
Implemented largely in user space, device information is gathered from sysfs. Device files can be stored on a conventional general-purpose file system, or in a memory file system (tmpfs).
DeviceFS was started in 1991[27] and first appeared in RISC OS 3. It manages several device like special files, most commonly: Parallel, Serial, FastParallel, and USB. The SystemDevices module implements the pseudo devices such as: Vdu, Kbd, Null and Printer.
As implemented in the kernel, character devices appear in the virtual \DEV directory and any disk directory. Under MS-DOS/PC DOS 2.x, the CONFIG.SYSAVAILDEV=FALSE directive can be used to force devices to exist only in \DEV.
The \\.\ prefix makes supporting APIs access the Win32 device namespace instead of the Win32 file namespace. The Win32 device names are symbolic links to device names under Windows NT \Device directory.
^Corbet, Jonathan; Kroah-Hartman, Greg; Rubini, Alessandro (2005). "Access Control on a Device File". Linux Device Drivers, 3rd Edition. O'Reilly. Retrieved 2017-04-28. The next step beyond a single-open device is to let a single user open a device in multiple processes but allow only one user to have the device open at a time.
^Gooch, Richard. "My Linux Contributions". Retrieved 2021-06-13. Devfsd provides configurable management of device nodes using the Linux Device Filesystem.
Penyuntingan Artikel oleh pengguna baru atau anonim untuk saat ini tidak diizinkan.Lihat kebijakan pelindungan dan log pelindungan untuk informasi selengkapnya. Jika Anda tidak dapat menyunting Artikel ini dan Anda ingin melakukannya, Anda dapat memohon permintaan penyuntingan, diskusikan perubahan yang ingin dilakukan di halaman pembicaraan, memohon untuk melepaskan pelindungan, masuk, atau buatlah sebuah akun. Billie EilishEilish pada saat sedang tampil di konser pada tahun 2022 di The O2 A...
Institute of tertiary education in Windhoek, Namibia Namibia University of Science and TechnologyOther nameNUSTMotto in EnglishTechnology and developmentTypePublic universityEstablished1994ChancellorPeter KatjaviviVice-ChancellorErold NaomabAcademic staff≥300[1]Administrative staff670 (including faculty)[2]Students10,500[3]LocationWindhoek, Khomas Region, NamibiaWebsitewww.nust.na The Namibia University of Science and Technology (NUST), formerly known as Polytec...
Untuk pesepak bola Australia, lihat Paul Dooley (pesepak bola). Paul DooleyDooley pada 2010LahirPaul Lee Brown22 Februari 1928 (umur 96)Parkersburg, West Virginia, Amerika SerikatAlmamaterUniversitas Virginia BaratPekerjaanPemeranpenulispelawakTahun aktifPanggung 1950an–Film 1964-kiniSuami/istriDonna Lee Wasser (m. 1958–?; bercerai)Winnie Holzman (m. 1984)Anak4; termasuk Savannah Dooley Paul Dooley (nama lahir Paul Lee Brown; lahir 22 Februari 1928...
نادي الهلالموسم 2012–13الرئيس الأمير عبد الرحمن بن مساعدالمدير الفني أنطوان كومباريه(حتى 31 يناير 2013) زلاتكو داليتش(من 1 فبراير 2013)الملعبملعب الملك فهد الدوليملعب الأمير فيصل بن فهددوري المحترفين السعوديالمركز الثانيكأس ولي العهد السعوديبطل الكأس اللقب الثاني عشركأس خادم ا...
Santiago Arias Arias with Atlético Madrid in 2019Informasi pribadiNama lengkap Santiago Arias Naranjo[1]Tanggal lahir 13 Januari 1992 (umur 32)[2]Tempat lahir Medellín, ColombiaTinggi 178 m (584 ft 0 in)[3]Posisi bermain Right-backInformasi klubKlub saat ini FC CincinnatiKarier junior La EquidadKarier senior*Tahun Tim Tampil (Gol)2009–2011 La Equidad 27 (0)2011–2013 Sporting CP 7 (0)2012–2013 Sporting CP B 28 (1)2013–2014 Jong PSV 2 (0)20...
French cyclist Mickaël BourgainPersonal informationFull nameMickaël BourgainBorn (1980-05-28) 28 May 1980 (age 43)Boulogne-sur-Mer, FranceTeam informationDisciplineTrackRoleRiderRider typeSprinterProfessional team1999-2009Cofidis Major winsTeam sprint world champion (2004, 2006, 2007 and 2009) Medal record Representing France Men's track cycling Olympic Games 2004 Athens Team Sprint 2008 Beijing Sprint World Championships 2004 Melbourne Team Sprint 2006 Bordeaux Team Sp...
Roman music redirects here. For music associated with the modern city of Rome, see Music in Rome. Trio of musicians playing an aulos, cymbala, and tympanum (mosaic from Pompeii) Masked theatrical troupe around an aulos player (mosaic from the House of the Tragic Poet, Pompeii) The music of ancient Rome was a part of Roman culture from the earliest of times. Songs (carmen) were an integral part of almost every social occasion.[1] The Secular Ode of Horace, for instance, was commission...
Saptahik BartamanCompanyBartaman Pvt. Ltd.WebsiteOfficial website Saptahik Bartaman is a Bengali language weekly magazine published by Bartaman Pvt. Ltd. (the publisher of the newspaper Bartaman) from Kolkata, India. It had a circulation of 1,48,378, in January–June, 2011.[1] References ^ Breakup of circulation figures – town wise, district wise, state wise for the audit period January – June 2011 (XLS). India: Audit Bureau of Circulations. Retrieved 8 December 2011. ...
Mean position of all the points in a shape This article includes a list of general references, but it lacks sufficient corresponding inline citations. Please help to improve this article by introducing more precise citations. (April 2013) (Learn how and when to remove this message) Centroid of a triangle In mathematics and physics, the centroid, also known as geometric center or center of figure, of a plane figure or solid figure is the arithmetic mean position of all the points in the surfac...
Baby daughter of Nero and Poppaea Sabina Claudia AugustaAugustaCLAVDIAStatue believed to possibly depict an older idealized Claudia.BornClaudiaCitizenshipRomanEraNeronianKnown forDaughter of Roman emperor NeroParentsNero (father)Poppaea Sabina (mother)FamilyJulio-ClaudianHonoursAugusta Claudia Augusta (Classical Latin: [ˈklau̯dɪ.a]; January 63 – May 63) was the only daughter[1] of the Roman Emperor Nero and his second wife, the Roman Empress Poppaea Sabina. Claudia a...
Dongola Kunoدنقلا العجوزGereja di Dongola KunoLokasiNegara Bagian Utara, SudanWilayahNubiaKoordinat18°13′N 30°45′E / 18.217°N 30.750°E / 18.217; 30.750JenisPermukimanCatatan situsKondisiReruntuhan Dongola Kuno (bahasa Nubia Kuno: Tungul; bahasa Arab: دنقلا العجوز, Dunqulā al-ʿAjūz) adalah sebuah kota yang telah ditinggalkan oleh penduduknya yang terletak di tepi timur Sungai Nil di hadapan Wadi Howar di Sudan. Kota ini merupakan kot...
2002 single by Do As InfinityUnder the Sun / Under the MoonSingle by Do As Infinityfrom the album True Song and Do the A-side ReleasedJuly 31, 2002GenreJ-popLength17:07LabelAvex TraxSongwriter(s)Dai NagaoProducer(s)Dai Nagao, Seiji KamedaDo As Infinity singles chronology Hi no Ataru Sakamichi (2002) Under the Sun / Under the Moon (2002) Shinjitsu no Uta (2002) Under the Sun and Under the Moon are songs on the double-A side thirteenth single by Do As Infinity, released in 2002. The second A-si...
Title for Jesus This article is about the Christian theological concept. For the Latin liturgical prayer, see Agnus Dei. For other uses, see Lamb of God (disambiguation). Agnus Dei c. 1635–1640, by Francisco de Zurbarán, Prado MuseumLamb of God (Greek: Ἀμνὸς τοῦ Θεοῦ, romanized: Amnòs toû Theoû; Latin: Agnus Dei, Ecclesiastical Latin: [ˈaɲ.ɲus ˈde.i]) is a title for Jesus that appears in the Gospel of John. It appears at John 1:29, where John the B...
Competition between nations to gain competitive advantage by manipulating monetary supplyBrazilian Finance Minister Guido Mantega, who made headlines when he raised the alarm about a currency war in September 2010 Currency war, also known as competitive devaluations, is a condition in international affairs where countries seek to gain a trade advantage over other countries by causing the exchange rate of their currency to fall in relation to other currencies. As the exchange rate of a countr...
Pour les articles homonymes, voir San Gabriel. Cet article est une ébauche concernant la montagne. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Monts San Gabriel Le bassin de Los Angeles Géographie Altitude 3 068 m, Mont San Antonio (en) Massif Transverse Ranges(Chaînes côtières du Pacifique) Administration Pays États-Unis État Californie modifier Les monts San Gabriel sont situés...
Cet article est une ébauche concernant le chemin de fer et le Canada. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Pour les articles homonymes, voir Thornton. Henry Worth Thornton Portrait en 1915. Données clés Naissance 6 novembre 1871 Logansport Décès 14 mars 1933 (à 61 ans) New York Profession Dirigeant d'entreprise Activité principale Chemin de fer modifier Henry Worth Thornton (1871-1933), es...
Governmental subdivision in France Map of the prefectures in France with their INSEE number In France, a prefecture (French: préfecture, pronounced [pʁefɛktyʁ] ⓘ) may be:[1][2] the chef-lieu de département, the commune in which the administration of a department is located; the chef-lieu de région, the commune in which the administration of a region is located; the jurisdiction of a prefecture; the official residence or headquarters of a prefect. Although the a...