353 Commits

Author SHA1 Message Date
Giuseppe Scrivano
d4188a4f59
main, rename: fix leak on error
fix a fd leak on the error exit path.

Closes: https://github.com/containers/fuse-overlayfs/issues/289

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-04-16 20:36:35 +02:00
cptpcrd
defd480c0e main: improve UTIME_NOW special-casing
FUSE never passes FUSE_SET_ATTR_ATIME_NOW without also passing
FUSE_SET_ATTR_ATIME. Since FUSE_SET_ATTR_ATIME_NOW was only checked if
FUSE_SET_ATTR_ATIME was not set, it would never be triggered.

Note that this is an *improvement*, not a *fix*, because FUSE always
passes the current time in st_atim whenever it sets
FUSE_SET_ATTR_ATIME_NOW. As a result, the previous code works properly,
but it does so differently from the way it was intended to.

(All of the above descriptions of st_atim handling also applies to
st_mtim.)
2021-04-13 21:33:00 -04:00
cptpcrd
d23dbe914d main: tv_sec -> tv_nsec
As specified in utimensat(2), *tv_nsec*, not *tv_sec*, should be set to
UTIME_NOW or UTIME_OMIT.

The way this bug manifests is that if utimensat() is called with
one of the timestamps set to UTIME_OMIT, fuse-overlayfs will
accidentally reset the timestamp to 1073741822, which is 2004-01-10
13:37:02 UTC.
2021-04-13 21:32:57 -04:00
Giuseppe Scrivano
11ad142525
main: fix reading xattrs longer than 256 bytes
fix reading extended attributes longer than 256 bytes.

Closes: https://github.com/containers/fuse-overlayfs/issues/284

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-21 17:50:06 +01:00
David Hedberg
5ec356b29e main: Add option static_nlink to set st_nlink to 1 for all directories
Skips calculation of st_nlink for directories, which can be
expensive on higher latency file systems such as NFS.

Signed-off-by: David Hedberg <david.hedberg@gmail.com>
2021-03-16 18:51:42 +01:00
Giuseppe Scrivano
d612d48326
main: mark directory not loaded on rename
if a whiteout was created as part of a rename operation, mark the
directory content as not loaded so to avoid some optimizations when a
whiteout file must be deleted.

Closes: https://github.com/containers/fuse-overlayfs/issues/279

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-05 17:51:18 +01:00
Giuseppe Scrivano
062ec18711
main: honor FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT also for renames
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-05 14:56:55 +01:00
Giuseppe Scrivano
0d77a9fdd0
main: simplify logic for FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-05 14:56:35 +01:00
Giuseppe Scrivano
44561349cd
main: use strncpy instead of strcpy
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-04 11:04:48 +01:00
Giuseppe Scrivano
c1fd9a7e0b
main: ignore write error
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-04 11:03:14 +01:00
Giuseppe Scrivano
360a0c6bfd
main: drop unused variable
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-04 11:02:37 +01:00
Giuseppe Scrivano
5df063677b
main: check for asprintf return code
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-04 11:00:46 +01:00
Giuseppe Scrivano
450b0d790f
fuse-overlayfs: fix renameat2(RENAME_NOREPLACE)
when device whiteouts are created (supported for unprivileged users in
newer Linux kernels) make sure the RENAME_NOREPLACE flag is dropped
when renaming the file on top of an existing whiteout.

Closes: https://github.com/containers/fuse-overlayfs/issues/273

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-02-01 23:00:50 +01:00
Giuseppe Scrivano
6f2af48a03
main: check if whiteout device already exists
on newer kernels unprivileged users can create whiteout devices.  If
the whiteout device creation failed with EEXIST, check whether the
existing file is already a whiteout.

Closes: https://github.com/containers/fuse-overlayfs/issues/271

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-01-25 19:00:15 +01:00
Giuseppe Scrivano
3ae5b85c5b
main: fix compiler warning
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-01-20 09:29:05 +01:00
Giuseppe Scrivano
e5d35c9a01
main: add squash_to_uid and squash_to_gid
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-12-22 15:57:56 +01:00
Giuseppe Scrivano
33a2fa47c9
main: invalidate directory cache on create/rename
if we are adding a new file to a directory, the parent directory must
be invalidated if it is in the middle of a opendir/releasedir
otherwise the added files won't be cached.

Closes: https://github.com/containers/fuse-overlayfs/issues/259

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-11-11 15:34:01 +01:00
Giuseppe Scrivano
a513d3de66
main: block setting the user.containers. xattr
it is reserved for internal usage with containers/storage.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-11-07 12:08:18 +01:00
Giuseppe Scrivano
3dbb7d9bd5
main: move stat override mode to enum
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-11-06 13:17:14 +01:00
Daniel J Walsh
d450ee1560
Merge pull request #256 from giuseppe/open-rm-files
main: open hidden files
2020-11-03 17:08:45 -05:00
Giuseppe Scrivano
98c62ee1a0
main: open hidden files
if a file is delete and not accessible from the file system, but it is
still referenced, we must be able to open and use it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-11-02 13:20:31 +01:00
Giuseppe Scrivano
de2fc6b14c
main: always remap ids when specified
if a mapping is specified, make sure it is always honored, also when
using xattr permissions.

Closes: https://github.com/containers/fuse-overlayfs/issues/253

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-11-02 11:55:21 +01:00
Giuseppe Scrivano
589e363cc8
main: honor option volatile
upstream Linux added an option "volatile" for overlay mounts that has
the same meaning as fsync=0 already supported by fuse-overlayfs.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-21 18:03:17 +02:00
Shotaro Gotanda
e6012da12f main: fix typo
Signed-off-by: Shotaro Gotanda <g.sho1500@gmail.com>
2020-10-21 05:27:45 +09:00
Shotaro Gotanda
6043ce7ddb main: fix fuse_reply_error to use errno on malloc failure
fuse_reply_error should receive errno instead of ENOMEM just after
malloc returned NULL.

