ffstools

module
v0.20.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2026 License: Apache-2.0

README

Command-line tools for FFS

See also https://github.com/creachadair/ffs.

GoDoc CI

Overview

  • The ffs tool supports running and communicating with a blob storage service, and provides commands to manipulate the contents of the store as FFS specific messages.

    # To install:
    go install github.com/creachadair/ffstools/ffs@latest
    

    When installing, you may want to specify build --tags to enable other storage backends. See Storage Backends.

  • The file2json tool decodes wire-format node messages and translates them to JSON for easier reading by humans.

    # To install:
    go install github.com/creachadair/ffstools/file2json@latest
    

Installation and Usage

Install ffs as noted above, then the following example should work as-written:

# Start up a storage server using local files as storage, and run a
# shell with the server addressed via the FFS_STORE environment.
# THe storage server stops after the shell exits.
ffs storage --store file:test.db --listen demo.sock --exec bash -s <<EOF
  # Create a root pointer to anchor some data.
  ffs root create example --desc 'Example root pointer'

  # Create some files to import into storage.
  mkdir -p files/sub
  echo "This is my file." > files/sub/f1.txt
  echo "Many others are like it" > files/sub/f2.txt
  echo "But this one is mine." > files/f3.txt

  # Copy the files directory into the store.
  ffs import --into example/test1 files

  # List the contents we just wrote...
  ffs file list -long example/test1
  ffs file list -long example/test1/sub

  # Move some files around...
  echo "That was your file." > files/sub/f1.txt
  mv files/sub/f2.txt files/f4.txt
  rm files/f3.txt

  # Add another copy of the structure.
  ffs import -into example/test2 files

  # List the revised contents...
  ffs file list -long example/test1
  ffs file list -long example/test2
  ffs file list -long example/test2/sub

  # List the stuff reachable from the root.
  ffs file list -long -key example

  # GC unreachable data in the store.
  ffs gc
EOF
Encryption

The ffs storage subcommand supports encrypting the underlying store, using the --key flag, which accepts the path of a file containing the encryption key. In this mode, each object in the store is encrypted with an AEAD over ChaCha20poly1305.

To generate a random keyring file, for example:

% ffs storage keygen example.keyring
Passphrase: ****
(confirm) Passphrase: ****
Wrote a new 32-byte keyring to "example.keyring"

This will prompt you to enter a passphrase to unlock the keyring, and initialize it with a randomly-generated key. You will be prompted again when starting up the store:

% ffs storage --store file:test.db --listen db.sock --key example.keyring
Passphrase for "example.keyring": ****

Storage Backends

The following storage backends are currently supported by default:

Type Description Implementation
memory In-memory storage (built-in) https://godoc.org/github.com/creachadair/ffs/blob/memstore
file Local directory (built-in) https://godoc.org/github.com/creachadair/ffs/storage/filestore

The following storage backends can be enabled by building with the specified tags:

Type/Tag Description Implementation Notes
badger BadgerDB docs LSM, fast, directory layout
bolt BoltDB docs B-tree, single-file, slow writes
buntdb BuntDB docs Log-structured, single-file
gcs Google Cloud Storage docs No local storage; requires GCP credentials
pebble PebbleDB docs LSM, directory; RocksDB layout
rosedb RoseDB docs LSM, multiple files, Bitcask layout
s3 Amazon S3 docs No local storage; requires AWS credentials

For local storage, I generally use BadgerDB unless I want a single file, in which case I currently prefer BuntDB.

[!WARNING] Some of the storage engines used here have begun accepting commits largely authored by LLM coding tools. It is unclear whether the maintainers are doing appropiate diligence on the results. Use caution in applying them for production uses.

Directories

Path Synopsis
ffs
config
Package config defines the configuration settings shared by the subcommands of the ffs command-line tool.
Package config defines the configuration settings shared by the subcommands of the ffs command-line tool.
internal/cmdblob
Package cmdblob provides basic support for reading and writing implementations of the blob.Store interface.
Package cmdblob provides basic support for reading and writing implementations of the blob.Store interface.
internal/cmddebug
Package cmddebug implements the "ffs debug" subcommand family.
Package cmddebug implements the "ffs debug" subcommand family.
internal/cmdexport
Package cmdexport implements the "ffs export" subcommand.
Package cmdexport implements the "ffs export" subcommand.
internal/cmdfile
Package cmdfile implements the "ffs file" subcommand.
Package cmdfile implements the "ffs file" subcommand.
internal/cmdgc
Package cmdgc implements the "ffs gc" subcommand.
Package cmdgc implements the "ffs gc" subcommand.
internal/cmdimport
Package cmdimport implements the "ffs import" subcommand.
Package cmdimport implements the "ffs import" subcommand.
internal/cmdmirror
Package cmdmirror implements the "ffs mirror" subcommand.
Package cmdmirror implements the "ffs mirror" subcommand.
internal/cmdmount
Package cmdmount implements the "ffs mount" subcommand.
Package cmdmount implements the "ffs mount" subcommand.
internal/cmdroot
Package cmdroot implements the "ffs root" subcommand.
Package cmdroot implements the "ffs root" subcommand.
internal/cmdstatus
Package cmdstatus implements the "ffs status" subcommand.
Package cmdstatus implements the "ffs status" subcommand.
internal/cmdstorage
Package cmdstorage implements the "ffs storage" subcommand.
Package cmdstorage implements the "ffs storage" subcommand.
internal/cmdstorage/registry
Package registry carries the registry of available storage implementations.
Package registry carries the registry of available storage implementations.
internal/cmdsync
Package cmdsync implements the "ffs sync" subcommand.
Package cmdsync implements the "ffs sync" subcommand.
internal/cmdweb
Package cmdweb implements the "ffs web" subcommand.
Package cmdweb implements the "ffs web" subcommand.
Program ffsgocache implements the GOCACHEPROG protocol to implement a cache for the Go toolchain.
Program ffsgocache implements the GOCACHEPROG protocol to implement a cache for the Go toolchain.
lib
exportlib
Package exportlib defines common plumbing for exporting file trees into archives and other filesystems.
Package exportlib defines common plumbing for exporting file trees into archives and other filesystems.
importlib
Package importlib implements common plumbing for copying file trees from a local filesystem into FFS representation.
Package importlib implements common plumbing for copying file trees from a local filesystem into FFS representation.
pbar
Package pbar implements a simple percentage-based terminal progress indicator.
Package pbar implements a simple percentage-based terminal progress indicator.
scanlib
Package scanlib implements a basic reachability scanner for FFS data blobs, files, and root pointers.
Package scanlib implements a basic reachability scanner for FFS data blobs, files, and root pointers.
storeclient
Package storeclient defines helpers for connecting to a storage service.
Package storeclient defines helpers for connecting to a storage service.
storeservice
Package storeservice implements a storage service over Chirp.
Package storeservice implements a storage service over Chirp.
zstdc
Package zstdc implements the encoded.Codec interface using zstd compression.
Package zstdc implements the encoded.Codec interface using zstd compression.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL