📄 devfsd.8
字号:
.\" Copyright (C) 1998-2002 Richard Gooch.\".\" This program is free software; you can redistribute it and/or modify.\" it under the terms of the GNU General Public License as published by.\" the Free Software Foundation; either version 2 of the License, or.\" (at your option) any later version..\".\" This program is distributed in the hope that it will be useful,.\" but WITHOUT ANY WARRANTY; without even the implied warranty of.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the.\" GNU General Public License for more details..\".\" You should have received a copy of the GNU General Public License.\" along with this program; if not, write to the Free Software.\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA..\".\" Richard Gooch may be reached by email at rgooch@atnf.csiro.au.\" The postal address is:.\" Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia..\".\" devfsd.8 Richard Gooch 8-MAR-2002.\".TH DEVFSD 8 "8 Mar 2002" "Linux System Daemons".SH NAMEdevfsd \- optional daemon for managing devfs (the Linux DeviceFilesystem).SH SYNOPSIS.B devfsd.B mntpnt[.B -v][.B -d][.B -t num][.B -D mask][.B -fg][.B -np].SH DESCRIPTIONThe \fIdevfsd\fP programme is a daemon, run by the system bootscripts, which can provide for intelligent management of deviceentries in the Device Filesystem (devfs). It is desirable to start thedaemon at the beginning of the boot scripts, in particular beforefilesystem checks..PPAs part of its setup phase \fIdevfsd\fP creates certain symboliclinks which are compiled into the code. These links are required by\fB/usr/src/linux/Documentation/devices.txt\fP. This behaviour maychange in future revisions..PP\fIdevfsd\fP will read the special control file \fI.devfsd\fP in amounted devfs, listening for the creation and removal of deviceentries (this is termed a change operation). For each changeoperation, \fIdevfsd\fP can take many actions. The daemon willnormally run itself in the background and send messages to syslog..PPThe opening of the syslog service is automatically delayed until\fI/dev/log\fP is created..PPAt startup, before switching to daemon mode, \fIdevfsd\fP will scanthe mounted device tree and will generate synthetic \fBREGISTER\fPevents for each leaf node and directory..SH OPTIONS.TP.B mntpntThis specifies a mount point for where devfs is mounted. This istypically "/dev". The daemon will change directory to this mount pointbefore opening any files..TP.B \-vThis option will print the protocol version numbers for \fIdevfsd\fPand the kernel-side protocol version provided by devfs itself. Theprogramme then exits..TP.B \-dRun \fIdevfsd\fP in debug mode. Used for debugging the kernel-sideprotocol implemented by devfs. This also prints the protocol versionnumbers. In this mode the daemon runs in the foreground..TP.B \-t numSet the trace level to \fInum\fP. If the level is greater than 0 thenoutput is sent to stderr rather than syslog(3). If the level isgreater than 1 then \fIdevfsd\fP will run in trace mode. Higher levelsyield more trace information..TP.B \-D maskSet the debug mask for devfs..TP.B \-fgRun the daemon in the foreground..TP.B \-npExit after parsing the configuration file and processing synthetic\fBREGISTER\fP events. Do not poll for events. This is primarily usedfor creating compatibility entries without needing a daemon running inthe background..SH CONFIGURATIONThe configuration file /etc/devfsd.conf configures the \fIdevfsd\fPprogramme. It is a simple ASCII file with one configuration option perline. Comment lines must start with a leading '#' character. Commentlines and blank lines are ignored. Each configuration option is akeyword followed by zero or more parameters, depending on theoption. The following section details the configuration options. Beloware the permitted keywords:.TP.B INCLUDE locationInclude the configuration file named by \fIlocation\fP. Variableexpansion is applied to \fIlocation\fP (see the section on VARIABLEEXPANSION below). If this is a directory, then all files (except thosewhich start with '.') are read. This is recursive (i.e. files whichare in fact subdirectories are also read).If the first character of \fIlocation\fP is "+",then the rest of \fIlocation\fP is the name of an NIS map to load.This operation is silently ignored if the NIS domain has not yet beenset (\fBSIGHUP\fP should then be sent after the NIS domain has beenset)..TP.B OPTIONAL_INCLUDE locationAs above, except that if the file does not exist, it is silentlyignored..TP.B CLEAR_CONFIGClear the current configuration..TP.B RESTORE directoryThis will restore entries previously saved under \fIdirectory\fP todevfs. Only symbolic links or entries with the sticky bit set will berestored. This action is taken as the configuration file is read. Withappropriate \fBCOPY\fP actions, complete persistence is acheived..PPThe config file can also be used to specify actions that should betaken at specified events. Each line specifies an event andaction. Multiple actions (of the same or different types) per eventmay be specified (one action per line). Events are processed in order,with the first event config line being processed first. The syntax is:.TP.B EVENT devname ACTION [args...]where \fIEVENT\fP is the event and \fIACTION\fP is the action to takewhen the event occurs. The action is only taken when \fIdevname\fPmatches the name of the device entry affected (this does not includethe mount point for the filesystem). This is processed as a regularexpression. Some actions support extra arguments, passed as\fIargs\fP.Variable expansion is applied to the arguments (see the section onVARIABLE EXPANSION below). After variable expansion, regularexpression substitution is performed (see the section on REGULAREXPRESSION SUBSTITUTION). Note that the following special variablenames are also recognised:.RS.TP.B devpaththe full path name of the new device.TP.B devnamethe name of the new device inside the devfs namespace.TP.B modethe mode of the device entry in octal.TP.B uidthe user ID of the process or inode.TP.B gidthe group ID of the process or inode.RE.PPThe following events are recognised:.TP.B REGISTERThe device entry or directory was registered by a device driver..TP.B UNREGISTERThe device entry was unregistered by a device driver..TP.B ASYNC_OPENThe inode was opened (the opening process does not wait for aresponse)..TP.B CLOSEThe file was closed..TP.B LOOKUPAn inode lookup was performed and there was no device entry. Thisevent is not sent if the initiating process is devfsd or one of itschildren..TP.B CHANGESome inode attributes were changed..TP.B CREATEAn inode was created by a process..TP.B DELETEAn inode was deleted by a process..PPThe following actions are recognised:.TP.B PERMISSIONS owner_and_group access_mode\fIowner_and_group\fP specifies the owner and group that the fileshould be set to. This must be of the form "user.group" and either"user" or "group" component may be symbolic or numeric. To specifythat the user or group be left alone, use a numeric value of "-1" forthe respective component. \fIaccess_mode\fP specifies the access modethe file should be set to. This must be either an octal value or asymbolic string of nine characters with the form "rwxrwxrwx". Whereaccess is not given, a '-' character should be used in place(e.g. "rw-rw-r--" gives read and write access to the user and groupand only read access to everybody else)..TP.B MODLOADThis action will pass "/dev/$devname" (i.e. "/dev/" prefixed to thedevice name) to the module loading facility. In addition, the\fI/etc/modules.devfs\fP configuration file is used..TP.B EXECUTE path [arg...]This action allows you to run a programme. \fIpath\fP is the pathnameof the programme to run and \fIarg\fP is a set of optional argumentspassed to the programme (maximum 6). \fIpath\fP is the first argument(i.e. argv[0]) passed to the programme..TP.B MFUNCTION path function [arg...]This action allows you to run a "main"-style function within a sharedobject. \fIpath\fP is the pathname of the shared object, with thespecial path of "GLOBAL" signifying all global symbols (e.g. fromlibc). The default directory is \fB/lib/devfsd\fP. \fIfunction\fP isthe name of the function symbol to run and \fIarg\fP is a set ofoptional arguments passed to the function (maximum 5). \fIpath\fP isthe first argument (i.e. argv[0]) passed to the function. Theprototype for this function is similar to the \fImain\fP function of Cprogrammes. The prototype is:int func (int argc, char **argv);.TP.B CFUNCTION path function [arg...]This action is similar to the \fBMFUNCTION\fP action, except for thecalling convention. The prototype for this function is:int func (void *arg1, void *arg2, void *arg3, void *arg4, void *arg5);Up to 5 arguments may be passed, each being of type \fIvoid *\fP. Thefollowing special arguments are recognised:.RS.TP.B EVENTa \fIstruct devfsd_notify_struct *\fP is passed.RE.PP.TP.B COPY source destinationThis action will copy the device type and permissions of \fIsource\fPto \fIdestination\fP. The sticky bit is set on the destination inodeif the source inode was create manually (i.e. not by a driver or\fIdevfsd\fP)..TP.B IGNOREThis action causes all subsequent processing for the event to beignored..TP.B MKOLDCOMPATThis action creates an "old" compatibility entry for the device..TP.B MKNEWCOMPATThis action creates a "new" compatibility entry for the device..TP.B RMOLDCOMPATThis action removes an "old" compatibility entry for the device..TP.B RMNEWCOMPATThis action removes a "new" compatibility entry for the device..SH VARIABLE EXPANSIONA subset of normal Bourne shell variable expansion is applied tovarious expressions. The currently supported subset is:\fI$variable\fP, \fI${variable}\fP and \fI${variable:-word}\fP.Variables are taken from the environment. The following variable namesare also defined :.TP.B hostnameThe hostname of the machine.TP.B mntpntThe mount point for devfs.SH REGULAR EXPRESSION SUBSTITUTIONSections of the matched regular expression can be included inan action. Use \fI\\0\fP to refer to the entire regular expressionmatched, \fI\\1\fP to refer to the first parenthesized subexpression,\fI\\2\fP to refer to the second, and so on. (Use \fI\\\\\fP toinclude an actual backslash.).PPSee \fBdevfsd.conf\fP(5) for examples of regular expressionsubstitution..SH SIGNALS\fIdevfsd\fP responds to signals in a variety of ways:.TP.B SIGINT\fIdevfsd\fP will exit cleanly..TP.B SIGTERM\fIdevfsd\fP will exit cleanly..TP.B SIGHUPThe configuration file is re-read and any shared objects arereloaded. Then the mounted device tree is scanned and synthetic\fBREGISTER\fP events are generated for each leaf node..TP.B SIGUSR1The configuration file is re-read and any shared objects arereloaded. No synthetic \fBREGISTER\fP events are generated..SH EXAMPLES.B Create and destroy "old" compatibility entries:.RS.nf.if t .ft CWREGISTER .* MKOLDCOMPATUNREGISTER .* RMOLDCOMPAT.if t .ft P.fi.RE.LP.B Create and destroy "new" compatibility entries:.RS.nf.if t .ft CWREGISTER .* MKNEWCOMPATUNREGISTER .* RMNEWCOMPAT.if t .ft P.fi.RE.LP.B Load modules:.RS.nf.if t .ft CWLOOKUP .* MODLOAD.if t .ft P.fi.RE.LP.B Make and remove a symbolic link:.RS.nf.if t .ft CWREGISTER mydir/mydev CFUNCTION GLOBAL mksymlink $devname mydevUNREGISTER mydir/mydev CFUNCTION GLOBAL unlink mydev.if t .ft P.fi.RE.LP.B Give sndusers group access to sound drivers.RS.nf.if t .ft CWREGISTER sound/.* PERMISSIONS root.sndusers rw-rw----.if t .ft P.fi.RE.SH FILES.TP.B /etc/devfsd.confthe configuration file. If this file is missing or has zero size,\fIdevfsd\fP will exit after its setup phase..TP.B /etc/modules.devfsthe generic module configuration file (required for the \fBMODLOAD\fPaction), which is installed with \fIdevfsd\fP. This in turn includes\fI/etc/modules.conf\fP.SH CAVEATSMake sure you understand the implications of regular expressionmatching. For example, if you had a configuration line such as:.B LOOKUP cdrom CFUNCTION GLOBAL mksymlink ${mntpnt}/cdroms/cdrom0 $devpaththen referencing "/dev/cdrom1" will create the symbolic link"/dev/cdrom1". Further, referencing "/dev/cdroms/1" would also createthe "/dev/cdroms/1" symbolic link. This is probably not what you want.If there was not already a "/dev/cdroms" directory, then you would geta "/dev/cdrom" symbolic link. Definately not what you want!The correct configuration line would be:.B LOOKUP ^cdrom$ CFUNCTION GLOBAL mksymlink ${mntpnt}/cdroms/cdrom0 $devpath.SH SEE ALSO.BR init (8),.BR devfsd.conf (5),.BR modprobe (8).SH AUTHORRichard Gooch (rgooch@atnf.csiro.au).SH AVAILABILITYThe Device Filesystem daemon is available from:http://www.atnf.csiro.au/~rgooch/linux/.SH FURTHER READINGIt is strongly recommended to read the devfs FAQ, which containsconfiguration tips. It is available at:http://www.atnf.csiro.au/~rgooch/linux/docs/devfs.html.SH MAILING LISTA mailing list exists for devfs kernel patch and devfsd releaseannouncements. This list also has a small amount of discussion traffic(a few messages per week). You may subscribe by sending a message to\fBmajordomo@oss.sgi.com\fP with \fBsubscribe devfs\fP in the message\fIbody\fP.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -