]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: (optlist) add is_recursive shortcut
authorKarel Zak <kzak@redhat.com>
Fri, 26 Aug 2022 08:17:30 +0000 (10:17 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Jan 2023 11:58:42 +0000 (12:58 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/mountP.h
libmount/src/optlist.c

index 8ececbc393c743e9e83547f0f34521e091695adf..51491eb2d710c66c7995c72ecf15a4488075c366 100644 (file)
@@ -537,6 +537,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_bind(struct libmnt_optlist *ls);
 extern int mnt_optlist_is_move(struct libmnt_optlist *ls);
 extern int mnt_optlist_is_rdonly(struct libmnt_optlist *ls);
index 875cad058f5f482736892878234a12117dfca8d6..a2b15d5b88e1ba3978dcea119ebbf393ff3c029a 100644 (file)
@@ -57,7 +57,8 @@ struct libmnt_optlist {
                        is_bind : 1,
                        is_rdonly : 1,
                        is_move : 1,
-                       is_silent : 1;
+                       is_silent : 1,
+                       is_recursive : 1;
 };
 
 struct libmnt_optlist *mnt_new_optlist(void)
@@ -179,7 +180,7 @@ int mnt_optlist_remove_opt(struct libmnt_optlist *ls, struct libmnt_opt *opt)
                        ls->propagation &= ~opt->ent->id;
                else if (opt->ent->id == MS_REMOUNT)
                        ls->is_remount = 0;
-               else if (opt->ent->id == MS_BIND)
+               else if (opt->ent->id & MS_BIND)        /* MS_BIND or MS_REC|MS_BIND */
                        ls->is_bind = 0;
                else if (opt->ent->id == MS_RDONLY)
                        ls->is_rdonly = 0;
@@ -187,6 +188,10 @@ int mnt_optlist_remove_opt(struct libmnt_optlist *ls, struct libmnt_opt *opt)
                        ls->is_move = 0;
                else if (opt->ent->id == MS_SILENT)
                        ls->is_silent = 0;
+
+               if (opt->ent->id & MS_REC)
+                       ls->is_recursive = 0;
+
        }
 
        optlist_cleanup_cache(ls, opt->map);
@@ -377,7 +382,7 @@ static struct libmnt_opt *optlist_new_opt(struct libmnt_optlist *ls,
                        ls->propagation |= ent->id;
                else if (opt->ent->id == MS_REMOUNT)
                        ls->is_remount = 1;
-               else if (opt->ent->id == MS_BIND)
+               else if (opt->ent->id & MS_BIND)        /* MS_BIND or MS_REC|MS_BIND */
                        ls->is_bind = 1;
                else if (opt->ent->id == MS_RDONLY)
                        ls->is_rdonly = 1;
@@ -385,6 +390,9 @@ static struct libmnt_opt *optlist_new_opt(struct libmnt_optlist *ls,
                        ls->is_move = 1;
                else if (opt->ent->id == MS_SILENT)
                        ls->is_silent = 1;
+
+               if (opt->ent->id & MS_REC)
+                       ls->is_recursive = 1;
        }
 
        if (ent && map) {
@@ -804,6 +812,11 @@ int mnt_optlist_is_remount(struct libmnt_optlist *ls)
        return ls && ls->is_remount;
 }
 
+int mnt_optlist_is_recursive(struct libmnt_optlist *ls)
+{
+       return ls && ls->is_recursive;
+}
+
 int mnt_optlist_is_move(struct libmnt_optlist *ls)
 {
        return ls && ls->is_move;