]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: revert X-* and x-* meaning
authorKarel Zak <kzak@redhat.com>
Fri, 9 Dec 2016 14:11:31 +0000 (15:11 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 9 Dec 2016 14:36:14 +0000 (15:36 +0100)
Let's hope this is last change necessary to cleanup x-* usage:

  x-*  persistent option, stored in utab, available for umount, etc.
  X-*  fstab comment only

mount(8) supports x-mount.mkdir= as well as newly recommended X-mount.mkdir=

Advantages:

 * less invasive
 * does not require exception for x-systemd
 * does not require rename x-initrd to X-initrd

The systemd and dracut users will get the new (=fixed) functionality without a
change in fstab configuration. This is the primary goal.

Disadvantages:

 * not 100% compatible libmount behavior, x-* options have not been
   previously stored in utab. The API is the same, options will be still
   available, but on x-* libmount will write to /run/mount/utab. For now
   it seems only systemd uses x-*, and they like this behavior, so...

Addresses: https://github.com/systemd/systemd/pull/4515
Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
libmount/src/context.c
libmount/src/libmount.h.in
libmount/src/optmap.c
sys-utils/mount.8
tests/ts/libmount/context

index e0240b322e15fefeaba3769112959615f2082055..08e06ffab2e7dda747736c5e60806a1ebcffc64d 100644 (file)
@@ -1971,7 +1971,6 @@ AS_IF([test "x$with_systemd" != xno], [
       [AC_MSG_ERROR([systemd expected but libsystemd not found])],
     [*:yes],
        AC_DEFINE([HAVE_LIBSYSTEMD], [1], [Define if libsystemd is available])
-       AC_DEFINE([HAVE_SYSTEMD], [1], [Define if systemd should be supported])
   )
 ])
 AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$have_systemd" = xyes])
index 87ccccfc6e3d7149a14e34b31995cdde33cb3112..44282c07bf9e5d9f38fc77f3a280deb51797d9d2 100644 (file)
@@ -1531,7 +1531,7 @@ int mnt_context_prepare_srcpath(struct libmnt_context *cxt)
        return 0;
 }
 
