]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mount: keep MS_MOVE as flag
authorKarel Zak <kzak@redhat.com>
Fri, 1 Jun 2018 12:07:53 +0000 (14:07 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 1 Jun 2018 12:07:53 +0000 (14:07 +0200)
The previous commit 4ebea84bb1ca6b0fa817588aba13de26c8d5e5a0 replaced
all operations by strings, but it does not work for MS_MOVE as this
operation is not supported in fstab by libmount.

Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context.c
sys-utils/mount.c

index 8e00b75a9e70f098d0a4889eec379cf47f8b02ac..7add0e39e9c3ae3ae75ccc726f705e2930a9c26b 100644 (file)
@@ -892,6 +892,9 @@ const char *mnt_context_get_fstype(struct libmnt_context *cxt)
  * @cxt: mount context
  * @optstr: comma delimited mount options
  *
+ * Note that that MS_MOVE cannot be specified as "string". It's operation that
+ * is no supported in fstab (etc.)
+ *
  * Returns: 0 on success, negative number in case of error.
  */
 int mnt_context_set_options(struct libmnt_context *cxt, const char *optstr)
@@ -1377,7 +1380,7 @@ struct libmnt_lock *mnt_context_get_lock(struct libmnt_context *cxt)
  *
  * Be careful if you want to use MS_REC flag -- in this case the bit is applied
  * to all bind/slave/etc. options. If you want to mix more propadation flags
- * and/or bind, move operations than it's better to specify mount options by
+ * and/or bind operations than it's better to specify mount options by
  * strings.
  *
  * Returns: 0 on success, negative number in case of error.
index 22672c40b3dc7de91f317726b0f914cd75792d24..040a84a57567553143f6dd46ebb820acff8bdae3 100644 (file)
@@ -517,7 +517,7 @@ int main(int argc, char **argv)
        struct libmnt_table *fstab = NULL;
        char *srcbuf = NULL;
        char *types = NULL;
-       int oper = 0;
+       int oper = 0, is_move = 0;
        int propa = 0;
        int optmode = 0, optmode_mode = 0, optmode_src = 0;
 
@@ -684,7 +684,7 @@ int main(int argc, char **argv)
                        break;
                case 'M':
                        oper = 1;
-                       append_option(cxt, "move");
+                       is_move = 1;
                        break;
                case 'R':
                        oper = 1;
@@ -870,6 +870,10 @@ int main(int argc, char **argv)
        if (mnt_context_is_restricted(cxt))
                sanitize_paths(cxt);
 
+       if (is_move)
+               /* "move" as option string is not supported by libmount */
+               mnt_context_set_mflags(cxt, MS_MOVE);
+
        if ((oper && !has_remount_flag(cxt)) || propa)
                /* For --make-* or --bind is fstab/mtab unnecessary */
                mnt_context_set_optsmode(cxt, MNT_OMODE_NOTAB);