Skip to content

Hello world of 9p servers: serve JSON as a 9p filesystem.

Notifications You must be signed in to change notification settings

abbyssoul/mjstyxfs

Repository files navigation

mjstyxFS C++ standard License


TravisCI LGTM issues

An example of async 9P server using libapsio: serving JSON file(s) as a 9p filesystem.

Usage

Once you built the project you can start serving json files:

mjstyxfs -H tcp:127.0.0.1:1564 my-file.json

This command starts mjstyxfs listening for tcp connections on local host port 1564 and serving my-file.json file. To test the server you can use 9p client of your choice or - if your system supports 9pfs - you can mount new fs directly:

sudo mount -t 9p 127.0.0.1 <directory> \
    -o version=9p2000,port=1564,dfltuid=$(id -u),dfltgid=$(id -g)

This will mount json file to . You can then use normal cd, ls, cat or a file browser of your choice to explore the structure of the JSON file as filesystem.

Slightly more advance usage

libapsio can listen on multiple addresses and protocols at the same time.

mjstyxfs -H tcp:127.0.0.1:1564,tcp:0.0.0.0:5164 -H unix:/var/run/mjstyxfs.socket my-file.json

It is also possible to server multiple files at the same time.

mjstyxfs -H tcp:127.0.0.1:1564 my-file.json other-file.json data-file.json

Keep in mind that this is only a limited example though. Contributions are welcomed.

Building

The project requires C++ compiler supporting C++17 and is using CMake for build management. Default configuration requires ninja as build system. Makefile is only used for automation of some manual tasks.

cd <checkout directory>

# In the project check-out directory:
# To build debug version with sanitizer enabled (recommended for development)
./configure --prefix=/user/home/${USER}/bin

# To build the project. Takes care of CMake and conan dependencies
make

# To build and run unit tests:
make test

# To install into <prefix> location
make  install

If you need to build debug / instrumented version, it is recommended to use sanitisers

./configure --prefix=/user/home/${USER}/bin  --enable-debug --enable-sanitizer

Build tools

In order to build this project following tools must be present in the system:

  • git (to check out project and it’s external modules, see dependencies section)
  • cmake - user for build script generation
  • ninja (opional, used by default)
  • cppcheck (opional, but recommended for static code analysis, latest version from git is used as part of the 'codecheck' step)
  • cpplint (opional, for static code analysis in addition to cppcheck)
  • valgrind (opional, for runtime code quality verification)

Dependencies

Project dependencies are managed using Conan.io package manager. Make sure you have conan installed to build the project.

  • libapsio - asynchronous 9p server.
  • libclime - command line agruments parser.
  • GTest - unit test framework.

Testing

The project is using GTest for unit tests. The source code for unit test located in directory test

Test suit can (and should) be run via:

make test

Developers/Contributing

Please make sure that static code check step returns no error before raising a pull request

make codecheck

It is also a good idea to run Valgrind on the test suit to make sure that the memory is safe. Note, sanitizers are not compatible with Valgrind:

./configure --enable-debug --disable-sanitizer
make clean && make verify

Contributing changes

The framework is work in progress and contributions are very welcomed. Please see CONTRIBUTING.md for details on how to contribute to this project.

Please note that in order to maintain code quality a set of static code analysis tools is used as part of the build process. Thus all contributions must be verified by this tools before PR can be accepted.

License

The library available under Apache License 2.0 Please see LICENSE for details.

Authors

Please see AUTHORS file for the list of contributors.

About

Hello world of 9p servers: serve JSON as a 9p filesystem.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published