linuxkit/projects/shiftfs
Avi Deitcher 14c29db5c2
Containerd v2.0.3 (#4112)
* containerd to semver v2.0.3

Signed-off-by: Avi Deitcher <avi@deitcher.net>

* containerd v2.0.3 plus commits to fix blkdiscard

Signed-off-by: Avi Deitcher <avi@deitcher.net>

* update containerd-dev dependencies

Signed-off-by: Avi Deitcher <avi@deitcher.net>

* updated pkg/init and pkg/containerd deps

Signed-off-by: Avi Deitcher <avi@deitcher.net>

---------

Signed-off-by: Avi Deitcher <avi@deitcher.net>
2025-03-06 17:12:07 +02:00
..
patches-4.11.x projects: add shiftfs project 2017-06-13 11:08:29 -06:00
Dockerfile projects: add shiftfs project 2017-06-13 11:08:29 -06:00
kernel_config-4.11.x projects: add shiftfs project 2017-06-13 11:08:29 -06:00
kernel_config.debug projects: add shiftfs project 2017-06-13 11:08:29 -06:00
Makefile Remove Notary and Content Trust 2021-03-30 14:51:11 +01:00
README.md fix typo 2017-06-13 14:05:42 -06:00
shiftfs.yml Containerd v2.0.3 (#4112) 2025-03-06 17:12:07 +02:00

shiftfs

Shiftfs is a virtual filesystem for mapping mountpoints across user namespaces. The idea is that it would be useful for dockerds spawning containers: they can keep filesystems on the host disk in terms of real root, but mount the container roots via shiftfs, allowing containers to share a particular filesystem with different uid maps, while not having to uidshift every file on disk (and thus destroying some of the sharing properties).

The version included here is the v2 version of shiftfs, using the superblock's user namespace instead of mountopts to figure out mappings. Thus, an extra step of "marking" mounts is needed. For example:

# mkdir source
# touch source/foo  # a root owned file
# mount -t shiftfs -o mark source source
# chmod 777 source

Now, let's make a user namespace:

# setuid 1000 unshare -rm
# cat /proc/self/uidmap
         0       1000          1
# mkdir dest
# mount -t shiftfs source dest
# stat dest/foo | grep Uid
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)

And thanks to the magic of shiftfs, the file is root owned in the user namespace.