Skip to content

Commit

Permalink
util/fusermount.c: Assume the kernel supports UMOUNT_NOFOLLOW (#574)
Browse files Browse the repository at this point in the history
UMOUNT_NOFOLLOW was added in Kernel 2.6.34. It's been 10 years since it's been added
Kernel 5.9, and 5.10 break this check mechanism[1]. Let's deprecate it.

[1]: https://lore.kernel.org/linux-fsdevel/20201223102604.2078-1-sargun@sargun.me/

Signed-off-by: Sargun Dhillon <sargun@sargun.me>
  • Loading branch information
sargun committed Dec 27, 2020
1 parent 9bfbeb5 commit b96e475
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions util/fusermount.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,26 +397,12 @@ static int chdir_to_parent(char *copy, const char **lastp)
}

#ifndef IGNORE_MTAB
/* Check whether the kernel supports UMOUNT_NOFOLLOW flag */
static int umount_nofollow_support(void)
{
int res = umount2("", UMOUNT_UNUSED);
if (res != -1 || errno != EINVAL)
return 0;

res = umount2("", UMOUNT_NOFOLLOW);
if (res != -1 || errno != ENOENT)
return 0;

return 1;
}

static int unmount_fuse_locked(const char *mnt, int quiet, int lazy)
{
int res;
char *copy;
const char *last;
int umount_flags = lazy ? UMOUNT_DETACH : 0;
int umount_flags = (lazy ? UMOUNT_DETACH : 0) | UMOUNT_NOFOLLOW;

if (getuid() != 0) {
res = may_unmount(mnt, quiet);
Expand All @@ -436,14 +422,6 @@ static int unmount_fuse_locked(const char *mnt, int quiet, int lazy)
if (res == -1)
goto out;

if (umount_nofollow_support()) {
umount_flags |= UMOUNT_NOFOLLOW;
} else {
res = check_is_mount(last, mnt, NULL);
if (res == -1)
goto out;
}

res = umount2(last, umount_flags);
if (res == -1 && !quiet) {
fprintf(stderr, "%s: failed to unmount %s: %s\n",
Expand Down

0 comments on commit b96e475

Please sign in to comment.