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

Conversation

Nekun
Copy link

@Nekun Nekun commented Feb 22, 2022

This new feature allows to hide files specified by a slash-separated list, --file-filter=r:*.png/d:dir1/junkfile/..., optionally POSIX globs and matching file modes can be specified. Files not appears in all directories, any access-by-path ops fails with ENOENT, any "write" ops, such as rename and link, fails with EPERM, even if specified files not exists.

Developed this feature for QEMU shared filesystems: bindfs is very useful for mapping owners and permissions when QEMU runs unprivileged and can't chown, but with "mapped-file" option (https://wiki.qemu.org/Documentation/9psetup#Starting_the_Guest_directly) which is only option for tmpfs since it can't store xattrs metadata is stored in target path in ".virtfs_metadata" dir created in each directory, makes it very inconvenient to delete them while copying files from guest to host. With filtering feature, we can just filter metadata dirs in resulting share.

Copy link
Owner

@mpartel mpartel left a comment

Choose a reason for hiding this comment

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

This looks useful and well thought out, thanks! I'll try to find time to review the code in detail later this week.

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?

src/bindfs.1 Outdated
Comment on lines 178 to 184
.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 \fBENOEMPTY\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.
Copy link
Author

@Nekun Nekun Feb 24, 2022

Choose a reason for hiding this comment

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

This option is intended to, returning to my QEMU use case, delete directories which contains hidden metadata dirs from resulting share, otherwise rmdir() fails with ENOTEMPTY

@mpartel
Copy link
Owner

mpartel commented Mar 14, 2022

I'm sorry I've still not found the time for this. It's still on my list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants