Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for file filtering (hiding) #108

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

bin_PROGRAMS = bindfs

noinst_HEADERS = debug.h permchain.h userinfo.h arena.h misc.h usermap.h rate_limiter.h
bindfs_SOURCES = bindfs.c debug.c permchain.c userinfo.c arena.c misc.c usermap.c rate_limiter.c
noinst_HEADERS = debug.h permchain.h userinfo.h arena.h misc.h usermap.h rate_limiter.h filter.h
bindfs_SOURCES = bindfs.c debug.c permchain.c userinfo.c arena.c misc.c usermap.c rate_limiter.c filter.c

AM_CPPFLAGS = ${my_CPPFLAGS} ${fuse_CFLAGS} ${fuse3_CFLAGS}
AM_CFLAGS = ${my_CFLAGS}
Expand Down
41 changes: 41 additions & 0 deletions src/bindfs.1
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,47 @@ them completely.
See \fB\%PERMISSION \%SPECIFICATION\fP below for details.


.SH FILE FILTERING POLICY

.TP
.B \-\-file-filter=\fIr:*.png/hiddenfile/d:dir2/...\fP, -o file-filter=...
Takes a slash-separated list of file names which will be hidden
in target filesystem. Files will not appear in directories, any
access operation will fail with \fBENOENT\fP, any write operation
(create, link, rename, ...) will fail with \fBEPERM\fP, even if
specified file not exist. If \fB\-\-resolve\-symlinks\fP specified,
symlinks referenced to a hidden files will also be hidden.

Files can be specified as a POSIX wildcards (see \fBglob\fP(7) for
details). Optionally, only certain file types might be matched, as
specified with the following tokens which preceded filename and
terminated with a colon:

\fBa\fP any file (this is a default)
\fBs\fP socket
\fBl\fP symbolic link
\fBr\fP regular file
\fBb\fP block device
\fBc\fP character device
\fBd\fP directory
\fBp\fP named pipe (FIFO)
e.g. \fIr:file/d:dir/slrbcp:notdir/...\fP

If a type tokens not specified, any file types will be matched.
If a filename contains a colon, type token part must be specified
to distinguish specifier parts, e.g. \fIa:pci:0000:00:00/...\fP,
where \fIa\fP is an "any type" specifier and \fIpci:0000:00:00\fP is
a file name.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we reserve / as the separator, we can't support filtering by paths later (without changing the flag name).
Does FUSE's option parser support reading multiple instances of the same flag? Then we wouldn't need a separator.
I'd also suggest a more verbose but more extensible and arguably clearer syntax like

--file-filter=type=socket,name-glob=*.sock --file-filter=type=symlink,name=something

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing options syntax, such as --map and permission stuff tends to be concise (and I'd like it), I'll try to follow this style. Maybe better just escape forward slashes?


.TP
.B \-\-delete\-filtered
When removing a directory, also transparently remove hidden with
\fB\-\-file\-filter\fP files in it. If this option not active,
such directories won't remove with \fBENOTEMPTY\fP error. If a directory
contains hidden directories, they will be deleted recursively, as with
\fBrm -rf\fP command. If \fB\-\-resolve\-symlinks\fP is active, hidden
files in resolved directories will not be removed.

.SH CHOWN/CHGRP POLICY
The behaviour on chown/chgrp calls can be changed. By default they are passed
through to the source directory even if bindfs is set to show
Expand Down
Loading