From: Bernd Schubert Magic numbers in the code are not good - we better use a define. Signed-off-by: Bernd Schubert --- lib/fuse_i.h | 3 +++ lib/mount.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/fuse_i.h b/lib/fuse_i.h index 9e3c5dc5021e210a2778e975a37ab609af324010..a2438a15afdd3b5f62dd35bc3514f9f6853f00c3 100644 --- a/lib/fuse_i.h +++ b/lib/fuse_i.h @@ -217,6 +217,9 @@ struct fuse_chan *fuse_chan_get(struct fuse_chan *ch); */ void fuse_chan_put(struct fuse_chan *ch); +/* Special return value for mount functions to indicate fallback to fusermount3 is needed */ +#define FUSE_MOUNT_FALLBACK_NEEDED (-2) + struct mount_opts *parse_mount_opts(struct fuse_args *args); void destroy_mount_opts(struct mount_opts *mo); void fuse_mount_version(void); diff --git a/lib/mount.c b/lib/mount.c index 6e404451cc9edc8e35434cc31f25612cfc4edca1..dec9d52274c13536648cacef959789f472c5682c 100644 --- a/lib/mount.c +++ b/lib/mount.c @@ -563,7 +563,7 @@ out_close: * @mo: mount options * @mnt_opts: mount options to pass to the kernel * - * Returns: 0 on success, -1 on failure, -2 if fusermount should be used + * Returns: 0 on success, -1 on failure, FUSE_MOUNT_FALLBACK_NEEDED if fusermount should be used */ static int fuse_kern_do_mount(const char *mnt, struct mount_opts *mo, const char *mnt_opts) @@ -611,7 +611,7 @@ static int fuse_kern_do_mount(const char *mnt, struct mount_opts *mo, * case try falling back to fusermount3 */ if (errno == EPERM) { - res = -2; + res = FUSE_MOUNT_FALLBACK_NEEDED; } else { int errno_save = errno; if (mo->blkdev && errno == ENODEV && @@ -749,7 +749,7 @@ int fuse_kern_mount(const char *mountpoint, struct mount_opts *mo) umount2(mountpoint, MNT_DETACH); /* lazy umount */ res = -1; } - } else if (res == -2) { + } else if (res == FUSE_MOUNT_FALLBACK_NEEDED) { if (mo->fusermount_opts && fuse_opt_add_opt(&mnt_opts, mo->fusermount_opts) == -1) goto out; -- 2.43.0