1ELEKTRA(5)                                                          ELEKTRA(5)
2
3
4

NAME

6       elektra - A framework to store configuration atoms hierarchically
7
8       Note
9       This section is provided for the sake of the openness of Elektra. You
10       should not access the Elektra´s key files directly. You should use the
11       API or the kdb(1) command for that.
12
13       Elektra Key Storage Strategy.PP Elektra implements a very simple way to
14       store the key-value pairs. The value (and some metainfo) for each key
15       is stored in a single file. The key name (and some of its context) is
16       sufficient to find the file name that stores the value.
17
18       The system/* keys are stored under /etc/kdb/, and the user/* keys can
19       be found under each user´s $HOME/.kdb/.
20
21       Here are some examples of key names, and where Elektra goes to look for
22       them in the disk.
23
24       system/sw/XFree86/screen0/driver
25           Maps to: /etc/kdb/system/sw/XFree86/screen0/driver
26
27       user/env/PATH
28           Maps to: ~$USER/.kdb/user/env/PATH
29
30       user:luciana/env/PATH
31           Maps to: ~luciana/.kdb/user/env/PATH
32
33       system/mime.types/some.mime
34           Maps to: /etc/kdb/system/mime.types/some.mime
35
36       Some may think that one file per key will consume many filesystem
37       i-nodes. Actually, when not using Reiser4 filesystem, it may consume
38       some more disk space, and it may also be not so efficient than reading
39       one single text file, as KConfig does. But Elektra´s nature lets
40       applications load their keys on demand; so it is possible to avoid the
41       read-all-use-some approach. Writing updated keys back to disk is also
42       more robust, because unchanged keys won´t be touched, different from a
43       single file approach, that must be entirelly rewritten.
44
45       Besides that, big applications (like Mozilla, Konqueror, KDE, Gnome)
46       key gathering time is a very small part of what they have to do to
47       start up. And the benefits of an homogeneous key database to the entire
48       system are much bigger then these issues. Think about a common
49       integration between everything, flexibility, security granularity and
50       openness.  XML, Storage Backends and Elektra.PP This document you are
51       just reading was written in DocBook XML. XML is a wonderfull
52       technology, but brings no value to this software. Two main goals of the
53       Elektra Project are to be lightweight, and to be accessible by early
54       boot stage programs like /sbin/init and the /etc/rc.d scripts.
55
56       XML parsing libraries are memory eaters, not so fast as we can expect,
57       and they are usualy located under /usr/lib, which may be unavailable to
58       these early boot stage needs.
59
60       Some discussions asked for a sort of plugin architecture to let user
61       decide the format to store keys content. Well, the info that goes into
62       the key file is not big deal as you´ll see, and sometimes, too many
63       options is bad business, and not the path for the Elektra Project.
64
65       So no XML, no plugin architecture, no sophistication. Lets keep it
66       simple and generic. A very straight forward text based file format was
67       defined to store a single key value.  Key Files Format.PP Inside
68       Elektra key database, each key is a file, and every file is a key. So
69       most of the key´s metainformation are actually its file attributes, as
70       you can see in a regular ls(1) command output.
71
72       So what needs to be stored inside the key file is the data type (binary
73       or text), key comment and the actual data. The format of each key file
74       is:
75
76           File Format Version
77           Data Type
78           As many lines of
79           comments as we want (UTF-8 encoded)
80           <DATA>
81           The data encoded as text
82
83
84       So if we set the key system/hw/eth0/driver as type String and value
85       "3com", and comment "The driver for my network interface", we´ll find
86       the file /etc/kdb/system/hw/eth0/driver containing:
87
88           RG002
89           40
90           The driver for my network interface
91           <DATA>
92           3com
93
94
95       Other example: setting user/tmp/proprietary as Binary, and value "A
96       groovy data I want to hide", and comment "Stay away from here", you´ll
97       get in ~$USER/.kdb/user/tmp/proprietary the following:
98
99           RG002
100           20
101           Stay away from here
102           <DATA>
103           41206772 6f6f7679 20646174 61204920 77616e74 20746f20 68696465
104
105
106       The current data types are:
107
108       Between 20 and 39
109           Binary value. The data will be encoded into a text format. Today
110           only type 20 is used, and means a raw stream of bytes with no
111           special semantics to Elektra. The other values are reserved for
112           future use; being treated still as binary values but possibly with
113           some semantics to Elektra or a higher level application.
114
115       40 up to 254
116           Text, UTF-8 encoded. Values higher then 40 are reserved for future
117           or application specific implementations of more abstract data
118           types, like time/date, color, font, etc. But always represented as
119           pure text that can be edited in any text editor like vi(1).
120
121       Types between 0 and 19 are used only internaly in the API, and will
122       never appear into a key file. They are used to define meta keys as
123       directory, link, etc.
124

SEE ALSO

126       kdb(1), elektra(7)
127

AUTHOR

129       Avi Alkalay <avi at unix.sh>
130       Linux Market Developer, Senior IT and Software Architect, IBM Linux
131       Impact Team :: ibm.com/linux
132           Author.
133
135       Copyright © 2004 Avi Alkalay
136
137
138
139Elektra Initiative                March 2004                        ELEKTRA(5)
Impressum