350 Commits

Author SHA1 Message Date
Giuseppe Scrivano
9b687001bb
main: fix signature for ovl_ioctl
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-30 15:13:31 +02:00
Giuseppe Scrivano
cb934ef871
main: delete dead code
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-30 15:13:30 +02:00
Giuseppe Scrivano
b947555f87
main: remove superflous check
pnode cannot be NULL.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-30 15:13:30 +02:00
Giuseppe Scrivano
33a3a7970e
main: avoid double free on cleanup
the cleanup_node_init label already takes care of it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-30 15:13:29 +02:00
Giuseppe Scrivano
5b271aa796
main: add check for malloc
Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2020-04-25 13:43:00 +02:00
Giuseppe Scrivano
26e4226a41
main: fix set mtime for a symlink
Closes: https://github.com/containers/fuse-overlayfs/issues/204

Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2020-04-25 13:28:33 +02:00
Giuseppe Scrivano
fb8eb3300e
main: use openat2 where available
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-21 18:33:33 +02:00
Giuseppe Scrivano
dd985bccba
main.c: accept "ro" as a mount option
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-20 12:28:53 +02:00
Daniel J Walsh
6cb22ea674
Merge pull request #194 from giuseppe/correct-nlink-dirs
main: drop nlink optimization
2020-03-16 10:23:52 -04:00
Giuseppe Scrivano
f703870668
main: drop nlink optimization
calculate the nlink for the directory on each stat.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-03-16 11:54:39 +01:00
Giuseppe Scrivano
e63c9b133d
main: stop ino lookup without an open fd
stop the lookup for the dev/ino if there is not an ino open as it also
prevents reading the origin xattr.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-03-16 11:36:55 +01:00
Giuseppe Scrivano
9660aaed2f
main: preserve errno for create_directory
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-03-03 16:50:16 +01:00
Giuseppe Scrivano
47218d09ab
main, rename: make sure destination is deleted
before doing a rename(2) make sure the destination is cleaned up,
otherwise a left-over directory can cause the rename to fail with
EEXIST.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-03-03 16:50:15 +01:00
Daniel J Walsh
14b1e91521
Add support for debug to match help
The help message that is printed does not match reality for the command line.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-18 11:09:12 -05:00
Giuseppe Scrivano
f8b554aa9a
main: lookup skip ino if there is no origin
if there is no origin xattr specified, do not overwrite the ino
number.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-01-31 15:39:41 +01:00
Giuseppe Scrivano
d4a957dea9
main: use the rename version when setting opaque
so that it can be correctly set on the directory before renaming it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-01-17 22:01:17 +01:00
Giuseppe Scrivano
632c56f4b9
listxattr/getxattr: do not access private xattrs
Closes: https://github.com/containers/fuse-overlayfs/issues/173

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-01-17 18:48:27 +01:00
Giuseppe Scrivano
ce93abae5f
main: do not copyup opaque xattr
when performing the copyup, do not copy the private xattrs.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-01-15 17:52:16 +01:00
Giuseppe Scrivano
214d606084
main: check if file is whiteout
when doing a lookup, make sure the returned file is not a whiteout for
functions that expect the file to exist.

Close: https://github.com/containers/fuse-overlayfs/issues/169

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-01-15 00:09:31 +01:00
Giuseppe Scrivano
724ab6d2b3
main: reset O_DIRECT on open
having the fd open with O_DIRECT causes pwrite64 to fail with EINVAL
if the write buffer is not aligned.  Since we have no control on the
buffer provided by libfuse, just drop O_DIRECT.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-01-14 12:28:54 +01:00
Giuseppe Scrivano
ffc83a4ed6
main: specify FUSE_BUF_FD_RETRY to libfuse
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-01-14 12:27:17 +01:00
Giuseppe Scrivano
dfea3f9b63
main: fix fallocate for deleted files
allow to use fallocate on an unlinked path if there is still a
reference to it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-01-13 22:24:34 +01:00
Daniel J Walsh
a0ba68151a
Merge pull request #164 from giuseppe/fix-160
main: force a dir reload after a move
2020-01-08 12:20:29 -05:00
Giuseppe Scrivano
9f27377e13
Merge pull request #163 from saschagrunert/segfault
Fix possible segmentation fault in direct_fsync()
2020-01-08 13:25:41 +01:00
Giuseppe Scrivano
a9c49ec18d
main: create_missing_whiteouts uses datastore
refactor create_missing_whiteouts to use the datastore API so it works
correctly with plugins.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-01-08 13:24:00 +01:00
Giuseppe Scrivano
efcfb045b4
main: skip whiteouts file when creating missing ones
do not attempt to create a whiteout if the file itself is already a
whiteout.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-01-08 13:23:16 +01:00
Giuseppe Scrivano
b29a8f1587
main: force a dir reload after a move
if the directory was moved, invalidate its cache and force a reload.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-01-08 13:22:20 +01:00
Sascha Grunert
0aa0537459
Fix possible segmentation fault in direct_fsync()
If the call to `get_upper_layer(lo)` returns `NULL` then the
`node->layer` will be `NULL`, too. If this is the case we pass `NULL` to
`direct_fsync()` which will cause a segmentation fault in:

