From: Karel Zak Date: Wed, 3 Jan 2024 11:38:21 +0000 (+0100) Subject: libmount: add mnt_context_within_helper() wrapper X-Git-Tag: v2.40-rc1~50^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0f9b2438c927d2787bf43b693809af3719e15646;p=thirdparty%2Futil-linux.git libmount: add mnt_context_within_helper() wrapper Signed-off-by: Karel Zak --- diff --git a/libmount/src/context.c b/libmount/src/context.c index 6db71f4e47..93fc3dbdcb 100644 --- a/libmount/src/context.c +++ b/libmount/src/context.c @@ -2737,7 +2737,6 @@ int mnt_context_get_excode( return rc; } - /** * mnt_context_init_helper * @cxt: mount context @@ -2773,6 +2772,14 @@ int mnt_context_init_helper(struct libmnt_context *cxt, int action, return rc; } +/* + * libmount used in /sbin/[u]mount. helper + */ +int mnt_context_within_helper(struct libmnt_context *cxt) +{ + return cxt && (cxt->flags & MNT_FL_HELPER); +} + /** * mnt_context_helper_setopt: * @cxt: context diff --git a/libmount/src/context_umount.c b/libmount/src/context_umount.c index 26394d51ef..79b62378d8 100644 --- a/libmount/src/context_umount.c +++ b/libmount/src/context_umount.c @@ -270,7 +270,7 @@ static int lookup_umount_fs_by_statfs(struct libmnt_context *cxt, const char *tg */ if (mnt_context_is_restricted(cxt) || *tgt != '/' - || (cxt->flags & MNT_FL_HELPER) + || mnt_context_within_helper(cxt) || mnt_context_is_force(cxt) || mnt_context_is_lazy(cxt) || mnt_context_is_nocanonicalize(cxt) diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h index 59921cf740..2385e191db 100644 --- a/libmount/src/mountP.h +++ b/libmount/src/mountP.h @@ -620,6 +620,8 @@ extern struct libmnt_context *mnt_copy_context(struct libmnt_context *o); extern int mnt_context_utab_writable(struct libmnt_context *cxt); extern const char *mnt_context_get_writable_tabpath(struct libmnt_context *cxt); +extern int mnt_context_within_helper(struct libmnt_context *cxt); + extern int mnt_context_get_mountinfo(struct libmnt_context *cxt, struct libmnt_table **tb); extern int mnt_context_get_mountinfo_for_target(struct libmnt_context *cxt, struct libmnt_table **mountinfo, const char *tgt);