-/* create a mountpoint if x-mount.mkdir[=<mode>] specified */
+/* create a mountpoint if X-mount.mkdir[=<mode>] specified */
 static int mkdir_target(const char *tgt, struct libmnt_fs *fs)
 {
        char *mstr = NULL;
@@ -1543,8 +1543,12 @@ static int mkdir_target(const char *tgt, struct libmnt_fs *fs)
        assert(tgt);
        assert(fs);
 
-       if (mnt_optstr_get_option(fs->user_optstr, "x-mount.mkdir", &mstr, &mstr_sz) != 0)
+       if (mnt_optstr_get_option(fs->user_optstr, "X-mount.mkdir", &mstr, &mstr_sz) != 0 &&
+           mnt_optstr_get_option(fs->user_optstr, "x-mount.mkdir", &mstr, &mstr_sz) != 0)      /* obsolete */
                return 0;
+
+       DBG(CXT, ul_debug("mkdir %s (%s) wanted", tgt, mstr));
+
        if (mnt_stat_mountpoint(tgt, &st) == 0)
                return 0;
 
@@ -1591,7 +1595,8 @@ int mnt_context_prepare_target(struct libmnt_context *cxt)
        /* mkdir target */
        if (cxt->action == MNT_ACT_MOUNT
            && !mnt_context_is_restricted(cxt)
-           && cxt->user_mountflags & MNT_MS_XCOMMENT) {
+           && (cxt->user_mountflags & MNT_MS_XCOMMENT ||
+               cxt->user_mountflags & MNT_MS_XFSTABCOMM)) {
 
                rc = mkdir_target(tgt, cxt->fs);
                if (rc)
index cbd4f000e4b12d99d2e0e427878db25fabe02753..f191a52fe0334f53078497b5b290a33442c889ed 100644 (file)
@@ -774,7 +774,7 @@ extern int mnt_context_set_syscall_status(struct libmnt_context *cxt, int status
 #define MNT_MS_OFFSET   (1 << 14)
 #define MNT_MS_SIZELIMIT (1 << 15)
 #define MNT_MS_ENCRYPTION (1 << 16)
-#define MNT_MS_XPERSIST (1 << 17)
+#define MNT_MS_XFSTABCOMM (1 << 17)
 
 /*
  * mount(2) MS_* masks (MNT_MAP_LINUX map)
index 114eb994e9eadf6d0fa2b420c186790096967a40..0aa285f938cabdda2a7f1387bfdf3c759e480ffc 100644 (file)
@@ -160,15 +160,8 @@ static const struct libmnt_optmap userspace_opts_map[] =
 
    { "comment=", MNT_MS_COMMENT, MNT_NOHLPS | MNT_NOMTAB },/* fstab comment only */
 
-   /*
-    * systemd assumes that x-systemd options namespace is available for umount,
-    * let's use the options as X-*
-    */
-#ifdef HAVE_SYSTEMD
-   { "x-systemd", MNT_MS_XPERSIST, MNT_NOHLPS | MNT_PREFIX },           /* like X-* */
-#endif
-   { "X-",      MNT_MS_XPERSIST, MNT_NOHLPS | MNT_PREFIX },              /* X- persistent comments (utab) */
-   { "x-",      MNT_MS_XCOMMENT, MNT_NOHLPS | MNT_NOMTAB | MNT_PREFIX }, /* x- fstab only comments */
+   { "x-",      MNT_MS_XCOMMENT,   MNT_NOHLPS | MNT_PREFIX },              /* persistent comments (utab) */
+   { "X-",      MNT_MS_XFSTABCOMM, MNT_NOHLPS | MNT_NOMTAB | MNT_PREFIX }, /* fstab only comments */
 
    { "loop[=]", MNT_MS_LOOP, MNT_NOHLPS },                             /* use the loop device */
    { "offset=", MNT_MS_OFFSET, MNT_NOHLPS | MNT_NOMTAB },                 /* loop device offset */
index f80b20252a7c98c54909acf6360391e468306398..54ad0d8d0fc96bd5260880587ae08ac364e8f1a3 100644 (file)
@@ -1142,32 +1142,34 @@ This option implies the options
 (unless overridden by subsequent options, as in the option line
 .BR users,exec,dev,suid ).
 .TP
-.B x-*
-All options prefixed with "x-" are interpreted as comments or as userspace
+.B X-*
+All options prefixed with "X-" are interpreted as comments or as userspace
 application-specific options.  These options are not stored in the user space (e.g. mtab file),
 nor sent to the mount.\fItype\fR helpers nor to the
 .BR mount (2)
-system call.  The suggested format is \fBx-\fIappname\fR.\fIoption\fR.
+system call.  The suggested format is \fBX-\fIappname\fR.\fIoption\fR.
 .TP
-.B X-*
-The same as \fBx-*\fR options, but stored permanently in the user space. It
+.B x-*
+The same as \fBX-*\fR options, but stored permanently in the user space. It
 means the options are also available for umount or another operations.  Note
-that maintain mount options in user space is a bad idea, because it's necessary
-to link all tools that use the options with libmount and there is no guarantee that the
-options will be always available (for example after a move mount operation or in
-unshared namespace).
-
-Note that x-systemd mount options are maintained as X-* options, the rename is
-unnecessary to keep existing fstab settings backwardly compatible.
+that maintain mount options in user space is tricky, because it's necessary use
+libmount based tools and there is no guarantee that the options will be always
+available (for example after a move mount operation or in unshared namespace).
 
+Note that before util-linux v2.30 the x-* options have not been maintained by
+libmount and stored in user space (functionality was the same as have X-* now),
+but due to growing number of use-cases (in initrd, systemd etc.) the
+functionality have been extended to keep existing fstab configurations usable
+without a change.
 .TP
-.BR x-mount.mkdir [ = \fImode\fR ]
+.BR X-mount.mkdir [ = \fImode\fR ]
 Allow to make a target directory (mountpoint).  The optional argument
 .I mode
 specifies the filesystem access mode used for
 .BR mkdir (2)
 in octal notation.  The default mode is 0755.  This functionality is supported
-only for root users.
+only for root users.  The option is also supported as x-mount.mkdir, this notation
+is deprecated for mount.mkdir since v2.30.
 
 .SH "FILESYSTEM-SPECIFIC MOUNT OPTIONS"
 The following options apply only to certain filesystems.
index ebb24411029a9d5989d260880866b810477dbe8b..2d85dbb5923caf9d2eec5b669d7b478b5d272710 100755 (executable)
@@ -23,9 +23,6 @@ LABEL=libmount-test
 UUID=$($TS_CMD_UUIDGEN)
 
 MOUNTPOINT="$TS_MOUNTPOINT"
-TS_NOEXIST="$TS_OUTDIR/${TS_TESTNAME}-${TS_SUBNAME}-noex"
-[ -d $TS_NOEXIST ] && rmdir $TS_NOEXIST
-
 [ -x $TESTPROG ] || ts_skip "test not compiled"
 
 ts_log "Init device"
@@ -147,7 +144,11 @@ is_mounted $MOUNTPOINT && echo "$MOUNTPOINT still mounted" >> $TS_OUTPUT 2>&1
 ts_finalize_subtest
 
 
+# deprecated
 ts_init_subtest "x-mount.mkdir"
+TS_NOEXIST="$TS_OUTDIR/${TS_TESTNAME}-${TS_SUBNAME}-noex"
+[ -d $TS_NOEXIST ] && rmdir $TS_NOEXIST
+
 $TS_CMD_MOUNT -o x-mount.mkdir --bind $MOUNTPOINT $TS_NOEXIST >> $TS_OUTPUT 2>&1 &&
   echo "successfully mounted" >> $TS_OUTPUT
 ts_finalize_subtest
@@ -155,5 +156,17 @@ ts_finalize_subtest
 $TS_CMD_UMOUNT $TS_NOEXIST
 rmdir $TS_NOEXIST
 
+
+ts_init_subtest "X-mount.mkdir"
+TS_NOEXIST="$TS_OUTDIR/${TS_TESTNAME}-${TS_SUBNAME}-noex"
+[ -d $TS_NOEXIST ] && rmdir $TS_NOEXIST
+
+$TS_CMD_MOUNT -o X-mount.mkdir --bind $MOUNTPOINT $TS_NOEXIST >> $TS_OUTPUT 2>&1 &&
+  echo "successfully mounted" >> $TS_OUTPUT
+ts_finalize_subtest
+
+$TS_CMD_UMOUNT $TS_NOEXIST
+rmdir $TS_NOEXIST
+
 ts_log "...done."
 ts_finalize