Slide 1

Slide 1 text

FUSE: Being where you aren't, seeing what I can't. Steven Lembark Workhorse Computing [email protected]

Slide 2

Slide 2 text

In the beginning was System7 And it was good... enough. One big innovation: mount points. No device names, just "absolute paths" One "filesystem" to rule them all.

Slide 3

Slide 3 text

I nodes, you nodes, we all need... Another innovation: "node" vs "link". Directory is a flat file of inodes + names. "Inode" has ownership, mods, allocation. Allows for symlinks.

Slide 4

Slide 4 text

Directory as indirection. One aside...

Slide 5

Slide 5 text

Directory as indirection. Directories Directories are are not not Folders Folders

Slide 6

Slide 6 text

UNIX Directories Dir contents are universal. dirent = basename -> inode

Slide 7

Slide 7 text

UNIX Directories Dir contents are universal. dirent = basename -> inode “link”

Slide 8

Slide 8 text

UNIX Directories Inodes defined by filesystem. Owner, group, mods, size, type... Can vary by filesystem type.

Slide 9

Slide 9 text

UNIX Directories Inodes defined by filesystem. Owner, group, mods, size, type... Can vary by filesystem type. stat( inode ) returns data.

Slide 10

Slide 10 text

UNIX Directories Inodes defined by filesystem. Owner, group, mods, size, type... Can vary by filesystem type. stat can be expensive.

Slide 11

Slide 11 text

Directory as indirection. Filesystem requires kernel support. Indirection across physical devices.

Slide 12

Slide 12 text

Directory as indirection. Filesystem requires kernel support. Hey, what about remote devices? NFS extended "inode" to "vnode". ”virtual node”

Slide 13

Slide 13 text

"vnode" abstracts device Replace single "filesystem". More OO-ish: vnode has "handler". Allows for multiple filesystem types. Semantics are specific to handler.

Slide 14

Slide 14 text

One thing didn't change Q: What do: LVM, NFS, XFS, BTRFS, F2FS, ext2, ext3, ext4, proc, sysfs, tmpfs have in common?

Slide 15

Slide 15 text

One thing didn't change Q: What do: LVM, NFS, XFS, BTRFS, F2FS, ext2, ext3, ext4, proc, sysfs, tmpfs have in common? A: /etc/fstab The only way to get there from here.

Slide 16

Slide 16 text

/etc/fstab makes mounts SU-only Only SU can "mount" or "umount". "users" allows mounting by non-SU UID's. Only at locations defined by /etc/fstab. Defined by SU.

Slide 17

Slide 17 text

Getting personal Some filesystems are personal: Only make sense to one UID at a time. Possibly only one process. Examples: Encryption. Access via ssh.

Slide 18

Slide 18 text

Breaking the tyranny: FUSE "fusermount" allows non-SU mounts. May be private to process or UID mounting. May be invisible to other proc's or UIDS.

Slide 19

Slide 19 text

A bit of indirection "Normal" mounts go into the kernel. FUSE mounts come back out again:

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Available for any number of systems Fuse for FreeBSD Fuse4X (now merged with OSXFuse.) MacFUSE OSXFuse successor to MacFUSE Dokan Windows user mode NetBSD starting with NetBSD-6.0 MINIX 3 starting with version 3.2.0

Slide 22

Slide 22 text

Example: sshfs Replace NFS with ssh. Secure. Less chatty: single mountpoint. User mounts in their own space.

Slide 23

Slide 23 text

Example: sshfs ssh connection is specific to a process. Or process group. sshfs not well suited to general mounts.

Slide 24

Slide 24 text

Mounting sshfs Step 1: Make sure ssh works. $ ssh-add; $ ssh jeeves; +lembark@dizzy ~ $

Slide 25

Slide 25 text

Executing sshfs mount One approach: /etc/fstab. Saves remembering it all. Fine for a desktop: only one user.

Slide 26

Slide 26 text

/etc/fstab entry for sshfs jeeves:/images /mnt/remote/images \ fuse.sshfs \ user,noauto,nonempty,reconnect 0 0 Filesytem type "fuse.sshfs" Delegates mount. "users" allows non-SU mount.

Slide 27

Slide 27 text

Do it manually "sshfs" is user-land mount utility: $ sshfs jeeves:/var/tmp /var/tmp/11061/ $ sshfs -u jeeves:/var/tmp /var/tmp/11061/

Slide 28

Slide 28 text

Make it magical afuse is a userland automounter: $ afuse -o mount_template='sshfs \ -o ServerAliveInterval=10 \ -o reconnect %r:/ %m' \ -o unmount_template= \ 'fusermount -u -z \ %m' ~/mnt/ssh ;

Slide 29

Slide 29 text

FUSE mounts are private Non-SU proc's mount for themselves. sshfs option: "allow_other". Makes mounts visible to other users. Without even SU cannot see contents.

Slide 30

Slide 30 text

Hide your porn encfs == encrypted FUSE. Passphrase required to mount volume. SU cannot access deciphered content. SU can back up enciphered space.

Slide 31

Slide 31 text

Example: My notebook ~lembark/.bash_profile: cd /var/tmp; /opt/bin/extmount $HOME; cd $HOME; exec bash --login

Slide 32

Slide 32 text

It takes two to tango Or mount encfs: one enciphered, one not. drwxr-s--- 71 lembark lembark 12288 Mar 9 17:56 lembark drwxr-s--- 71 lembark lembark 12288 Mar 9 17:56 .lembark

Slide 33

Slide 33 text

The enchpered portion is visible to others But not very useful: $ ls -1 total 262689 0d9jdsFuZmhxlsqwQ7GMV,Pt 0KvCQ2RXsi2YTGe7K0G3OHtG 0NzQCAtLUiL1XTAfFjzPfBID ...

Slide 34

Slide 34 text

Mounting the encfs #!/bin/bash mount=${1-$HOME}; shadow=$(dirname $mount)/.$(basename $mount); /usr/bin/encfs –ondemand \ --extpass=/opt/bin/extpass -i 60 $shadow \ $mount -o nonempty ;

Slide 35

Slide 35 text

Getting the password Encfs wants md5, not text. Fix: Grab the input and output md5_hex: #!/bin/perl my $phrase = shift || acquire_password; say md5_base64 $phrase;

Slide 36

Slide 36 text

Backing up # ls /home/lembark ls: cannot access /home/lembark: Permission denied SU can back up /home/.lembark. Backups are enciphered.

Slide 37

Slide 37 text

More examples adbfs Android via USB. CloudFusion DropBox, Google Drive... fuse-archive Read-only compressed. gphotofs Mount a camera. s3fs AWS S3 as a filesytem

Slide 38

Slide 38 text

Bedside Reading The Design and Implementation of the 4.3BSD UNIX Operating System Sam Leffler, Kirk McKusick, Michael Karels & John Quartermann. 1989, Addison-Wesley. ISBN 0-201-06196-1.

Slide 39

Slide 39 text

Bedside Reading https://www.usenix.org/legacy/events/ usenix99/full_papers/zadok/zadok.pdf Extending File Systems Using Stackable Templates

Slide 40

Slide 40 text

Bedside Reading https://github.com/pcarrier/afuse/ Userland fuse automounter.

Slide 41

Slide 41 text

Bedside Reading $ man mount.sshfs; $ man -k encfs;

Slide 42

Slide 42 text

Bedside Reading https://wiki.archlinux.org/title/FUSE Nice list of fuse systems.