⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dev.4

📁 操作系统设计与实现源码
💻 4
字号:
.TH DEV 4.SH NAMEdev \- device files in /dev.SH DESCRIPTIONDevice files are the eyes and ears of the system.  Through the device filesone has access to the disks, terminals and other parts of the machine.Single bytes or disk blocks may be transferred to or from a device withordinary.BR read (2)or.BR write (2)calls, byte positions set with.BR lseek (2),or more complicated control functions performed with.BR ioctl(2)..PPDevice files as found in.B /devhave several attributes that must be considered.  Here are two examples as.B "ls \-l"shows them:.PP.RS.nf.if t .ft Cbrw-rw-rw-  1 root     operator   2,   1 Jun 10  1995 fd1crw--w----  1 kjb      tty        4,   0 May 11 09:41 console.if t .ft P.fi.RE.PPMost attributes are the same as for a regular file and have the samefunction.  The file type and the major and minor device numbers are specialto devices..PPCharacter devices are marked with a.B cas a file type letter.  Any I/O on a character device is sent down to thedevice driver without any interpretation.  This means that a process doingthe I/O must know the characteristics of the device and deal with themappropriately..PPBlock devices provoke the file system server into buffering the data onthose devices.  Data read or written by processes is passed through the filesystem block cache.  Unaligned bytes read or written are extracted orreassembled by the file server from or to whole blocks in the cache.  Thefile server transfers data to or from the device driver as blocks topositions at block size boundaries.  These blocks are Minix blocks of 1024bytes, disk devices usually have a 512 byte block size.  Only block devicescan be mounted as part of the file system tree if they contain a Minix filesystem..PPThe major device number (2 for.B fd1and 4 for.BR console )are used by FS to find the device driver that manages a device.  The minordevice number (1 for.B fd1and 0 for.BR console )is passed to the driver to select a device among a number of related devicesthat are all managed by that driver.  The device drivers are usually kerneltasks under Minix, small processes that are contained within the addressspace of the kernel.  The following tasks and associated devices exist:.SS "Memory (major 1)"The.BR ram ,.BR mem ,.BR kmem ,and.BR nulldevices are managed by the memory task.The.B ramdevice is a block device for a chunk of memory that is the RAM disk.  Anybyte read from or written to the.B ramdevice is copied from or to that memory chunk.The.B memdevice is a character device for the entire address space of the system, but.B kmemonly for the kernel data area.  These two devices allow programs like.BR ps (1)to hunt around the system looking for interesting bits.The.B nulldevice is a data sink.  It happily swallows any bytes written to it, andreturns nothing on a read..SS "Floppy disk (major 2)"The.BR fd0 ,.BR fd0a ,.BR fd0b ,.BR fd0c ,and.BR fd0dblock devices are the first floppy disk and the four partitions that mayexist on a that floppy disk.  Likewise are.BR fd1and.BR fd1[a\-d]the device and partitions for the second floppy disk.  The floppy diskdevices are described in detail in.BR fd (4).Partitioning in general is explained in.BR hd (4)..SS "Hard disk (major 3)"The first hard disk can be accessed by block device.BR hd0 .This device addresses the entire hard disk from the first to the lastsector.  A hard disk is normally partitioned in up to four primarypartitions,.BR hd1 ,.BR hd2 ,.BR hd3 ,and.BR hd4 .Each of these devices accesses a range of sectors on the.B hd0device.  It is customary to give each operating system on a disk a primarypartition.  So the MS-DOS C: "drive" can be on.BR hd1 ,and Minix can be on.BR hd2 .Minix wants to have several partitions on its own, so.B hd2can be further subdivided into the subpartitions.BR hd2a ,.BR hd2b ,.BR hd2c ,and.BR hd2d ..B /devcontains devices for the first and second hard disk.RB ( hd0and.BR hd5 )their primary partitions.RB ( hd[1\-46\-9] )and subpartitions thereof.RB ( hd[1\-46\-9][a\-d] ).More detail can be found in.BR hd (4)..SS "Terminals (minor 4)"The TTY driver manages the system console device, aptly named.BR console ,the serial lines,.BR tty00and.BR tty01 ,and the pseudo ttys.Through the console device one can display characters on a screen attachedto a monochrome, Hercules, color, or VGA adapter.  The.BR ttyc1 ,.BR ttyc2 ,etc. devices are the so-called "virtual consoles" that share the oneconsole display.  One can select which virtual console is to be visible onthe screen and take input from the keyboard.To allow remote login the devices with minor numbers of 128 or higher offervirtual terminals.  These pseudo ttys come in tty, pty pairs that form apipe between processes running under the tty, and a controlling processattached to the pty side.See also.BR console (4),and.BR tty (4)..SS "Anonymous TTY (major 5)"This is just one device named.BR ttythat is a synonym for the controlling tty of a process.  This device is notmanaged by any device driver, but is handled by FS itself.  A process canget access to the terminal it is running under by using.BR /dev/tty ..SS "Line printer (major 6)"The.B lpdevice sends any bytes written to it to the printer..SS "TCP/IP (major 7)"The TCP/IP task is not a kernel task, but a server like MM and FS.  It sitsbetween FS and the DP8390 task that manages the ethernet boards.  Togetherthey implement the TCP/IP protocol.  See also.BR ip (4)..SS "CD-ROM (major 8)"This is the CD-ROM driver for the Mitsumi proprietary CD-ROM interface.  The.BR cd0device addresses the whole CD, with extra.BR cd[1\-4]and.BR cd[1\-4][a\-d]devices for if the CD also contains partitions with Minix file systems..SS "SCSI disks and tapes (major 10)"The.B sd*devices are disks in the same way as the.B hd*devices.  Except that these disks are SCSI disks attached to an Adaptec1540 controller or compatible.  The driver also manages the.B rst*and.B nrst*tape devices (rewinding or non-rewinding).  See.BR sd (4)..SS "Audio (major 13)"The.B audiodevice can be used to produce or record air vibrations using a Soundblaster16 type audio card.  See.BR audio (4)..SS "Mixer (major 14)"The.B mixerdevice is used to control the audio driver..SH FILES.TP 10.B /dev/*All Minix devices.SH "SEE ALSO".BR read (2),.BR write (2),.BR lseek (2),.BR ioctl (2),.BR console (4),.BR fd (4),.BR hd (4),.BR ip (4),.BR sd (4),.BR tty (4),.BR MAKEDEV (8)..SH DIAGNOSTICSThere are five prominent errors that processes accessing device files mayprovoke:.IP "ENODEV \- No such device" 5There is no driver managing the device class this device belongs to.  Eitherthe driver is configured out, or it is not loaded (inet)..IP "ENXIO \- No such device or address"This device is not available.  Either the driver does not support it at all,or the hardware isn't available, i.e. accessing the second disk on a systemwith only one disk..IP "EACCES \- Permission denied"This error may cause a lot of head scratching if.B ls \-lshows a device file to be writable.  The media you are trying to access issimply physically write protected!.IP "EINVAL \- Invalid argument"Devices may not like reads or writes that are not block multiples, or verybig transfers, etc.  The device manual page should list the limits..IP "EIO \- I/O error"This may be a real I/O error, i.e. a read or write on the device failing dueto a media error.  But it may also be the result of an operation that adevice can't do, or an empty tape drive, etc..SH NOTESSome devices are not present by default.  The.BR MAKEDEVscript knows how to make them..SS "MS-DOS equivalents"The names of MS-DOS devices map to Minix devices as follows:.PP.RS.nf.ta +10n +16nA:	fd0B:	fd1C:	hd1, sd1	(usually the first partition)D:	hd6, sd1, sd6	(or an extended partition)CON	consoleCOM1	tty00	(UNIX counts from 0)LPT1	lp.fi.RE.SH AUTHORKees J. Bot (kjb@cs.vu.nl)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -