aboutsummaryrefslogtreecommitdiffstats
path: root/example/passthrough_ll.c
AgeCommit message (Collapse)AuthorLines
2020-09-09Updated example code to work with new API (#547)AKowshik-3/+7
2020-05-14passthrough_ll: remove symlink fallbacks (#514)Miklos Szeredi-70/+8
* passthrough_ll/hp: remove symlink fallbacks Path lookup in the kernel has special rules for looking up magic symlinks under /proc. If a filesystem operation is instructed to follow symlinks (e.g. via AT_SYMLINK_FOLLOW or lack of AT_SYMLINK_NOFOLLOW), and the final component is such a proc symlink, then the target of the magic symlink is used for the operation, even if the target itself is a symlink. I.e. path lookup is always terminated after following a final magic symlink. I was erronously assuming that in the above case the target symlink would also be followed, and so workarounds were added for a couple of operations to handle the symlink case. Since the symlink can be handled simply by following the proc symlink, these workardouds are not needed. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Co-authored-by: Miklos Szeredi <mszeredi@redhat.com>
2020-03-13State GPL version in comment (#485)Dr. David Alan Gilbert-1/+1
IN a bunch of comments we say 'under the terms of the GNU GPL', make it clear this is GPLv2 (as LICENSE says). Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2020-02-24passthrough_ll: Remove unneeded variable assignment (#501)philmd-2/+0
Fix warning reported by Clang static code analyzer: example/passthrough_ll.c:390:5: warning: Value stored to 'saverr' is never read saverr = ENOMEM; ^ ~~~~~~ Fixes: 4a92a82f2e2 Reported-by: Clang Static Analyzer Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2020-01-30examples: mark ops variables constant (#496)zsugabubus-1/+1
2020-01-24passthrough_ll: Use cache_readdir for directory open (#492)Misono Tomohiro-1/+1
Upstreamed from: https://www.redhat.com/archives/virtio-fs/2020-January/msg00106.html Since keep_cache(FOPEN_KEEP_CACHE) has no effect for directory as described in fuse_common.h, use cache_readdir(FOPEN_CACHE_DIR) for diretory open when cache=always mode. Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
2020-01-06passthrough_ll: pass correct errno to fuse_reply_err()Dr. David Alan Gilbert-1/+1
fuse_reply_err() expects the error code, not its negative. Upstreamed from https://www.redhat.com/archives/virtio-fs/2020-January/msg00000.html. Original commit message: lo_copy_file_range() passes -errno to fuse_reply_err() and then fuse_reply_err() changes it to errno again, so that subsequent fuse_send_reply_iov_nofree() catches the wrong errno.(i.e. reports "fuse: bad error value: ..."). Make fuse_send_reply_iov_nofree() accept the correct -errno by passing errno directly in lo_copy_file_range(). Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com> Reviewed-by: Eryu Guan <eguan@linux.alibaba.com> Co-authored-by: Xiao Yang <ice_yangxiao@163.com>
2019-11-03Implement lseek operation (#457)Yuri Per-0/+14
2019-11-03passthrough_ll: drop lo_dirp->fd field (#464)Stefan Hajnoczi-7/+9
fdopendir(3) takes ownership of the file descriptor. The presence of the lo_dirp->fd field could lead to someone incorrectly adding a close(d->fd) cleanup call in the future. Do not store the file descriptor in struct lo_dirp since it is unused. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2019-09-10passthrough_ll: use fuse_log() instead of err()/errx()Stefan Hajnoczi-8/+17
Send everything through fuse_log() instead of writing directly to stderr. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2019-09-10passthrough_ll: use fuse_log()Stefan Hajnoczi-16/+16
Make use of fuse_log() instead of printing directly to stderr. This demonstrates unified logging and also caught the fact that I forgot to add fuse_log APIs to lib/fuse_versionscript. So it's basically a test case :). Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2019-09-09passthrough_ll: fix fallocate variant ifdefs (#449)Dr. David Alan Gilbert-2/+2
If fallocate isn't available we incorrectly check for the value of HAVE_POSIX_FALLOCATE rather than it being defined. We also fail to initialise 'err' in the case where neither are defined. Fixes: 5fc562c90d7925963467 ("Add fallocate and use it instead of ...") Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2019-05-15passthrough: fix unix-domain sockets on FreeBSD (#413)Alan Somers-9/+4
FreeBSD doesn't allow creating sockets using mknod(2). Instead, one has to use socket(2) and bind(2). Add appropriate logic to the examples and add a test case.
2019-04-18Add fallocate and use it instead of posix_fallocate if possible (#398)Liu Bo-0/+7
fuse.ko has supported FALLOC_FL_KEEP_SIZE and FALLOC_FL_PUNCH_HOLE at this moment and more modes may be supported in the future. fallocate(2) supports modes while posix_fallocate(2) does not, so this makes lo_fallocate use fallocate(2) instead. Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
2019-01-22passthrough_ll: lo_create() should honor CACHE_NEVER (#345)Miklos Szeredi-0/+5
lo_create() did not honour CACHE_NEVER in lo_create(), which has an effect on how I/O is performed after the open. The value of CACHE_ALWAYS, which results in setting fi->keep_cache, only has an effect for the state of the cache at open, and since the file was just created the cache is always empty. Hence setting this doesn't have an effect on lo_create(), but keep it for symmetry with lo_open().
2018-12-29Fixed memory leak.Nikolaus Rath-5/+0
Fixes: #338.
2018-11-27Fix fd/inode leakNikolaus Rath-13/+19
If do_readdir() calls do_lookup(), but the latter fails, we still have to return any entries that we already stored in the readdir buffer to avoid leaking inodes. do_lookup() may fail if e.g. we reach the file descriptor limit.
2018-11-24Avoid needless telldir() call.Nikolaus Rath-1/+1
2018-11-24Fixed lookup-count leak in do_readdir().Nikolaus Rath-3/+7
2018-11-19examples: add copy_file_range() support to passthrough(_fh)Niels de Vos-0/+30
The passthrough example filesystem can be used for validating the API and the implementation in the FUSE kernel module.
2018-11-09Don't crash if mountpoint is not specified.Nikolaus Rath-0/+7
Fixes: #319.
2018-10-10passthrough_ll: initialize unused memoryMiklos Szeredi-3/+4
For '.' and '..' entries only the file type in e.attr.st_mode and the inode number in e.attr.st_ino are used. But it's prudent to at least initialize the other fields of struct fuse_entry_param as well, instead of using random values from the stack.
2018-10-10passthrough_ll: allow configuring cachingMiklos Szeredi-8/+55
Caching can be controlled with the following options: "cache=never": disable caching "cache=normal": enable caching but also refresh after the timeout "cache=always": never refresh cache The timeout can be controlled with the "timeout=SEC" option, where SEC is the number of seconds and can be an arbitrary non-negative floating point number. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: add *xattr() operationsMiklos Szeredi-0/+186
The extended attribute functionality is enabled with the "xattr" option (default) and disabled with the "no_xatt" option. New operations added: - getxattr - listxattr - setxattr - removexattr Caveat: none of these operations will work on a symbolic link, because it's difficult to implement that without races that can result in incorrect operation. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: add flock()Miklos Szeredi-0/+23
Conditionally enable flock() locking on underlying filesystem, based on the flock/no_flock options. Default is "no_flock", meaning locking will be local to the fuse filesystem and won't be propagated to the filesystem passed through. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: whitespace cleanupMiklos Szeredi-6/+5
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: add forget_multi()Vivek Goyal-1/+16
Add method forget_multi() to forget multiple inodes in a single message. Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: add source optionVivek Goyal-2/+19
Right now, passthrough_ll will use "/" as source directory for passthrough. We need more flexibility where user can specify path of directory to be passed through. Hence add an option "source=<source-dir>". Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: add some of the missing operationsMiklos Szeredi-1/+324
New operations added: - mkdir - mknod - symlink - link - unlink - rmdir - rename - setattr - fsyncdir - flush - fsync - statfs - fallocate Caveats: - The utimes(2) family of syscalls will fail on symlinks on 4.18 and earlier kernels. Hoping to add support to later kernels. - The link(2) and linkat(2) system calls will fail on symlinks unless running with privileges (CAP_DAC_READ_SEARCH). Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: add is_symlink to lo_inodeMiklos Szeredi-0/+3
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: set umask at startupMiklos Szeredi-0/+3
Like all the other passthrough examples. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: fix refcount for "." and ".." entriesMiklos Szeredi-7/+19
Kernel is not expecting an elevated lookup count for the "." and ".." entries when doing READDIRPLUS. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: add locking to inode cacheMiklos Szeredi-26/+51
Otherwise it may crash when running multithreaded. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-04-13Invert calloc(3) argument order (`nmemb` comes first)Tomohiro Kusumi-1/+1
No functional difference expected, but should still follow the standard. http://pubs.opengroup.org/onlinepubs/009695399/functions/calloc.html
2018-01-15Fix typo in "passthrough" docstring (#229)Mateusz Urbańczyk-1/+1
2017-09-25Removed unneccessary #include <config.h> from examplesNikolaus Rath-4/+0
Fixes: #208.
2017-08-24passthrough_ll: only active EXPORT_SUPPORT of supported by kernel.Nikolaus Rath-1/+3
2017-08-06Added writeback cache to passthrough_llNikolaus Rath-2/+46
This fixes issue #191 (where the test was done by simply adding FUSE_CAP_WRITEBACK_CACHE without adjusting the flags in the open() call). Fixes: #191.
2017-08-06Removed compat stuff in passthrough_llNikolaus Rath-42/+0
As the comment says, this made it compile but not work. If there is a need, we can add these checks to meson.build to only build this file if the prerequisites are satisfied.
2017-08-04passthrough_ll: added more debugging outputNikolaus Rath-1/+20
2017-08-03Fix compilation on 32bit systemsNikolaus Rath-6/+6
Fixes: #185.
2017-07-08Added public fuse_lib_help(), bumped minor versionNikolaus Rath-1/+1
2017-06-05examples/passthrough_ll: added support for create()Nikolaus Rath-1/+23
2017-06-05example/passthrough_ll: added write supportNikolaus Rath-1/+21
2017-05-25passthrough_ll: document that fuse_ino_t and uintptr_t sizes must matchNikolaus Rath-0/+13
We can consider changing the code to drop the requirement if it turns out that there's a system where this isn't given. Fixes issue #167.
2017-04-07passthrough_ll: document that functionality is restrictedNikolaus Rath-1/+5
2017-03-15passthrough_fh: declare support for . and .. lookups.Nikolaus Rath-0/+8
2016-11-28examples/passthrough_ll.c: Include <limits.h> (for PATH_MAX macro).Przemyslaw Pawelczyk-0/+1
Otherwise building w/o optimization (-O0) fails. passthrough_ll.c: In function 'lo_readlink': passthrough_ll.c:251:11: error: 'PATH_MAX' undeclared (first use in this function) char buf[PATH_MAX + 1]; (gcc v5.3.0 in Alpine Linux v3.4.6 x86_64 w/ musl-libc v1.1.14.)
2016-11-28examples/passthrough_ll.c: Close root fd before application ends.Przemyslaw Pawelczyk-0/+3
If we want to do, what system would do anyway upon program termination, then let's try to be a bit more scrupulous.
2016-11-28examples/passthrough_ll.c: Fix segfault when showing help or version.Przemyslaw Pawelczyk-1/+2
root lo_inode's next and prev were not set early enough, which led to accessing addr 0x8 (or 0x4, depending on ptr size) when setting prev variable in lo_free(lo.root.next), because lo.root.next was NULL.