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

📄 readme

📁 linux-2.6.15.6
💻
📖 第 1 页 / 共 5 页
字号:
Now you may feel like changing the configuration (common targets are/etc/fstab and /etc/devfsd.conf). Since you have asystem that works, if you make any changes and it doesn't work, younow know that you only have to restore your configuration files to thedefault and it will work again.Permissions persistence across rebootsIf you don't use mknod(2) to create a device file, nor use chmod(2) orchown(2) to change the ownerships/permissions, the inode ctime willremain at 0 (the epoch, 12 am, 1-JAN-1970, GMT). Anything with a ctimelater than this has had it's ownership/permissions changed. Hence, asimple script or programme may be used to tar up all changed inodes,prior to shutdown. Although effective, many consider this approach akludge.A much better approach is to use devfsd to save and restorepermissions. It may be configured to record changes in permissions andwill save them in a database (in fact a directory tree), and restorethese upon boot. This is an efficient method and results in immediatesaving of current permissions (unlike the tar approach, which savespermissions at some unspecified future time).The default configuration file supplied with devfsd has config entrieswhich you may uncomment to enable persistence management.If you decide to use the tar approach anyway, be aware that tar willfirst unlink(2) an inode before creating a new device node. Theunlink(2) has the effect of breaking the connection between a devfsentry and the device driver. If you use the "devfs=only" boot option,you lose access to the device driver, requiring you to reload themodule. I consider this a bug in tar (there is no real need tounlink(2) the inode first).Alternatively, you can use devfsd to provide more sophisticatedmanagement of device permissions. You can use devfsd to storepermissions for whole groups of devices with a single configurationentry, rather than the conventional single entry per device entry.Permissions database stored in mounted-over /devIf you wish to save and restore your device permissions into thedisc-based /dev while still mounting devfs onto /devyou may do so. This requires a 2.4.x kernel (in fact, 2.3.99 orlater), which has the VFS binding facility. You need to do thefollowing to set this up:make sure the kernel does not mount devfs at boot timemake sure you have a correct /dev/console entry in yourroot file-system (where your disc-based /dev lives)create the /dev-state directoryadd the following lines near the very beginning of your bootscripts:mount --bind /dev /dev-statemount -t devfs none /devdevfsd /devadd the following lines to your /etc/devfsd.conf file:REGISTER	^pt[sy]		IGNORECREATE		^pt[sy]		IGNORECHANGE		^pt[sy]		IGNOREDELETE		^pt[sy]		IGNOREREGISTER	.*		COPY	/dev-state/$devname $devpathCREATE		.*		COPY	$devpath /dev-state/$devnameCHANGE		.*		COPY	$devpath /dev-state/$devnameDELETE		.*		CFUNCTION GLOBAL unlink /dev-state/$devnameRESTORE		/dev-stateNote that the sample devfsd.conf file contains these lines,as well as other sample configurations you may find useful. See thedevfsd distributionreboot.Permissions database stored in normal directoryIf you are using an older kernel which doesn't support VFS binding,then you won't be able to have the permissions database in amounted-over /dev. However, you can still use a regulardirectory to store the database. The sample /etc/devfsd.conffile above may still be used. You will need to create the/dev-state directory prior to installing devfsd. If you haveold permissions in /dev, then just copy (or move) the devicenodes over to the new directory.Which method is better?The best method is to have the permissions database stored in themounted-over /dev. This is because you will not need to copydevice nodes over to /dev-state, and because it allows you toswitch between devfs and non-devfs kernels, without requiring you tocopy permissions between /dev-state (for devfs) and/dev (for non-devfs).Dealing with drivers without devfs supportCurrently, not all device drivers in the kernel have been modified touse devfs. Device drivers which do not yet have devfs support will notautomagically appear in devfs. The simplest way to create device nodesfor these drivers is to unpack a tarfile containing the requireddevice nodes. You can do this in your boot scripts. All your driverswill now work as before.Hopefully for most people devfs will have enough support so that theycan mount devfs directly over /dev without losing most functionality(i.e. losing access to various devices). As of 22-JAN-1998 (devfspatch version 10) I am now running this way. All the devices I haveare available in devfs, so I don't lose anything.WARNING: if your configuration requires the old-style device names(i.e. /dev/hda1 or /dev/sda1), you must install devfsd and configureit to maintain compatibility entries. It is almost certain that youwill require this. Note that the kernel creates a compatibility entryfor the root device, so you don't need initrd.Note that you no longer need to mount devpts if you use Unix98 PTYs,as devfs can manage /dev/pts itself. This saves you some RAM, as youdon't need to compile and install devpts. Note that some versions ofglibc have a bug with Unix98 pty handling on devfs systems. Contactthe glibc maintainers for a fix. Glibc 2.1.3 has the fix.Note also that apart from editing /etc/fstab, other things will needto be changed if you *don't* install devfsd. Some software (like the Xserver) hard-wire device names in their source. It really is mucheasier to install devfsd so that compatibility entries are created.You can then slowly migrate your system to using the new device names(for example, by starting with /etc/fstab), and then limiting thecompatibility entries that devfsd creates.IF YOU CONFIGURE TO MOUNT DEVFS AT BOOT, MAKE SURE YOU INSTALL DEVFSDBEFORE YOU BOOT A DEVFS-ENABLED KERNEL!Now that devfs has gone into the 2.3.46 kernel, I'm getting a lot ofreports back. Many of these are because people are trying to runwithout devfsd, and hence some things break. Please just run devfsd ifthings break. I want to concentrate on real bugs rather thanmisconfiguration problems at the moment. If people are willing to fixbugs/false assumptions in other code (i.e. glibc, X server) and submitthat to the respective maintainers, that would be great.All the way with DevfsThe devfs kernel patch creates a rationalised device tree. As statedabove, if you want to keep using the old /dev naming scheme,you just need to configure devfsd appopriately (see the manpage). People who prefer the old names can ignore this section. Forthose of us who like the rationalised names and an uncluttered/dev, read on.If you don't run devfsd, or don't enable compatibility entrymanagement, then you will have to configure your system to use the newnames. For example, you will then need to edit your/etc/fstab to use the new disc naming scheme. If you want tobe able to boot non-devfs kernels, you will need compatibilitysymlinks in the underlying disc-based /dev pointing back tothe old-style names for when you boot a kernel without devfs.You can selectively decide which devices you want compatibilityentries for. For example, you may only want compatibility entries forBSD pseudo-terminal devices (otherwise you'll have to patch you Clibrary or use Unix98 ptys instead). It's just a matter of putting inthe correct regular expression into /dev/devfsd.conf.There are other choices of naming schemes that you may prefer. Forexample, I don't use the kernel-suppliednames, because they are too verbose. A common misconception isthat the kernel-supplied names are meant to be used directly inconfiguration files. This is not the case. They are designed toreflect the layout of the devices attached and to provide easyclassification.If you like the kernel-supplied names, that's fine. If you don't thenyou should be using devfsd to construct a namespace more to yourliking. Devfsd has built-in code to construct anamespace that is both logical and easy tomanage. In essence, it creates a convenient abbreviation of thekernel-supplied namespace.You are of course free to build your own namespace. Devfsd has all theinfrastructure required to make this easy for you. All you need do iswrite a script. You can even write some C code and devfsd can load theshared object as a callable extension.Other IssuesThe init programmeAnother thing to take note of is whether your init programmecreates a Unix socket /dev/telinit. Some versions of initcreate /dev/telinit so that the telinit programme cancommunicate with the init process. If you have such a system you needto make sure that devfs is mounted over /dev *before* initstarts. In other words, you can't leave the mounting of devfs to/etc/rc, since this is executed after init. Otherversions of init require a named pipe /dev/initctlwhich must exist *before* init starts. Once again, you need tomount devfs and then create the named pipe *before* initstarts.The default behaviour now is not to mount devfs onto /dev atboot time for 2.3.x and later kernels. You can correct this with the"devfs=mount" boot option. This solves any problems with init,and also prevents the dreaded:Cannot open initial consolemessage. For 2.2.x kernels where you need to apply the devfs patch,the default is to mount.If you have automatic mounting of devfs onto /dev then youmay need to create /dev/initctl in your boot scripts. Thefollowing lines should suffice:mknod /dev/initctl pkill -SIGUSR1 1       # tell init that /dev/initctl now existsAlternatively, if you don't want the kernel to mount devfs onto/dev then you could use the following procedure is aguideline for how to get around /dev/initctl problems:# cd /sbin# mv init init.real# cat > init#! /bin/shmount -n -t devfs none /devmknod /dev/initctl pexec /sbin/init.real $*[control-D]# chmod a+x initNote that newer versions of init create /dev/initctlautomatically, so you don't have to worry about this.Module autoloadingYou will need to configure devfsd to enable moduleautoloading. The following lines should be placed in your/etc/devfsd.conf file:LOOKUP	.*		MODLOADAs of devfsd-v1.3.10, a generic /etc/modules.devfsconfiguration file is installed, which is used by the MODLOADaction. This should be sufficient for most configurations. If yourequire further configuration, edit your /etc/modules.conffile. The way module autoloading work with devfs is:a process attempts to lookup a device node (e.g. /dev/fred)if that device node does not exist, the full pathname is passed todevfsd as a stringdevfsd will pass the string to the modprobe programme (provided theconfiguration line shown above is present), and specifies that/etc/modules.devfs is the configuration file/etc/modules.devfs includes /etc/modules.conf toaccess local configurationsmodprobe will search it's configuration files, looking for an aliasthat translates the pathname into a module namethe translated pathname is then used to load the module.If you wanted a lookup of /dev/fred to load themymod module, you would require the following configurationline in /etc/modules.conf:alias    /dev/fred    mymodThe /etc/modules.devfs configuration file provides many suchaliases for standard device names. If you look closely at this file,you will note that some modules require multiple alias configurationlines. This is required to support module autoloading for old and newdevice names.Mounting root off a devfs deviceIf you wish to mount root off a devfs device when you pass the"devfs=only" boot option, then you need to pass in the"root=<device>" option to the kernel when booting. If you useLILO, then you must have this in lilo.conf:append = "root=<device>"Surprised? Yep, so was I. It turns out if you have (as most peopledo):root = <device>then LILO will determine the device number of <device> and willwrite that device number into a special place in the kernel imagebefore starting the kernel, and the kernel will use that device numberto mount the root filesystem. So, using the "append" variety ensuresthat LILO passes the root filesystem device as a string, which devfscan then use.Note that this isn't an issue if you don't pass "devfs=only".TTY issuesThe ttyname(3) function in some versions of the C library makesfalse assumptions about device entries which are symbolic links.  Thetty(1) programme is one that depends on this function.  I'vewritten a patch to libc 5.4.43 which fixes this. This has beenincluded in libc 5.4.44 and a similar fix is in glibc 2.1.3.Kernel Naming SchemeThe kernel provides a default naming scheme. This scheme is designedto make it easy to search for specific devices or device types, and toview the available devices. Some device types (such as hard discs),have a directory of entries, making it easy to see what devices ofthat class are available. Often, the entries are symbolic links into adirectory tree that reflects the topology of available devices. Thetopological tree is useful for finding how your devices are arranged.Below is a list of the naming schemes for the most common drivers. Alist of reserved device names isavailable for reference. Please send email torgooch@atnf.csiro.au to obtain an allocation. Please bepatient (the maintainer is busy). An alternative name may be allocatedinstead of the requested name, at the discretion of the maintainer.Disc DevicesAll discs, whether SCSI, IDE or whatever, are placed under the/dev/discs hierarchy:	/dev/discs/disc0	first disc	/dev/discs/disc1	second discEach of these entries is a symbolic link to the directory for thatdevice. The device directory contains:	disc	for the whole disc	part*	for individual partitionsCD-ROM DevicesAll CD-ROMs, whether SCSI, IDE or whatever, are placed under the

⌨️ 快捷键说明

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