]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mount: use internally string to set move/bind operations
authorKarel Zak <kzak@redhat.com>
Fri, 1 Jun 2018 10:11:03 +0000 (12:11 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 1 Jun 2018 10:11:03 +0000 (12:11 +0200)
It's better to inform libmount about operations by string than by
flags, because for example "rbind,slave" cannot be specified by
MS_REC|MS_BIND|MS_SLAVE.

https://bugzilla.redhat.com/show_bug.cgi?id=1584443
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/mount.c

index 3a7bbf6ddbf775470f39f37c2b841f6c3cc6684d..22672c40b3dc7de91f317726b0f914cd75792d24 100644 (file)
@@ -517,7 +517,7 @@ int main(int argc, char **argv)
        struct libmnt_table *fstab = NULL;
        char *srcbuf = NULL;
        char *types = NULL;
-       unsigned long oper = 0;
+       int oper = 0;
        int propa = 0;
        int optmode = 0, optmode_mode = 0, optmode_src = 0;
 
@@ -679,13 +679,16 @@ int main(int argc, char **argv)
                        mnt_context_enable_sloppy(cxt, TRUE);
                        break;
                case 'B':
-                       oper |= MS_BIND;
+                       oper = 1;
+                       append_option(cxt, "bind");
                        break;
                case 'M':
-                       oper |= MS_MOVE;
+                       oper = 1;
+                       append_option(cxt, "move");
                        break;
                case 'R':
-                       oper |= (MS_BIND | MS_REC);
+                       oper = 1;
+                       append_option(cxt, "rbind");
                        break;
                case MOUNT_OPT_SHARED:
                        append_option(cxt, "shared");
@@ -867,10 +870,6 @@ int main(int argc, char **argv)
        if (mnt_context_is_restricted(cxt))
                sanitize_paths(cxt);
 
-       if (oper)
-               /* BIND/MOVE operations, let's set the mount flags */
-               mnt_context_set_mflags(cxt, oper);
-
        if ((oper && !has_remount_flag(cxt)) || propa)
                /* For --make-* or --bind is fstab/mtab unnecessary */
                mnt_context_set_optsmode(cxt, MNT_OMODE_NOTAB);