From: Sargun Dhillon Date: Sun, 27 Dec 2020 11:17:46 +0000 (-0800) Subject: util/fusermount.c: Assume the kernel supports UMOUNT_NOFOLLOW (#574) X-Git-Tag: fuse-3.10.2~8 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=b96e4758041ffac1b8d8c39f4897edd6182a46e9;p=qemu-gpiodev%2Flibfuse.git util/fusermount.c: Assume the kernel supports UMOUNT_NOFOLLOW (#574) 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 --- diff --git a/util/fusermount.c b/util/fusermount.c index 953d4ca..45e96bc 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -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); @@ -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",