```c
cfd = openat(l->fd, path, O_NOFOLLOW|O_DIRECTORY);
```

To fix this we now apply an additional check and error in the case of
`get_upper_layer(lo) == NULL`.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-01-08 09:33:48 +01:00
Sascha Grunert
07627d4ddb
Fix dead assignment in main.c
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-01-08 09:23:42 +01:00
Sascha Grunert
8f3a1dde24
Fix dead increment in main.c
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-01-08 09:22:22 +01:00
Giuseppe Scrivano
884052db48
build: fix compiler warnings found by gcc
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-12-09 14:49:34 +01:00
Giuseppe Scrivano
1d7b99d95a
fuse-overlayfs: fix some warnings reported by clang
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-12-09 11:05:47 +01:00
Giuseppe Scrivano
5d053201d1
main: drop special handling for security.capability
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-11-29 11:53:49 +01:00
Giuseppe Scrivano
dfd9f18773
main: prevent parent whiteout to hide file
use the full relative path when looking up the whiteout file,
otherwise a whiteout in the upper layer will hide files in
subdirectories.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-11-27 21:03:21 +01:00
Daniel J Walsh
b57e5c8d00
Merge pull request #147 from giuseppe/fix-build-musl
build: fix build on musl
2019-11-26 05:46:12 -05:00
Giuseppe Scrivano
d1f318ef73
build: fix build on musl
Closes: https://github.com/containers/fuse-overlayfs/issues/145

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-11-18 13:47:37 +01:00
Giuseppe Scrivano
d077ea28e3
configure: check for FUSE copy_file_range
check if the version of FUSE supports copy_file_range.

It fixes the build on RHEL 8.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-11-18 13:41:51 +01:00
Giuseppe Scrivano
2403cd9537
main: honor opaque whiteout
Closes: https://github.com/containers/fuse-overlayfs/issues/138

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-11-04 08:36:37 +01:00
Giuseppe Scrivano
35ef75d9b0
main, mkdir: set directory opaque
when creating a directory, set it opaque.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-11-02 19:46:51 +01:00
Giuseppe Scrivano
042846de50
main: correctly mark the last_layer with a deleted directory
Closes: https://github.com/containers/fuse-overlayfs/issues/136

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-31 14:26:15 +01:00
Giuseppe Scrivano
715a95c39d
plugins: load from default location
if no -o plugins is specified, load them from $PKGLIBEXECDIR (usually
has the value /usr/libexec/fuse-overlayfs).

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-25 11:02:17 +02:00
Giuseppe Scrivano
3fa10346c3
main: drop magic numbers
use EXIT_FAILURE and EXIT_SUCCESS instead.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-24 13:52:35 +02:00
Giuseppe Scrivano
1c490d91d8
plugins: allow to manage multiple layers with a ds
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-24 13:52:34 +02:00
Giuseppe Scrivano
7095cc29ef
main: fix fast_ino
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-21 18:41:53 +02:00
Giuseppe Scrivano
62abdcf00f
readdir: use mode from uppermost layer
differently than dev/ino number, use the uppermost mode found.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-20 22:06:41 +02:00
Giuseppe Scrivano
9f6f90a6da
direct: use statx when available
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-20 22:06:40 +02:00
Giuseppe Scrivano
b28a23a39d
fuse-overlayfs: add plugin system
Add a simple plugin mechanism that will help to expand fuse-overlayfs
functionalities, in particular it allows to load data from a layer on
demand.

A plugin is loaded into fuse-overlayfs using the option:

-o plugins=path/to/plugin.so:path/to/another/plugin.so

A layer can use a plugin with the syntax:

-o lowerdir=//plugin-name/DATA-FOR-THE-PLUGIN/path

Each time a file/directory is looked up, if a plugin is registered for
a layer, the plugin is first notified about the request.

After the callback is invoked, fuse-overlayfs still expects the data
to be accessible at the specified directory.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-20 22:06:39 +02:00
Giuseppe Scrivano
c2c2ac5b82
main: split the code in multiple files
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-20 19:44:20 +02:00
Giuseppe Scrivano
53c165e6bd
main: refactor to use a data store
this is the first step towards supporting data from lower layers
coming from other sources.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-20 19:44:20 +02:00
Giuseppe Scrivano
e72f92bcf6
main: fix debug format string
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-20 19:43:23 +02:00