
\begin{DoxyItemize}
\item infos = Information about the multifile plugin is in keys below
\item infos/author = Thomas \href{mailto:thomas.waser@libelektra.org}{\tt thomas.\+waser@libelektra.\+org}
\item infos/licence = B\+SD
\item infos/needs =
\item infos/provides = resolver storage
\item infos/recommends =
\item infos/placements = getresolver setresolver commit rollback getstorage setstorage
\item infos/status = maintained conformant compatible specific shelltest tested nodep configurable
\item infos/metadata =
\item infos/description = mounts multiple files within a directory
\end{DoxyItemize}

For some applications it is beneficially to have multiple configuration files. One way to achieve this, is to mount different files for the application.

In some situations we are not able to specify every configuration file with separate mounts because new configuration files might be created any time. Instead we want to include every configuration file matching a given pattern.

The multifile-\/resolver does so by calling resolver and storage plugins for each file matching a given pattern.


\begin{DoxyItemize}
\item {\ttfamily recursive}\+: If present, fts (3) will be used to traverse the directory tree and fnmatch to match {\ttfamily pattern} to the filename. If not present, glob (3) with {\ttfamily pattern} will be used on the directory
\item {\ttfamily pattern}\+: The pattern to be used to match configuration files.
\item {\ttfamily storage}\+: The storage plugin to use.
\item {\ttfamily resolver}\+: The resolver plugin to use.
\item \textquotesingle{}child/$<$configname$>$\textquotesingle{}\+: configuration passed to the child backends, {\ttfamily child/} part gets removed.
\end{DoxyItemize}

{\ttfamily kdb mount -\/R multifile -\/c storage=\char`\"{}ini\char`\"{},pattern=\char`\"{}$\ast$/$\ast$.\+ini\char`\"{},resolver=\char`\"{}resolver\char`\"{} /path /mountpoint}

{\ttfamily kdb mount -\/R multifile -\/c storage=\char`\"{}ini\char`\"{},pattern=\char`\"{}$\ast$.\+ini\char`\"{},recursive=,resolver=\char`\"{}resolver\char`\"{} /path /mountpoint}


\begin{DoxyCode}
rm -rf $(dirname $(kdb file user))/multitest || $(exit 0)
mkdir -p $(dirname $(kdb file user))/multitest || $(exit 0)

cat > $(dirname $(kdb file user))/multitest/lo.ini << EOF \(\backslash\)
[lo]\(\backslash\)
addr = 127.0.0.1\(\backslash\)
Link encap = Loopback\(\backslash\)
EOF

cat > $(dirname $(kdb file user))/multitest/lan.ini << EOF \(\backslash\)
[eth0]\(\backslash\)
addr = 192.168.1.216\(\backslash\)
Link encap = Ethernet\(\backslash\)
EOF

cat > $(dirname $(kdb file user))/multitest/wlan.ini << EOF \(\backslash\)
[wlan0]\(\backslash\)
addr = 192.168.1.125\(\backslash\)
Link encap = Ethernet\(\backslash\)
EOF

sudo kdb mount -R multifile -c storage="ini",pattern="*.ini",resolver="resolver" multitest
       user/tests/multifile

kdb ls user/tests/multifile
#> user/tests/multifile/lan.ini/eth0
#> user/tests/multifile/lan.ini/eth0/Link encap
#> user/tests/multifile/lan.ini/eth0/addr
#> user/tests/multifile/lo.ini/lo
#> user/tests/multifile/lo.ini/lo/Link encap
#> user/tests/multifile/lo.ini/lo/addr
#> user/tests/multifile/wlan.ini/wlan0
#> user/tests/multifile/wlan.ini/wlan0/Link encap
#> user/tests/multifile/wlan.ini/wlan0/addr

kdb set user/tests/multifile/lan.ini/eth0/addr 10.0.0.2

kdb get user/tests/multifile/lan.ini/eth0/addr
#> 10.0.0.2

cat > $(dirname $(kdb file user))/multitest/test.ini << EOF \(\backslash\)
[testsection]\(\backslash\)
key = val\(\backslash\)
EOF

kdb ls user/tests/multifile
#> user/tests/multifile/lan.ini/eth0
#> user/tests/multifile/lan.ini/eth0/Link encap
#> user/tests/multifile/lan.ini/eth0/addr
#> user/tests/multifile/lo.ini/lo
#> user/tests/multifile/lo.ini/lo/Link encap
#> user/tests/multifile/lo.ini/lo/addr
#> user/tests/multifile/test.ini/testsection
#> user/tests/multifile/test.ini/testsection/key
#> user/tests/multifile/wlan.ini/wlan0
#> user/tests/multifile/wlan.ini/wlan0/Link encap
#> user/tests/multifile/wlan.ini/wlan0/addr

kdb rm -r user/tests/multifile/test.ini

stat $(dirname $(kdb file user))/multifile/test.ini
# RET:1

sudo kdb umount user/tests/multifile
\end{DoxyCode}


Recursive\+:


\begin{DoxyCode}
rm -rf $(dirname $(kdb file user))/multitest || $(exit 0)
mkdir -p $(dirname $(kdb file user))/multitest $(dirname $(kdb file user))/multitest/a/a1/a12 $(dirname
       $(kdb file user))/multitest/a/a2/a22 $(dirname $(kdb file user))/multitest/b/b1|| $(exit 0)

echo "a1key = a1val" > $(dirname $(kdb file user))/multitest/a/a1/a12/testa1.file
echo "a2key = a2val" > $(dirname $(kdb file user))/multitest/a/a2/a22/testa2.file
echo "b1key = b1val" > $(dirname $(kdb file user))/multitest/b/b1/testb1.file

sudo kdb mount -R multifile -c storage="ini",pattern="*.file",recursive=,resolver="resolver" multitest
       user/tests/multifile

kdb ls user/tests/multifile
#> user/tests/multifile/a/a1/a12/testa1.file/a1key
#> user/tests/multifile/a/a2/a22/testa2.file/a2key
#> user/tests/multifile/b/b1/testb1.file/b1key

rm -rf $(dirname $(kdb file user))/multitest

sudo kdb umount user/tests/multifile
\end{DoxyCode}



\begin{DoxyItemize}
\item You cannot get rid of the configuration file name. 
\end{DoxyItemize}