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

Permission denied for bind mounts inside XFS filesystems #519

Closed
sbraz opened this issue Sep 6, 2021 · 1 comment
Closed

Permission denied for bind mounts inside XFS filesystems #519

sbraz opened this issue Sep 6, 2021 · 1 comment
Labels

Comments

@sbraz
Copy link
Contributor

sbraz commented Sep 6, 2021

Hi,
I recently noticed that there are permission errors for mount points outside of the folders on which I run rmlint. It only seems to happen inside XFS filesystems.

I believe the problem happens somewhere around here:

while((wrap_entry = rm_mount_list_next(self))) {

To reproduce:

# Inside an XFS filesystem
cd /mnt/xfs
mkdir source target
chmod 700 source
mount --bind source target

# In a different folder
cd /tmp/empty
rmlint

This will output: /mnt/xfs/target: Permission denied. Strace shows openat(AT_FDCWD, "/mnt/xfs/target", O_RDONLY) = -1 EACCES (Permission denied).

Does rmlint really need to enumerate each mount point? The error is also present when -x is used.

sbraz added a commit to sbraz/rmlint that referenced this issue Sep 7, 2021
…#519

This would make test_stdin.test_path_starting_with_dash fail in certain
situations.
@cebtenzzre cebtenzzre added the bug label Aug 12, 2022
@cebtenzzre
Copy link
Collaborator

This ugly line is to blame for that error message:

char *cmd = g_strdup_printf("xfs_info '%s' | grep -q 'reflink=1'", mountpoint);

Redirecting stderr to null would be the quick fix. rm_mounts_can_reflink is useful to avoid attempting reflinks on filesystems that obviously can't make them, especially when an rmlint run includes more than one fs type. Enumerating them eagerly is the easiest way to do that, but the way it works now isn't perfect. For instance, since Linux 5.5 you can do server-side copy on NFS filesystems, which means cp --reflink will create a reflink if the backing filesystem supports it. The only reason rmlint --dedupe does not work on NFS yet is that it expects FS_IOC_FIEMAP to be available.

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

No branches or pull requests

2 participants