2019-02-26 05:13:58 +01:00
|
|
|
# tabfs
|
|
|
|
|
|
|
|
## Setup
|
|
|
|
|
|
|
|
You need to both install the Chrome extension and run the native
|
|
|
|
filesystem.
|
|
|
|
|
|
|
|
### Run the C filesystem
|
|
|
|
|
2020-10-24 07:47:59 +02:00
|
|
|
First, make sure you `git submodule update --init` to get the
|
|
|
|
`fs/cJSON` and `fs/base64` dependencies.
|
|
|
|
|
|
|
|
And make sure you have FUSE. On Linux, for example, `sudo apt install
|
|
|
|
libfuse-dev`. On macOS, get FUSE for macOS.
|
2019-02-26 05:13:58 +01:00
|
|
|
|
|
|
|
```
|
|
|
|
$ cd fs
|
|
|
|
$ mkdir mnt
|
2020-10-24 07:47:59 +02:00
|
|
|
$ make
|
2019-02-26 05:13:58 +01:00
|
|
|
```
|
|
|
|
|
2020-10-24 07:47:59 +02:00
|
|
|
### Install the Chrome extension
|
2019-02-26 05:13:58 +01:00
|
|
|
|
2020-10-24 07:47:59 +02:00
|
|
|
Go to the [Chrome extensions page](chrome://extensions).
|
2019-02-26 05:13:58 +01:00
|
|
|
|
2020-10-24 07:47:59 +02:00
|
|
|
Enable Developer mode. Load-unpacked the `extension/` folder in this repo.
|
2019-02-26 05:13:58 +01:00
|
|
|
|
|
|
|
Now your browser tabs should be mounted in `fs/mnt`!
|
|
|
|
|
|
|
|
## Design
|
|
|
|
|
|
|
|
- `extension/`: Browser extension, written in JS
|
|
|
|
- `fs/`: Native FUSE filesystem, written in C
|
2020-10-24 07:47:59 +02:00
|
|
|
- `tabfs.c`: Talks to FUSE, implements fs operations, talks to browser.
|
2019-02-26 05:13:58 +01:00
|
|
|
|
|
|
|
When you, say, `cat` a file in the tab filesystem:
|
|
|
|
|
|
|
|
1. `cat` makes something like a `read` syscall,
|
|
|
|
|
|
|
|
2. which goes to the FUSE kernel module which backs that filesystem,
|
|
|
|
|
|
|
|
3. FUSE forwards it to the `tabfs_read` implementation in our
|
|
|
|
userspace filesystem in `fs/tabfs.c`,
|
|
|
|
|
|
|
|
4. then `tabfs_read` rephrases the request as a JSON string and
|
2020-10-24 07:47:59 +02:00
|
|
|
forwards it to the browser extension over 'native messaging',
|
2019-02-26 05:13:58 +01:00
|
|
|
|
|
|
|
6. our browser extension in `extension/background.js` handles the
|
|
|
|
incoming message and calls the browser APIs to construct the data
|
|
|
|
for that synthetic file;
|
|
|
|
|
2020-10-24 07:47:59 +02:00
|
|
|
7. then the data gets sent back in a JSON native message to `tabfs.c`
|
|
|
|
and and finally back to FUSE and the kernel and `cat`.
|
2019-02-26 05:13:58 +01:00
|
|
|
|
|
|
|
(very little actual work happened here, tbh. it's all just
|
|
|
|
marshalling)
|
|
|
|
|
|
|
|
TODO: make diagrams?
|