📄 readme
字号:
IDE Hard DiscsAll IDE discs are placed under /dev/ide/hd, using a similarconvention to SCSI discs. The following mappings exist between the newand the old names: /dev/hda /dev/ide/hd/c0b0t0u0 /dev/hdb /dev/ide/hd/c0b0t1u0 /dev/hdc /dev/ide/hd/c0b1t0u0 /dev/hdd /dev/ide/hd/c0b1t1u0IDE TapesA similar naming scheme is used as for IDE discs. The entries willappear in the /dev/ide/mt directory.IDE CD-ROMA similar naming scheme is used as for IDE discs. The entries willappear in the /dev/ide/cd directory.IDE FloppiesA similar naming scheme is used as for IDE discs. The entries willappear in the /dev/ide/fd directory.XT Hard DiscsAll XT discs are placed under /dev/xd. The first XT discwould appear as /dev/xd/c0t0.SCSI Host Probing IssuesDevfs allows you to identify SCSI discs based in part on SCSI hostnumbers. If you have only one SCSI host (card) in your computer, thenclearly it will be given host number 0. Life is not always that easyis you have multiple SCSI hosts. Unfortunately, it can sometimes bedifficult to guess what the probing order of SCSI hosts is. You needto know the probe order before you can use device names. To make thiseasy, there is a kernel boot parameter called "scsihosts". This allowsyou to specify the probe order for different types of SCSI hosts. Thesyntax of this parameter is:scsihosts=<name_1>:<name_2>:<name_3>:...:<name_n>where <name_1>,<name_2>,...,<name_n> are the namesof drivers used in the /proc filesystem. For example: scsihosts=aha1542:ppa:aha1542::ncr53c7xxmeans that devices connected to- first aha1542 controller - will be c0b#t#u#- first parallel port ZIP - will be c1b#t#u#- second aha1542 controller - will be c2b#t#u#- first NCR53C7xx controller - will be c4b#t#u#- any extra controller - will be c5b#t#u#, c6b#t#u#, etc- if any of above controllers will not be found - the reserved names will not be used by any other device.- c3b#t#u# names will never be usedYou can use ',' instead of ':' as the separator character if youwish. I have used the devfsd naming schemehere.Note that this scheme does not address the SCSI host order if you havemultiple cards of the same type (such as NCR53c8xx). In this case youneed to use the driver-specific boot parameters to control this.-----------------------------------------------------------------------------Device drivers currently ported- All miscellaneous character devices support devfs (this is done transparently through misc_register())- SCSI discs and generic hard discs- Character memory devices (null, zero, full and so on) Thanks to C. Scott Ananian <cananian@alumni.princeton.edu>- Loop devices (/dev/loop?) - TTY devices (console, serial ports, terminals and pseudo-terminals) Thanks to C. Scott Ananian <cananian@alumni.princeton.edu>- SCSI tapes (/dev/scsi and /dev/tapes)- SCSI CD-ROMs (/dev/scsi and /dev/cdroms)- SCSI generic devices (/dev/scsi)- RAMDISCS (/dev/ram?)- Meta Devices (/dev/md*)- Floppy discs (/dev/floppy)- Parallel port printers (/dev/printers)- Sound devices (/dev/sound) Thanks to Eric Dumas <dumas@linux.eu.org> and C. Scott Ananian <cananian@alumni.princeton.edu>- Joysticks (/dev/joysticks)- Sparc keyboard (/dev/kbd)- DSP56001 digital signal processor (/dev/dsp56k)- Apple Desktop Bus (/dev/adb)- Coda network file system (/dev/cfs*)- Virtual console capture devices (/dev/vcc) Thanks to Dennis Hou <smilax@mindmeld.yi.org>- Frame buffer devices (/dev/fb)- Video capture devices (/dev/v4l)-----------------------------------------------------------------------------Allocation of Device NumbersDevfs allows you to write a driver which doesn't need to allocate adevice number (major&minor numbers) for the internal operation of thekernel. However, there are a number of userspace programmes that usethe device number as a unique handle for a device. An example is thefind programme, which uses device numbers to determine whetheran inode is on a different filesystem than another inode. The devicenumber used is the one for the block device which a filesystem isusing. To preserve compatibility with userspace programmes, blockdevices using devfs need to have unique device numbers allocated tothem. Furthermore, POSIX specifies device numbers, so some kind ofdevice number needs to be presented to userspace.The simplest option (especially when porting drivers to devfs) is tokeep using the old major and minor numbers. Devfs will take whatevervalues are given for major&minor and pass them onto userspace.Alternatively, you can have devfs choose unique device numbers foryou. When you register a character or block device usingdevfs_register you can provide the optionalDEVFS_FL_AUTO_DEVNUM flag, which will then automatically allocate aunique device number (the allocation is separated for the characterand block devices).This device number is a 16 bit number, so this leaves plenty of spacefor large numbers of discs and partitions. This scheme can also beused for character devices, in particular the tty devices, which arecurrently limited to 256 pseudo-ttys (this limits the total number ofsimultaneous xterms and remote logins). Note that the device numberis limited to the range 36864-61439 (majors 144-239), in order toavoid any possible conflicts with existing official allocations.Please note that using dynamically allocated block device numbers maybreak the NFS daemons (both user and kernel mode), which expect dev_tfor a given device to be constant over the lifetime of remote mounts.A final note on this scheme: since it doesn't increase the size ofdevice numbers, there are no compatibility issues with userspace.-----------------------------------------------------------------------------Questions and AnswersMaking things workAlternatives to devfsMaking things workHere are some common questions and answers.Devfsd is not managing all my permissionsMake sure you are capturing the appropriate events. For example,device entries created by the kernel generate REGISTER events,but those created by devfsd generate CREATE events.Devfsd is not capturing all REGISTER eventsSee the previous entry: you may need to capture CREATE events.X will not startMake sure you followed the steps outlined above.Why don't my network devices appear in devfs?This is not a bug. Network devices have their own, completely separatenamespace. They are accessed via socket(2) andsetsockopt(2) calls, and thus require no device nodes. I haveraised the possibilty of moving network devices into the devicenamespace, but have had no response.Alternatives to devfsI've attempted to collate all the anti-devfs proposals and explaintheir limitations. Under construction.Why not just pass device create/remove events to a daemon?Here the suggestion is to develop an API in the kernel so that devicescan register create and remove events, and a daemon listens for thoseevents. The daemon would then populate/depopulate /dev (whichresides on disc).This has several limitations:it only works for modules loaded and unloaded (or devices insertedand removed) after the kernel has finished booting. Without a databaseof events, there is no way the daemon could fully populate/devif you add a database to this scheme, the question is then how topresent that database to user-space. If you make it a list of stringswith embedded event codes which are passed through a pipe to thedaemon, then this is only of use to the daemon. I would argue that thenatural way to present this data is via a filesystem (since many ofthe events will be of a hierarchical nature), such as devfs.Presenting the data as a filesystem makes it easy for the user to seewhat is available and also makes it easy to write scripts to scan the"database"the tight binding between device nodes and drivers is no longerpossible (requiring the otherwise perfectly avoidabletable lookups)you cannot catch inode lookup events on /dev which meansthat module autoloading requires device nodes to be created. This is aproblem, particularly for drivers where only a few inodes are createdfrom a potentially large setthis technique can't be used when the root FS is mountedread-onlyJust implement a better scsidevThis suggestion involves taking the scsidev programme andextending it to scan for all devices, not just SCSI devices. Thescsidev programme works by scanning /proc/scsiProblems:the kernel does not currently provide a list of all devicesavailable. Not all drivers register entries in /proc orgenerate kernel messagesthere is no uniform mechanism to register devices other than thedevfs APIimplementing such an API is then the same as theproposal abovePut /dev on a ramdiscThis suggestion involves creating a ramdisc and populating it withdevice nodes and then mounting it over /dev.Problems:this doesn't help when mounting the root filesystem, since youstill need a device node to do thatif you want to use this technique for the root device node aswell, you need to use initrd. This complicates the booting sequenceand makes it significantly harder to administer and configure. Theinitrd is essentially opaque, robbing the system administrator of easyconfigurationinsufficient information is available to correctly populate theramdisc. So we come back to theproposal above to "solve" thisa ramdisc-based solution would take more kernel memory, since thebacking store would be (at best) normal VFS inodes and dentries, whichtake 284 bytes and 112 bytes, respectively, for each entry. Comparethat to 72 bytes for devfsDo nothing: there's no problemSometimes people can be heard to claim that the existing scheme isfine. This is what they're ignoring:device number size (8 bits each for major and minor) is a reallimitation, and must be fixed somehow. Systems with large numbers ofSCSI devices, for example, will continue to consume the remainingunallocated major numbers. USB will also need to push beyond the 8 bitminor limitationsimplying increasing the device number size is insufficient. Apartfrom causing a lot of pain, it doesn't solve the management issuesof a /dev with thousands or more device nodesignoring the problem of a huge /dev will not make it goaway, and dismisses the legitimacy of a large number of people whowant a dynamic /devthe standard response then becomes: "write a device managementdaemon", which brings us back to theproposal above-----------------------------------------------------------------------------Other resourcesDouglas Gilbert has written a useful document athttp://www.torque.net/sg/devfs_scsi.html whichexplores the SCSI subsystem and how it interacts with devfsDouglas Gilbert has written another useful document athttp://www.torque.net/scsi/scsihosts.html whichdiscusses the scsihosts= boot optionDouglas Gilbert has written yet another useful document athttp://www.torque.net/scsi/linux_scsi_24/ whichdiscusses the Linux SCSI subsystem in 2.4.Johannes Erdfelt has started a discussion paper on Linux andhot-swap devices, describing what the requirements are for a scalablesolution and how and why he's used devfs+devfsd. Note that this is anearly draft only, available in plain text form at:http://johannes.erdfelt.com/hotswap.txt.Johannes has promised a HTML version will follow.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -