Home

Awesome

<img src="https://zboxfs.github.io/zbox/images/logo.svg" alt="ZboxFS Logo" height="96" /> ZboxFS

GitHub action Crates.io Crates.io GitHub last commit license GitHub stars

ZboxFS is a zero-details, privacy-focused in-app file system. Its goal is to help application store files securely, privately and reliably. By encapsulating files and directories into an encrypted repository, it provides a virtual file system and exclusive access to authorised application.

Unlike other system-level file systems, such as ext4, XFS and Btrfs, which provide shared access to multiple processes, ZboxFS is a file system that runs in the same memory space as the application. It provides access to only one process at a time.

By abstracting IO access, ZboxFS supports a variety of underlying storage layers, including memory, OS file system, RDBMS and key-value object store.

Disclaimer

ZboxFS is under active development, we are not responsible for any data loss or leak caused by using it. Always back up your files and use at your own risk!

Features

Comparison

Many OS-level file systems support encryption, such as EncFS, APFS and ZFS. Some disk encryption tools also provide virtual file system, such as TrueCrypt, LUKS and VeraCrypt.

This diagram shows the difference between ZboxFS and them.

Comparison

Below is the feature comparison list.

ZboxFSOS-level File SystemsDisk Encryption Tools
Encrypts file contents:heavy_check_mark:partial:heavy_check_mark:
Encrypts file metadata:heavy_check_mark:partial:heavy_check_mark:
Encrypts directory:heavy_check_mark:partial:heavy_check_mark:
Data integrity:heavy_check_mark:partial:heavy_multiplication_x:
Shared access for processes:heavy_multiplication_x::heavy_check_mark::heavy_check_mark:
Deduplication:heavy_check_mark::heavy_multiplication_x::heavy_multiplication_x:
Compression:heavy_check_mark:partial:heavy_multiplication_x:
Content versioning:heavy_check_mark::heavy_multiplication_x::heavy_multiplication_x:
COW semantics:heavy_check_mark:partial:heavy_multiplication_x:
ACID Transaction:heavy_check_mark::heavy_multiplication_x::heavy_multiplication_x:
Varieties of storages:heavy_check_mark::heavy_multiplication_x::heavy_multiplication_x:
API access:heavy_check_mark:through VFSthrough VFS
Symbolic links:heavy_multiplication_x::heavy_check_mark:depends on inner FS
Users and permissions:heavy_multiplication_x::heavy_check_mark::heavy_check_mark:
FUSE support:heavy_multiplication_x::heavy_check_mark::heavy_check_mark:
Linux and macOS support:heavy_check_mark::heavy_check_mark::heavy_check_mark:
Windows support:heavy_check_mark:partial:heavy_check_mark:

Supported Storage

ZboxFS supports a variety of underlying storages. Memory storage is enabled by default. All the other storages can be enabled individually by specifying its corresponding Cargo feature when building ZboxFS.

StorageURI identifierCargo Feature
Memory"mem://"N/A
OS file system"file://"storage-file
SQLite"sqlite://"storage-sqlite
Redis"redis://"storage-redis
Zbox Cloud Storage"zbox://"storage-zbox-native

* Visit zbox.io to learn more about Zbox Cloud Storage.

Specs

Algorithm and data structureValue
Authenticated encryptionAES-256-GCM or XChaCha20-Poly1305
Password hashingArgon2
Key derivationBLAKE2B
Content dedupRabin rolling hash
File dedupMerkle tree
Index structureLog-structured merge-tree
CompressionLZ4 in fast mode

Limits

LimitValue
Data block size8 KiB
Maximum encryption frame size128 KiB
Super block size8 KiB
Maximum filename lengthNo limit
Allowable characters in directory entriesAny UTF-8 character except /
Maximum pathname lengthNo limit
Maximum file size16 EiB
Maximum repo size16 EiB
Max number of filesNo limit

Metadata

MetadataValue
Stores file ownerNo
POSIX file permissionsNo
Creation timestampsYes
Last access / read timestampsNo
Last change timestampsYes
Access control listsNo
SecurityIntegrated with crypto
Extended attributesNo

Capabilities

CapabilityValue
Hard linksNo
Symbolic linksNo
Case-sensitiveYes
Case-preservingYes
File Change LogBy content versioning
Filesystem-level encryptionYes
Data deduplicationYes
Data checksumsIntegrated with crypto
Offline growNo
Online growAuto
Offline shrinkNo
Online shrinkAuto

Allocation and layout policies

FeatureValue
Address allocation schemeAppend-only, linear address space
Sparse filesNo
Transparent compressionYes
ExtentsNo
Copy on writeYes

Storage fragmentation

FragmentationValue
Memory storageNo
File storagefragment unit size < 32 MiB
RDBMS storageNo
Key-value storageNo
Zbox cloud storagefragment unit size < 128 KiB

How to use

For reference documentation, please visit documentation.

Requirements

Supported Platforms

32-bit and other OS are NOT supported yet.

Usage

Add the following dependency to your Cargo.toml:

[dependencies]
zbox = "0.9.2"

If you don't want to install libsodium by yourself, simply specify libsodium-bundled feature in dependency, which will automatically download, verify and build libsodium.

[dependencies]
zbox = { version = "0.9.2", features = ["libsodium-bundled"] }

Example

extern crate zbox;

use std::io::{Read, Write, Seek, SeekFrom};
use zbox::{init_env, RepoOpener, OpenOptions};

fn main() {
    // initialise zbox environment, called first
    init_env();

    // create and open a repository in current OS directory
    let mut repo = RepoOpener::new()
        .create(true)
        .open("file://./my_repo", "your password")
        .unwrap();

    // create and open a file in repository for writing
    let mut file = OpenOptions::new()
        .create(true)
        .open(&mut repo, "/my_file.txt")
        .unwrap();

    // use std::io::Write trait to write data into it
    file.write_all(b"Hello, World!").unwrap();

    // finish writing to make a permanent content version
    file.finish().unwrap();

    // read file content using std::io::Read trait
    let mut content = String::new();
    file.seek(SeekFrom::Start(0)).unwrap();
    file.read_to_string(&mut content).unwrap();
    assert_eq!(content, "Hello, World!");
}

Build with Docker

ZboxFS comes with Docker support, which made building ZboxFS easier. Check each repo for more details.

Static linking with libsodium

By default, ZboxFS uses dynamic linking when it is linked with libsodium. If you want to change this behavior and use static linking, you can enable below two environment variables.

On Linux/macOS,

export SODIUM_LIB_DIR=/path/to/your/libsodium/lib
export SODIUM_STATIC=true

On Windows,

set SODIUM_LIB_DIR=C:\path\to\your\libsodium\lib
set SODIUM_STATIC=true

And then re-build the code.

cargo build

Performance

The performance test is run on a Macbook Pro 2017 laptop with spec as below.

SpecValue
Processor Name:Intel Core i7
Processor Speed:3.5 GHz
Number of Processors:1
Total Number of Cores:2
L2 Cache (per Core):256 KB
L3 Cache:4 MB
Memory:16 GB
OS Version:macOS High Sierra 10.13.6

Test result:

ReadWriteTPS
Baseline (memcpy):3658.23 MB/s3658.23 MB/sN/A
Baseline (file):1307.97 MB/s2206.30 MB/sN/A
Memory storage (no compress):605.01 MB/s186.20 MB/s1783 tx/s
Memory storage (compress):505.04 MB/s161.11 MB/s1180 tx/s
File storage (no compress):445.28 MB/s177.39 MB/s313 tx/s
File storage (compress):415.85 MB/s158.22 MB/s325 tx/s

To run the performance test on your own computer, please follow the instructions in CONTRIBUTING.md.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms of conditions.

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Community

License

ZboxFS is licensed under the Apache 2.0 License - see the LICENSE file for details.