From 03b2e73ae649a957a4f695df4f44c2cbce8d5f92 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 29 Oct 2024 08:58:14 +0100 Subject: [PATCH] libmount: improving readability The function name mnt_optlist_is_recursive() is not accurate. It is only used for propagation operations based on the MS_REC flag and should not be confused with any other recursive stuff, such as ro=recursive. A more appropriate name for this function would be mnt_optlist_is_rpropagation(). Signed-off-by: Karel Zak --- libmount/src/context.c | 3 +++ libmount/src/hook_idmap.c | 2 +- libmount/src/mountP.h | 2 +- libmount/src/optlist.c | 10 +++++----- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libmount/src/context.c b/libmount/src/context.c index 96eb32d029..565825ca5d 100644 --- a/libmount/src/context.c +++ b/libmount/src/context.c @@ -1847,6 +1847,9 @@ int mnt_context_open_tree(struct libmnt_context *cxt, const char *path, unsigned if ((mflg & MS_BIND) && !(mflg & MS_REMOUNT)) { oflg |= OPEN_TREE_CLONE; + /* AT_RECURSIVE is only permitted for OPEN_TREE_CLONE (rbind). + * The other recursive operations are handled by + * mount_setattr() and are independent of open_tree() */ if (mnt_optlist_is_rbind(cxt->optlist)) oflg |= AT_RECURSIVE; } diff --git a/libmount/src/hook_idmap.c b/libmount/src/hook_idmap.c index 9b2425a77d..0fa9335597 100644 --- a/libmount/src/hook_idmap.c +++ b/libmount/src/hook_idmap.c @@ -303,7 +303,7 @@ static int hook_mount_post( .attr_set = MOUNT_ATTR_IDMAP, .userns_fd = hd->userns_fd }; - const int recursive = mnt_optlist_is_recursive(cxt->optlist); + const int recursive = mnt_optlist_is_rpropagation(cxt->optlist); const char *target = mnt_fs_get_target(cxt->fs); int fd_tree = -1; int rc, is_private = 1; diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h index 2c1f62a8ff..b54f672592 100644 --- a/libmount/src/mountP.h +++ b/libmount/src/mountP.h @@ -568,7 +568,7 @@ extern int mnt_optlist_strdup_optstr(struct libmnt_optlist *ls, char **optstr, extern int mnt_optlist_get_propagation(struct libmnt_optlist *ls); extern int mnt_optlist_is_propagation_only(struct libmnt_optlist *ls); extern int mnt_optlist_is_remount(struct libmnt_optlist *ls); -extern int mnt_optlist_is_recursive(struct libmnt_optlist *ls); +extern int mnt_optlist_is_rpropagation(struct libmnt_optlist *ls); extern int mnt_optlist_is_bind(struct libmnt_optlist *ls); extern int mnt_optlist_is_rbind(struct libmnt_optlist *ls); extern int mnt_optlist_is_move(struct libmnt_optlist *ls); diff --git a/libmount/src/optlist.c b/libmount/src/optlist.c index 11a7eed047..2ba294929a 100644 --- a/libmount/src/optlist.c +++ b/libmount/src/optlist.c @@ -72,7 +72,7 @@ struct libmnt_optlist { is_rdonly : 1, is_move : 1, is_silent : 1, - is_recursive : 1; + is_rpropagation : 1; /* recursive propagation (rbind, rprivate, ...) */ }; struct libmnt_optlist *mnt_new_optlist(void) @@ -203,7 +203,7 @@ int mnt_optlist_remove_opt(struct libmnt_optlist *ls, struct libmnt_opt *opt) ls->is_silent = 0; if (opt->ent->id & MS_REC) - ls->is_recursive = 0; + ls->is_rpropagation = 0; } optlist_cleanup_cache(ls); @@ -475,7 +475,7 @@ static struct libmnt_opt *optlist_new_opt(struct libmnt_optlist *ls, ls->is_silent = 1; if (opt->ent->id & MS_REC) { - ls->is_recursive = 1; + ls->is_rpropagation = 1; opt->recursive = 1; } } @@ -1104,9 +1104,9 @@ int mnt_optlist_is_remount(struct libmnt_optlist *ls) return ls && ls->is_remount; } -int mnt_optlist_is_recursive(struct libmnt_optlist *ls) +int mnt_optlist_is_rpropagation(struct libmnt_optlist *ls) { - return ls && ls->is_recursive; + return ls && ls->is_rpropagation; } int mnt_optlist_is_move(struct libmnt_optlist *ls) -- 2.47.2