Skip to content

A Linux filesystem that implements a key-value store.

License

Notifications You must be signed in to change notification settings

j4cobgarby/kvfs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kvfs - A simple key-value store filesystem for Linux.

Usage Example

Once the filesystem is mounted, you can use it as following. We'll assume it's mounted at /dev/kvs1 for this example. You may mount as many kvfs instances as you need.

# Create a new empty key called 'my_key'
$ echo -n my_key > /dev/kvs1/_mk

# Set the value of 'my_key' to 'Hello, world!'
$ echo -n "Hello, world!" > /dev/kvs1/my_key

# Read the value of 'my_key'
$ cat /dev/kvs1/my_key

# Delete the key 'my_key'
$ echo -n my_key > /dev/kvs1/_del

The above example accesses the key-value store using shell commands, which can be a convenient way to do it. Of course, though, this filesystem can be used just as well from any programming language.

mkf = open("/dev/kvs1/_mk", "wb", buffering=0)
delf = open("/dev/kvs1/_del", "wb", buffering=0)

# Create a new key. You may need to mkf.flush().
mkf.write(b"newkey")

k1 = open("/dev/kvs1/newkey", "r+b", buffering=0)
k1.write(b"Some data")
print(k1.read())

delf.write(b"newkey")

mkf.close()
delf.close()
k1.close()

Hopefully it's easy to see that this functionality could be nicely wrapped into a library, that would make it very simple for a programmer to use this key value store.

Installation

Build the kernel module with either make, or running init.sh.

make will just build the kernel module (which will be in build/kvfsmod.ko, whereas running init.sh will both build it and mount an instance of the filesystem to /dev/kvs1.

To build, you will need to have:

  • A C compiler toolchain (we use gcc)
  • The linux headers/module build scripts (which on Arch linux are in the package linux-headers)

Permissions

When mounting a kvfs instance, you can specify a GID. This GID will be given read/write permission to all the files within that specific instance. Kvfs will read this value from the mount options string, and it's the only mount option it accepts.

Running init.sh will mount an instance at /dev/kvs1, with the GID of the group "kvfs" as its mount option.

About

A Linux filesystem that implements a key-value store.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published