Elektra  0.9.11
Functions
mount.c File Reference

Internals of mount functionality. More...

#include <stdio.h>
#include <kdbassert.h>
#include "kdbinternal.h"
Include dependency graph for mount.c:

Functions

int mountOpen (KDB *kdb, KeySet *config, KeySet *modules, Key *errorKey)
 Creates a trie from a given configuration. More...
 
int mountDefault (KDB *kdb, KeySet *modules, int inFallback, Key *errorKey)
 Reopens the default backend and mounts the default backend if needed. More...
 
int elektraMountGlobalsLoadPlugin (Plugin **plugin, KeySet *referencePlugins, Key *cur, KeySet *global, KeySet *system, KeySet *modules, Key *errorKey)
 Loads global plugin. More...
 
int mountModules (KDB *kdb, KeySet *modules, Key *errorKey)
 Mount all module configurations. More...
 
int mountVersion (KDB *kdb, Key *errorKey)
 Mount the version backend. More...
 
int mountBackend (KDB *kdb, Backend *backend, Key *errorKey)
 Mounts a backend into the trie. More...
 
Key * mountGetMountpoint (KDB *handle, const char *where)
 Lookup a mountpoint in a handle for a specific key. More...
 
Backend * mountGetBackend (KDB *handle, const char *where)
 Lookup a backend handle for a specific key. More...
 

Detailed Description

Internals of mount functionality.

Function Documentation

◆ elektraMountGlobalsLoadPlugin()

int elektraMountGlobalsLoadPlugin ( Plugin **  plugin,
KeySet *  referencePlugins,
Key *  cur,
KeySet *  global,
KeySet *  system,
KeySet *  modules,
Key *  errorKey 
)

Loads global plugin.

Return values
-1on failure
0on empty plugin name (nothing configured at given position)
1on success

◆ mountBackend()

int mountBackend ( KDB *  kdb,
Backend *  backend,
Key *  errorKey 
)

Mounts a backend into the trie.

Precondition
user must pass correctly allocated backend
Postcondition
sets reference counter of backend
Warning
in case of init and default backends, the reference counter needs to be modified after calling mountBackend.
Parameters
kdbthe handle to work with
backendthe backend to mount
errorKeythe key used to report warnings
Return values
-1on failure
1on success

◆ mountDefault()

int mountDefault ( KDB *  kdb,
KeySet *  modules,
int  inFallback,
Key *  errorKey 
)

Reopens the default backend and mounts the default backend if needed.

Precondition
Default Backend is closed. mountOpen was executed before.
Parameters
kdbthe handle to work with
modulesthe current list of loaded modules
errorKeythe key used to report warnings
Return values
-1on error
0on success

◆ mountGetBackend()

Backend* mountGetBackend ( KDB *  handle,
const char *  where 
)

Lookup a backend handle for a specific key.

The required canonical name is ensured by using a key as parameter, which will transform the key to canonical representation.

Will return handle when no more specific KDB could be found.

If key is 0 or invalid the default backend will be returned.

Parameters
handleis the data structure, where the mounted directories are saved.
wherethe key name, that should be looked up.
Returns
the backend handle associated with the key

◆ mountGetMountpoint()

Key* mountGetMountpoint ( KDB *  handle,
const char *  where 
)

Lookup a mountpoint in a handle for a specific key.

Will return a key representing the mountpoint or null if there is no appropriate mountpoint e.g. its the root mountpoint.

Example:
KDB * handle = kdbOpen();
Key *mountpoint=0;
mountpoint=kdbGetMountpoint(handle, "system:/template");
printf("The backend I am using is %s mounted in %s\n",
keyValue(mountpoint),
keyName(mountpoint));
kdbClose (handle);
KDB * kdbOpen(const KeySet *contract, Key *errorKey)
Opens the session with the Key database.
Definition: kdb.c:413
int kdbClose(KDB *handle, Key *errorKey)
Closes the session with the Key database.
Definition: kdb.c:585
const char * keyName(const Key *key)
Returns a pointer to the abbreviated real internal key name.
Definition: elektra/keyname.c:256
const void * keyValue(const Key *key)
Return a pointer to the real internal key value.
Definition: keyvalue.c:163
Parameters
handleis the data structure, where the mounted directories are saved.
wherethe key name, that should be looked up.
Returns
the mountpoint associated with the key

◆ mountModules()

int mountModules ( KDB *  kdb,
KeySet *  modules,
Key *  errorKey 
)

Mount all module configurations.

Parameters
kdbthe handle to work with
modulesthe current list of loaded modules
errorKeythe key used to report warnings
Return values
-1if not rootkey was found
0otherwise

◆ mountOpen()

int mountOpen ( KDB *  kdb,
KeySet *  config,
KeySet *  modules,
Key *  errorKey 
)

Creates a trie from a given configuration.

The config will be deleted within this function.

Note
mountDefault is not allowed to be executed before
Parameters
kdbthe handle to work with
modulesthe current list of loaded modules
configthe configuration which should be used to build up the trie.
errorKeythe key used to report warnings
Return values
-1on failure
0on success

◆ mountVersion()

int mountVersion ( KDB *  kdb,
Key *  errorKey 
)

Mount the version backend.

Parameters
kdbthe handle to work with
errorKeythe key used to report warnings
Return values
0on success