Skip to content

Commit

Permalink
Merge pull request #2639 from mpranj/mmapstorage-export
Browse files Browse the repository at this point in the history
mmapstorage: add  import/export compatibility
  • Loading branch information
markus2330 committed Apr 22, 2019
2 parents 90d0808 + 9b3c6f4 commit 096900b
Show file tree
Hide file tree
Showing 7 changed files with 360 additions and 33 deletions.
5 changes: 5 additions & 0 deletions doc/news/_preparation_next_release.md
Expand Up @@ -271,6 +271,11 @@ The following section lists news about the [modules](https://www.libelektra.org/
- [cache](https://www.libelektra.org/plugins/cache) is a new global caching plugin. It uses [mmapstorage](https://www.libelektra.org/plugins/mmapstorage) as its storage backend and lazily stores keysets from previous ´kdbGet()´ calls. We added initial support for the default resolver and multifile resolver. _(Mihael Pranjić)_
- Add check of resolved filenames, fixes false cache hits. _(Mihael Pranjić)_

### mmapstorage

- [mmapstorage](https://www.libelektra.org/plugins/mmapstorage) is now able to persist the Global KeySet, which is used by the `cache` plugin. _(Mihael Pranjić)_
- Fixed support for `kdb import` and `kdb export`. _(Mihael Pranjić)_

## Libraries

The text below summarizes updates to the [C (and C++)-based libraries](https://www.libelektra.org/libraries/readme) of Elektra.
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/mmapstorage/README.md
Expand Up @@ -88,3 +88,8 @@ sudo kdb umount user/tests/mmapstorage
## Limitations

Mapped files shall not be altered, otherwise the behavior is undefined.

The `mmap()` system call only supports regular files and so does the mmapstorage
plugin with one notable exception: The plugin detects when it is called with the
files `/dev/stdin` and `/dev/stdout` and makes an internal copy. This makes the
plugin compatible with `kdb import` and `kdb export`.
11 changes: 10 additions & 1 deletion src/plugins/mmapstorage/internal.h
Expand Up @@ -37,9 +37,18 @@
/** Mmap format version */
#define ELEKTRA_MMAP_FORMAT_VERSION (1)

/** Mmap temp file template */
#define ELEKTRA_MMAP_TMP_NAME "/tmp/elektraMmapTmpXXXXXX"

/** Buffer size for file I/O */
#define ELEKTRA_MMAP_BUFSIZE (4096)

#define STDOUT_FILENAME ("/dev/stdout")
#define STDIN_FILENAME ("/dev/stdin")

/** Suppress warnings in cache mode to debug level */
#define ELEKTRA_MMAP_LOG_WARNING(...) \
if (mode == MODE_GLOBALCACHE) \
if (test_bit (mode, MODE_GLOBALCACHE)) \
{ \
ELEKTRA_LOG_DEBUG (__VA_ARGS__); \
} \
Expand Down

0 comments on commit 096900b

Please sign in to comment.