📄 amdref.texinfo
字号:
* Key Lookup::* Location Format::@end menu@node Map Types, Key Lookup, Mount Maps, Mount Maps@comment node-name, next, previous, up@section Map Types@cindex Mount map types@cindex Map types@cindex Configuration map types@cindex Types of mount map@cindex Types of configuration map@cindex Determining the map typeA mount-map provides the run-time configuration information to @i{Amd}.Maps can be implemented in many ways. Some of the forms supported by@i{Amd} are regular files, ndbm databases, NIS maps the @dfn{Hesiod}name server and even the password file.A mount-map @dfn{name} is a sequence of characters. When an automountpoint is created a handle on the mount-map is obtained. For each maptype configured @i{Amd} attempts to reference the a map of theappropriate type. If a map is found, @i{Amd} notes the type for futureuse and deletes the reference, for example closing any open filedescriptors. The available maps are configure when @i{Amd} is built andcan be displayed by running the command @samp{amd -v}.By default, @i{Amd} caches data in a mode dependent on the type of map.This is the same as specifying @samp{cache:=mapdefault} and selects asuitable default cache mode depending on the map type. The individualdefaults are described below. The @var{cache} option can be specifiedon automount points to alter the caching behaviour (@pxref{AutomountFilesystem}).@refillThe following map types have been implemented, though some are notavailable on all machines. Run the command @samp{amd -v} to obtain alist of map types configured on your machine.@menu* File maps::* ndbm maps::* NIS maps::* Hesiod maps::* Password maps::* Union maps::@end menu@node File maps, ndbm maps, Map Types, Map Types@comment node-name, next, previous, up@subsection File maps@cindex File maps@cindex Flat file maps@cindex File map syntactic conventionsWhen @i{Amd} searches a file for a map entry it does a simple scan ofthe file and supports both comments and continuation lines.Continuation lines are indicated by a backslash character (@samp{\}) asthe last character of a line in the file. The backslash, newline character@emph{and any leading white space on the following line} are discarded. A maximumline length of 2047 characters is enforced after continuation lines are readbut before comments are stripped. Each line must end witha newline character; that is newlines are terminators, not separators.The following examples illustrate this:@examplekey valA valB; \ valC@end examplespecifies @emph{three} locations, and is identical to@examplekey valA valB; valC@end exampleHowever,@examplekey valA valB;\ valC@end examplespecifies only @emph{two} locations, and is identical to@examplekey valA valB;valC@end exampleAfter a complete line has been read from the file, includingcontinuations, @i{Amd} determines whether there is a comment on theline. A comment begins with a hash (``@samp{#}'') character andcontinues to the end of the line. There is no way to escape or changethe comment lead-in character.Note that continuation lines and comment support @dfn{only} apply tofile maps, or ndbm maps built with the @code{mk-amd-map} program.When caching is enabled, file maps have a default cache mode of@code{all} (@pxref{Automount Filesystem}).@node ndbm maps, NIS maps, File maps, Map Types@comment node-name, next, previous, up@subsection ndbm maps@cindex ndbm mapsAn ndbm map may be used as a fast access form of a file map. The program,@code{mk-amd-map}, converts a normal map file into an ndbm database.This program supports the same continuation and comment conventions thatare provided for file maps. Note that ndbm format files may @emph{not}be sharable across machine architectures. The notion of speed generallyonly applies to large maps; a small map, less than a single disk block,is almost certainly better implemented as a file map.ndbm maps do not support cache mode @samp{all} and, when caching isenabled, have a default cache mode of @samp{inc} (@pxref{Automount Filesystem}).@node NIS maps, Hesiod maps, ndbm maps, Map Types@comment node-name, next, previous, up@subsection NIS maps@cindex NIS (YP) mapsWhen using NIS (formerly YP), an @i{Amd} map is implemented directlyby the underlying NIS map. Comments and continuation lines are@emph{not} supported in the automounter and must be stripped whenconstructing the NIS server's database.NIS maps do not support cache mode @code{all} and, when caching isenabled, have a default cache mode of @code{inc} (@pxref{Automount Filesystem}).The following rule illustrates what could be added to your NIS @file{Makefile},in this case causing the @file{amd.home} map to be rebuilt:@example$(YPTSDIR)/amd.home.time: $(ETCDIR)/amd.home -@@sed -e "s/#.*$$//" -e "/^$$/d" $(ETCDIR)/amd.home | \ awk '@{ \ for (i = 1; i <= NF; i++) \ if (i == NF) @{ \ if (substr($$i, length($$i), 1) == "\\") \ printf("%s", substr($$i, 1, length($$i) - 1)); \ else \ printf("%s\n", $$i); \ @} \ else \ printf("%s ", $$i); \ @}' | \ $(MAKEDBM) - $(YPDBDIR)/amd.home; \ touch $(YPTSDIR)/amd.home.time; \ echo "updated amd.home"; \ if [ ! $(NOPUSH) ]; then \ $(YPPUSH) amd.home; \ echo "pushed amd.home"; \ else \ : ; \ fi@end exampleHere @code{$(YPTSDIR)} contains the time stamp files, and @code{$(YPDBDIR)} containsthe dbm format NIS files.@node Hesiod maps, Password maps, NIS maps, Map Types@comment node-name, next, previous, up@subsection Hesiod maps@cindex Hesiod mapsWhen the map name begins with the string @samp{hesiod.} lookups are madeusing the @dfn{Hesiod} name server. The string following the dot isused as a name qualifier and is prepended with the key being located.The entire string is then resolved in the @code{automount} context. Forexample, if the the key is @samp{jsp} and map name is@samp{hesiod.homes} then @dfn{Hesiod} is asked to resolve@samp{jsp.homes.automount}.Hesiod maps do not support cache mode @samp{all} and, when caching isenabled, have a default cache mode of @samp{inc} (@pxref{Automount Filesystem}).The following is an example of a @dfn{Hesiod} map entry:@examplejsp.homes.automount HS TXT "rfs:=/home/charm;rhost:=charm;sublink:=jsp"njw.homes.automount HS TXT "rfs:=/home/dylan/dk2;rhost:=dylan;sublink:=njw"@end example@node Password maps, Union maps, Hesiod maps, Map Types@comment node-name, next, previous, up@subsection Password maps@cindex Password file maps@cindex /etc/passwd maps@cindex User maps, automatic generation@cindex Automatic generation of user maps@cindex Using the password file as a mapThe password map support is unlike the four previous map types. Whenthe map name is the string @file{/etc/passwd} @i{Amd} can lookup a username in the password file and re-arrange the home directory field toproduce a usable map entry.@i{Amd} assumes the home directory has the format`@t{/}@i{anydir}@t{/}@i{dom1}@t{/../}@i{domN}@t{/}@i{login}'.@c @footnote{This interpretation is not necessarily exactly what you want.}It breaks this string into a map entry where @code{$@{rfs@}} has thevalue `@t{/}@i{anydir}@t{/}@i{domN}', @code{$@{rhost@}} has the value`@i{domN}@t{.}@i{...}@t{.}@i{dom1}', and @code{$@{sublink@}} has thevalue @samp{login}.@refillThus if the password file entry was@example/home/achilles/jsp@end examplethe map entry used by @i{Amd} would be@examplerfs:=/home/achilles;rhost:=achilles;sublink:=jsp@end exampleSimilarly, if the password file entry was@example/home/cc/sugar/mjh@end examplethe map entry used by @i{Amd} would be @examplerfs:=/home/sugar;rhost:=sugar.cc;sublink:=jsp@end example@node Union maps, , Password maps, Map Types@comment node-name, next, previous, up@subsection Union maps@cindex Union file mapsThe union map support is provided specifically for use with the unionfilesystem, @pxref{Union Filesystem}.It is identified by the string @samp{union:} which is followed by acolon separated list of directories. The directories are read in order,and the names of all entries are recorded in the map cache. Laterdirectories take precedence over earlier ones. The union filesystemtype then uses the map cache to determine the union of the names in allthe directories.@c subsection Gdbm@node Key Lookup, Location Format, Map Types, Mount Maps@comment node-name, next, previous, up@section How keys are looked up@cindex Key lookup@cindex Map lookup@cindex Looking up keys@cindex How keys are looked up@cindex Wildcards in mapsThe key is located in the map whose type was determined when theautomount point was first created. In general the key is a pathnamecomponent. In some circumstances this may be modified by variableexpansion (@pxref{Variable Expansion}) and prefixing. If the automountpoint has a prefix, specified by the @var{pref} option, then that isprepended to the search key before the map is searched.If the map cache is a @samp{regexp} cache then the key is treated as anegrep-style regular expression, otherwise a normal string comparison ismade.If the key cannot be found then a @dfn{wildcard} match is attempted.@i{Amd} repeatedly strips the basename from the key, appends @samp{/*} andattempts a lookup. Finally, @i{Amd} attempts to locate the special key @samp{*}.@groupFor example, the following sequence would be checked if @file{home/dylan/dk2} wasbeing located:@example home/dylan/dk2 home/dylan/* home/* *@end example@end groupAt any point when a wildcard is found, @i{Amd} proceeds as if an exactmatch had been found and the value field is then used to resolve themount request, otherwise an error code is propagated back to the kernel.(@pxref{Filesystem Types}).@refill@node Location Format, , Key Lookup, Mount Maps@comment node-name, next, previous, up@section Location Format@cindex Location format@cindex Map entry format@cindex How locations are parsedThe value field from the lookup provides the information required tomount a filesystem. The information is parsed according to the syntaxshown below.@display@i{location-list}: @i{location-selection} @i{location-list} @i{white-space} @t{||} @i{white-space} @i{location-selection}@i{location-selection}: @i{location} @i{location-selection} @i{white-space} @i{location}@i{location}: @i{location-info} @t{-}@i{location-info} @t{-}@i{location-info}: @i{sel-or-opt} @i{location-info}@t{;}@i{sel-or-opt} @t{;}@i{sel-or-opt}: @i{selection} @i{opt-ass}@i{selection}: selector@t{==}@i{value} selector@t{!=}@i{value}@i{opt-ass}: option@t{:=}@i{value}@i{white-space}: space tab@end displayNote that unquoted whitespace is not allowed in a location description.White space is only allowed, and is mandatory, where shown with non-terminal@samp{white-space}.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -