Commit Graph

23 Commits

Author SHA1 Message Date
Kir Kolyshkin b7fb12e894 Remove unneeded conversion
Those are the cases where the value being converted is already of that
type (checked to be that way for all os/arch combinations).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-01 16:18:43 -07:00
Kir Kolyshkin 83c0c077c5 all: remove old-style +build tags
Brought to you by

	go fix ./...

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-09-19 17:00:48 -07:00
Jan Rodák 4485ffa7a6
Fix errcheck: error return value of `unix.Unmount` is not checked
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2024-07-09 17:29:06 +02:00
Giuseppe Scrivano 6dadae0f0d
overlay, composefs: use data-only lower layers
use the new overlay data-only feature to mount the composefs data
directory so there is no need for upper layers to create whiteouts to
hide payload files.

The feature was added to Linux 6.5.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-10-02 09:53:08 +02:00
Kir Kolyshkin a4d8f720a2 Format sources with gofumpt
gofumpt is a superset of gofmt, enabling some more code formatting
rules.

This commit is brought to you by

	gofumpt -w .

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-05-26 16:17:31 -07:00
Nalin Dahyabhai ca4d7dd4fc drivers/overlay.get(): only use the relative workdir for mountOverlayFrom()
When we convert the work directory's location to a relative path for
passing to mount-in-a-subprocess, don't change the value that we'll
subsequently use when removing the "work/incompat/volatile" subdirectory
while still in the parent process.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-05-17 17:15:04 -04:00
Giuseppe Scrivano 90a1a54933
idmap: new package
move the idmap utils from the overlay driver to a separate package.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-01-27 17:07:42 +01:00
Nalin Dahyabhai c1adb196b8 Tweak a couple of error messages
Add missing punctuation to a couple of error messages, and include which
mount options we tried to use when we complain about mount() failing.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2022-09-14 11:08:47 -04:00
Miloslav Trmač a1ccc9d862 Use os.WriteFile instead of ioutil.WriteFile
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-09-12 16:31:34 +02:00
Miloslav Trmač 23bac7e055 Use os.MkdirTemp instead of ioutil.TempDir
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-09-12 16:30:47 +02:00
Daniel J Walsh 3f8c0dc0de
Wrap errors properly with fmt.Errorf
Also returned errors should not begine with a capatalized errors.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-07-12 13:26:10 -04:00
Sascha Grunert 3455d12729
Switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of the
deprecated github.com/pkg/errors package.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-07 13:22:46 +02:00
Giuseppe Scrivano b9b8a592d4
overlay: use idmapped lower layers where supported
use idmapped mounts for the overlay lower layers when the kernel
supports them.

For each lower directory with ID=0...N-1, it creates a idmapped mount
at $GRAPHROOT/overlay/$LAYER/mapped/$ID.  The final overlay mount will
use these idmapped mounts instead of the original source directory.

The upperdir is not idmapped, so files are created with the same
IDs used by the user namespace.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-04-08 16:56:23 +02:00
Giuseppe Scrivano 1e81ec1dba
overlay: fix check for rootless native diff
make sure "userxattr" is specified, otherwise the "user.overlay."
xattrs are not treated specially and copied up as for the root case.

Closes: https://github.com/containers/storage/issues/947

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-06-22 14:13:42 +02:00
Giuseppe Scrivano 0c5ccab411
overlay: check for unix.ENOTSUP
if lgetxattr(..., "user.overlay.metacopy") fails with EOPNOTSUPP, it
means metacopy is not supported for the current user.

Prefer this runtime check instead of testing unshare.IsRootless(), so
that metacopy support will be detected in case it will be enabled in a
user namespace in future.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-05-20 10:32:10 +02:00
Giuseppe Scrivano 345bc79f84
overlay, rootless: use user.* instead of trusted.*
unprivileged users cannot use the trusted.* xattrs.  Since for
rootless we always mount overlay with userxattr, we can just check if
running in rootless mode and use user.* instead of trusted.*.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-04-06 17:10:25 +02:00
Daniel J Walsh 38e784fe4a
We should ignore metacopy option on kernels that do not support it
Distributions are shipping metacopy option along with kernels that do
not support it.  We should warn on this situation rather then fail.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-02-15 08:31:17 -05:00
Giuseppe Scrivano ffe1eb2df5
drivers: add support for volatile to overlay
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-02-11 10:13:28 +01:00
Daniel J Walsh d5d5c4c92d
Add mountoptions to help figure out why mount failed
Fuse-overlay now has an option fsync=0, which kernel overlay does
not support, when I changed from fuse-overlay, to regular with
the fsync=0 flag set, I had a hard time diagnosing what was going
wrong. This information would have helped.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-15 16:33:19 -04:00
Nalin Dahyabhai 05c69f1b2a overlay: check if metacopy is happening
In the overlay driver, check if metacopy is enabled, and report it along
with other status information.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-01-17 14:14:10 -05:00
Daniel J Walsh ab4364860e
Pass mount options to useNaiveDiff
If in storage.conf I set the mount options to:
mountopt = "nodev,metacopy=on,redirect_dir=on"
This will turn on redirect_dir but the useNaiveDiff does not currently check
this option.  This will cause container images on commit to not be saved
correctly.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-10-25 15:33:00 -04:00
Daniel J Walsh 09480532cf Fallback to use naive diff driver if enable CONFIG_OVERLAY_FS_REDIRECT_DIR
Grab Lei Jitang <leijitang@huawei.com> patches from
github.com/Moby/Moby/49c3a7c4bac2877265ef8c4eaf210159560f08b4

    When use overlay2 as the graphdriver and the kernel enable
    `CONFIG_OVERLAY_FS_REDIRECT_DIR=y`, rename a dir in lower layer
    will has a xattr to redirct its dir to source dir. This make the
    image layer unportable. This patch fallback to use naive diff driver
    when kernel enable CONFIG_OVERLAY_FS_REDIRECT_DIR

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-10-05 15:27:54 -04:00
Daniel J Walsh e5f58bf9c2 Backport moby overlay driver changes to containers/storage
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-09-26 20:45:15 +00:00