Linux Kernel Architecture

(Jacob Rumans) #1
Mauerer runapp02.tex V2 - 09/04/2008 6:09pm Page 1151

Appendix B: Working with the Source Code


Attributes


Attributes are used to more precisely specify the effect of configuration options. The following excerpt
from the kernel sources makes use of attributes:

config SWAP
bool "Support for paging of anonymous memory (swap)"
depends on MMU & BLOCK
default y

depends onspecifies thatSWAPmay be chosen only if the kernel iscompiled for a system with MMU, and
if the block layer is compiled in.defaultindicates thatyis selected by default — if users do not change
the setting, this value is automatically assigned to theSWAPsymbol.

Before moving on to deal with how the dependency specification is used (described in the next subsec-
tion), take a look at the following attributes:

❑ defaultspecifies the default setting for theconfigentry. Forboolqueries, the possible defaults
areyorn.mis a third alternative fortristate. Modified defaults must be specified for the other
option types: strings forstring, and numbers forintegerandhex.
❑ rangelimits the possible value range for numeric options. The first argument specifies the lower
limit; the second argument specifies the upper limit.
❑ selectis used to automatically select other configuration options if the entry is selected using
theselectstatement. Thisreverse dependencymechanism can be used only withtristatesand
bool.
❑ helpand--help--introduce help text, as demonstrated previously.

All these attributes may also be followed by anifclause, which specifies the conditions in which the
attribute applies. As withdepends on, this is done by linking the symbols on which the attribute depends
by means of logical operators, as shown in the following (fictitious) example:

config ENABLE_ACCEL
bool "Enable device acceleration"
default n

...

config HYPERCARD_SPEEDUP
integer "HyperCard Speedup"
default 20 if ENABLE_ACCEL
range 1 20

Dependencies


As previously explained, entry dependencies can be specified in the form of logical clauses based on a
syntax similar to C. A dependency specification must be structured as follows:

depends [on] <expr>
<expr> ::= <Symbol>
<Symbol> ’=’ <Symbol>
<Symbol> ’!=’ <Symbol>
Free download pdf