github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbfs/README.md (about) 1 # Keybase Filesystem (KBFS) [![Build Status](https://travis-ci.org/keybase/kbfs.svg?branch=master)](https://travis-ci.org/keybase/kbfs) [![Build status](https://ci.appveyor.com/api/projects/status/xpxqhgpl60m1h3sb/branch/master?svg=true)](https://ci.appveyor.com/project/keybase/kbfs/branch/master) 2 3 This repository contains the official [Keybase](https://keybase.io) 4 implementation of the client-side code for the Keybase filesystem 5 (KBFS). See [the KBFS documentation](https://keybase.io/docs/kbfs) for an 6 introduction and overview. 7 8 ![Sharing](https://keybase.io/images/github/repo_share.png?) 9 10 All code is written in the [Go Language](https://golang.org), and relies 11 on the [Keybase 12 service](https://github.com/keybase/client/tree/master/go). 13 14 ### Architecture 15 16 This client allows you to mount KBFS as a proper filesystem at some 17 mountpoint on your local device (by default, `/keybase/`). It 18 communicates locally with the Keybase service, and remotely with three 19 types of KBFS servers (block servers, metadata servers, and key 20 servers). 21 22 The code is organized as follows: 23 24 - [cache](cache/): Generic cache data structures. 25 - [data](data/): Data structures and logic for KBFS file and directory data. 26 - [dokan](dokan/): Helper code for running Dokan filesystems on Windows. 27 - [env](env/): Code to implement libkbfs.Context in terms of libkb. 28 - [favorites](favorites/): Data structures for the favorited lists of 29 top-level folders (TLFs) that appear under private/, public/, and 30 team/. 31 - [fsrpc](fsrpc/): RPC interfaces that connected clients can call in KBFS, 32 to do certain operations, such as listing files. 33 - [idutil](idutil/): Basic data structures, interfaces, and helper 34 code for dealing with identity data for users and teams. 35 - [ioutil](ioutil/): Helper functions for I/O. 36 - [kbfsblock](kbfsblock/): Types and functions to work with KBFS blocks. 37 - [kbfscodec](kbfscodec/): Interfaces and types used for serialization in KBFS. 38 - [kbfscrypto](kbfscrypto/): KBFS-specific cryptographic types and functions. 39 - [kbfsdokan](kbfsdokan/): The main executable for running KBFS on 40 Windows. 41 - [kbfsfuse](kbfsfuse/): The main executable for running KBFS on Linux 42 and OS X. 43 - [kbfsgit](kbfsgit/): The main executable for the Keybase git remote helper. 44 - [kbfshash](kbfshash/): An implementation of the KBFS hash spec. 45 - [kbfsmd](kbfsmd/): Types and functions to work with KBFS TLF metadata. 46 - [kbfssync](kbfssync/): KBFS-specific synchronization primitives. 47 - [kbfstool](kbfstool/): A thin command line utility for interacting with KBFS 48 without using a filesystem mountpoint. 49 - [kbpagesconfig](kbpagesconfig/): Configuration code for Keybase Pages. 50 - [kbpagesd](kbpagesd/): The main executable for Keybase Pages. 51 - [libcontext](ldbutils/): KBFS-specific levelDB utility code. 52 - [libcontext](libcontext/): KBFS-specific context helper code. 53 - [libdokan](libdokan/): Library code gluing together KBFS and the 54 Dokan protocol. 55 - [libfs](libfs/): Common library code useful to any filesystem 56 presentation layer for KBFS. 57 - [libfuse](libfuse/): Library code gluing together KBFS and the FUSE 58 protocol. 59 - [libgit](libgit/): Library for git-related logic. 60 - [libhttpserver](libhttpserver/): Library for serving KBFS files with 61 a local HTTP server. 62 - [libkey](libkey/): Library for managing KBFS server keys and key metadata. 63 - [libkbfs](libkbfs/): The core logic for KBFS. 64 - [libmime](libmime/): Library for determining the MIME types of KBFS 65 files. 66 - [libpages](libpages/): Library for the logic behind Keybase Pages. 67 - [metricsutil](metricsutil/): Helper code for collecting metrics. 68 - [redirector](redirector/): The executable that redirects user FUSe 69 requests to the correct user KBFS mount. The redirector is usually 70 mounted at `/keybase` on Linux and macOS. 71 - [simplefs](simplefs/): A simple RPC-based interface to KBFS. 72 - [stderrutils](stderrutils/): A simple library for dealing with 73 stderr on different platforms. 74 - [sysutils](sysutils/): Library for dealing with platform-specific 75 systems stuff. 76 - [test](test/): A test harness with a domain-specific test language 77 and tests in that language. 78 - [tlf](tlf/): Code and structures for top-level folders (TLFs). 79 - [tlfhandle](tlfhandle/): The data structure for "Handles" to 80 top-level folders (TLFs), which represent an identifier for each 81 TLF, containing all the user or team IDs associated with the it. 82 83 ### Status 84 85 KBFS currently works on both Linux (at least Debian, Ubuntu and Arch), 86 OS X, and Windows. It is approaching release ready, though currently 87 it is still in alpha. There may still be bugs, so please keep backups 88 of any important data you store in KBFS. Currently our pre-built 89 packages are available by invitation only. 90 91 KBFS depends in part on the following awesome technologies to present 92 a mountpoint on your device: 93 94 - [FUSE](https://github.com/libfuse/) (on Linux) 95 - [FUSE for OS X](https://osxfuse.github.io/) (on OS X) 96 - [Dokany](https://github.com/dokan-dev/dokany) (on Windows) 97 98 See [our vendor directory](vendor/) for a complete list of open source 99 packages KBFS uses. 100 101 Currently, our server implementations are not open source. 102 103 ### To run from source against production KBFS servers 104 105 #### On Linux or OS X: 106 107 Prerequisites: 108 109 - [Go 1.15](https://golang.org/dl/) or higher. 110 - A running Keybase client service (see [instructions](https://github.com/keybase/client/tree/master/go)). 111 - On OS X, you may have to [install FUSE yourself](https://osxfuse.github.io/). 112 - You may need to pass the `--use-system-fuse` flag to `kbfsfuse` if 113 you install FUSE yourself. 114 - Then, mount KBFS at `/keybase/` as follows: 115 116 ```bash 117 cd kbfsfuse 118 go install 119 mkdir -p /keybase && sudo chown $USER /keybase 120 KEYBASE_RUN_MODE=prod kbfsfuse /keybase 121 ``` 122 123 Note that our pre-built packages for OS X include a branded version of 124 FUSE for OS X, to ensure that it doesn't conflict with other local 125 FUSE installations. It is still open source -- see 126 [here](https://github.com/keybase/client/blob/master/osx/Fuse/build.sh) 127 to see how we build it. 128 129 #### On Windows: 130 131 See our [kbfsdokan](kbfsdokan/) documentation. 132 133 #### On FreeBSD: 134 135 There are instructions for getting KBFS running on FreeBSD 136 [here](https://wiki.freebsd.org/Ports/security/kbfs). This is a 137 user-supported effort, which is not officially supported by the 138 Keybase team at the moment. 139 140 ### To run from source against local in-memory servers 141 142 ```bash 143 kbfsfuse -bserver=memory -mdserver=memory -localuser strib /keybase 144 ``` 145 146 (Use `-bserver=dir:/path/to/dir` and `-mdserver=dir:/path/to/dir` if 147 instead you want to save your data to local disk.) 148 149 Now you can do cool stuff like: 150 151 ```bash 152 ls /keybase/private/strib 153 echo blahblah > /keybase/private/strib/foo 154 ls /keybase/private/strib,max 155 ``` 156 157 (Note that "localuser" mode has only four hard-coded users to play 158 with: "strib", "max", "chris", and "fred".) 159 160 ### Code style 161 162 We require all code to pass `gofmt` and `govet`. You can install our 163 precommit hooks to make sure your code passes `gofmt` and `govet`: 164 165 ```bash 166 go get golang.org/x/tools/cmd/vet 167 ln -s $GOPATH/src/github.com/keybase/client/git-hooks/pre-commit $GOPATH/src/github.com/keybase/client/go/kbfs/.git/hooks/pre-commit 168 ``` 169 170 Though it doesn't happen automatically, we also expect your code to be 171 as "lint-free" as possible. Running golangci-lint is easy: 172 173 ```bash 174 golangci-lint --deadline 15m 175 ``` 176 177 ### Vendoring 178 179 KBFS vendors all of its dependencies into the local `vendor` 180 directory. To add or update dependencies, use the `govendor` tool, as 181 follows: 182 183 ```bash 184 go install github.com/kardianos/govendor 185 govendor add github.com/foo/bar # or `govendor update` 186 git add --all vendor 187 ``` 188 189 ### Testing 190 191 From kbfs/: 192 193 ```bash 194 go test -i ./... # install dependencies 195 go test ./... # run tests 196 ``` 197 198 If you change anything in interfaces.go, you will have to regenerate 199 the mock interfaces used by the tests (make sure you have [mockgen](https://github.com/golang/mock) 200 installed): 201 202 ```bash 203 cd libkbfs 204 ./gen_mocks.sh 205 ``` 206 207 (Right now the mocks are checked into the repo; this isn't ideal and 208 we should probably change it.) 209 210 ### Licensing 211 212 Most code is released under the New BSD (3 Clause) License. If 213 subdirectories include a different license, that license applies 214 instead. (Specifically, [dokan/dokan_header](dokan/dokan_header) and 215 most subdirectories in [vendor](vendor/) are released under their own 216 licenses.)