Signed-off-by: Shotaro Gotanda <g.sho1500@gmail.com>
2020-10-21 00:30:23 +09:00
Shotaro Gotanda
df46733cf8 main: fix fuse_reply_error to use ENOMEM on calloc failure
fuse_reply_error should receive ENOMEM instead of ENOENT.

Signed-off-by: Shotaro Gotanda <g.sho1500@gmail.com>
2020-10-21 00:25:57 +09:00
Shotaro Gotanda
65ea4595c4
fix typo 2020-10-20 06:41:44 +09:00
Daniel J Walsh
f009906072
Merge pull request #246 from giuseppe/create-inodes-0755
main: create inodes with 0755 with xattr_permissions
2020-10-10 07:16:29 -04:00
Giuseppe Scrivano
9eb724ca15
main: create inodes with 0755 with xattr_permissions
make sure the inodes are created with mode 0755 when using
xattr_permissions, otherwise the original permission could prevent
running on NFS.  Requires Linux 5.9 for NFS with xattr support.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-09 16:33:14 +02:00
Patrick J. LoPresti
032877c501 Add squash_to_root mount option
(https://github.com/containers/fuse-overlayfs/issues/241).
2020-10-08 12:49:40 -07:00
Daniel J Walsh
3c4eb36f7b
Merge pull request #239 from giuseppe/leak-fix
main: fix a potential leak and be more aggressive on releasing inodes
2020-10-07 11:01:54 -04:00
Giuseppe Scrivano
0e33eb5da8
main: drop the ino if the last node is removed
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-06 17:47:36 +02:00
Giuseppe Scrivano
228544e71d
main: remove unreferenced inodes on forget_multi
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-06 17:47:35 +02:00
Giuseppe Scrivano
6e2675593c
main: attempt an inode free on releasedir
if the reference held by the directory is the last one, it would miss
to clean up the inode.  Fix it by calling do_forget.

Closes: https://github.com/containers/fuse-overlayfs/issues/238

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-06 17:47:34 +02:00
Giuseppe Scrivano
e9cdbc444c
main: print usage statistics on USR1
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-06 11:10:33 +02:00
Giuseppe Scrivano
540f80dbe8
main: record how many objects are in memory
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-06 11:10:33 +02:00
Giuseppe Scrivano
573cfac0a6
main: prevent creating files longer than f_namemax
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-04 20:30:02 +02:00
Giuseppe Scrivano
4725e0ba66
main: reserve sfs.f_namemax for whiteout prefix
redure the reported sfs.f_namemax by the maximum length that can be
added for whiteout files.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-04 16:45:07 +02:00
Giuseppe Scrivano
d34833dfb3
main: skip ENAMETOOLONG for whiteouts lookup
adding the .wh. prefix could cause the lookup to cross the f_namemax
limit and fail the lookup with ENAMETOOLONG.  If the lookup fails with
ENAMETOOLONG then the whiteout file doesn't exist.

Closes: https://github.com/containers/fuse-overlayfs/issues/236

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-04 16:41:42 +02:00
Daniel J Walsh
cb6b7d55bc
Fix problems found by codespell
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-09-11 10:29:03 -04:00
Giuseppe Scrivano
b1cc0e2b98
main: honor chownat flags
honor the specified flags to fchownat.

commit 50787d38278fa41c1b3f8167ccfe13ec83d9a063 introduced the
regression.

Closes: https://github.com/containers/fuse-overlayfs/issues/233

Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2020-09-03 22:25:02 +02:00
Giuseppe Scrivano
b958a3062e
Merge pull request #230 from mgoltzsche/fix_alpine_file_exists_at
utils.c: fix file_exists_at on musl.
2020-08-27 09:43:56 +02:00
Max Goltzsche
d5b725b6f1
utils.c: fix file_exists_at musl compatibility.
utils.c: file_exists_at: fallback to `fstatat` when `faccessat` fails with `EINVAL` (on musl).
.travis.yml: alpine test added.
main.c: reallocate path before appending.

Closes #174.

Signed-off-by: Max Goltzsche <max.goltzsche@gmail.com>
2020-08-26 02:22:53 +02:00
Giuseppe Scrivano
b8086b58fa
main: support writing uid/gid/mode to xattr
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-08-21 19:52:28 +02:00
Giuseppe Scrivano
50787d3827
main: prepare wrappers for chown/chmod
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-08-21 16:43:59 +02:00
Giuseppe Scrivano
ab407f7c9e
direct: store if the layer must be remapped
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-08-21 16:02:59 +02:00
Giuseppe Scrivano
8f666d4820
main: fix segfault if no mountpoint specified
Closes: https://github.com/containers/fuse-overlayfs/issues/225

Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2020-07-17 23:39:03 +02:00
Giuseppe Scrivano
2b8dff330f
main: fix memory leak when creating a whiteout
Closes: https://github.com/containers/fuse-overlayfs/issues/222

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-06-29 13:54:22 +02:00
Giuseppe Scrivano
1d8f4b529d
main: fix lookup for overflow uid
we were mistakenly using the overflow GID also for UIDs lookups.  Not
a big issue as they usually have the same value.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-06-20 20:34:28 +02:00
Giuseppe Scrivano
0d985794d9
main: add error checks for workdir initialization
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-06-20 20:33:52 +02:00