mount jetstream as a userspace character device on linux
at main 1.2 kB view raw
1excuse - mount jetstream as a character device on linux 2 3CUSE is FUSE's little brother, and it allows mounting a 4single character device file in /dev, with the device driver 5being implemented in userspace. 6 7unlike typical files, character devices like /dev/urandom 8are not seekable. they only support a streaming interface: 9 10 λ cat /dev/urandom # random numbers 11 12excuse simply mounts a websocket connection to an atproto 13jetstream as a userspace character device: 14 15 λ sudo RUST_LOG=info excuse 16 [2025-09-21 INFO excuse] Initializing CUSE at /dev/jetstream 17 [2025-09-21 INFO excuse] /dev/jetstream is now 0644 18 19in another terminal: 20 21 λ cat /dev/jetstream | jq 22 { 23 "did": "did:plc:s6zjj6aw652mmvsrs573j6ti", 24 "time_us": 1758442606746247, 25 "kind": "commit", 26 "commit": { ... } 27 } 28 . 29 . 30 . 31 32you will notice a couple of optimizations: 33 34 - the websocket is only opened when the file has readers, 35 and is closed when all readers are closed 36 - the same connection is shared by all readers 37 - the data is buffered and not sent byte by byte 38 39it is a bit of a gimmick however, you can do this easily 40with websocat: 41 42 λ websocat wss://jetstream1.us-east.fire.hose.cam/subscribe