diff options
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | libmount/src/context.c | 11 | ||||
-rw-r--r-- | libmount/src/libmount.h.in | 2 | ||||
-rw-r--r-- | libmount/src/optmap.c | 11 | ||||
-rw-r--r-- | sys-utils/mount.8 | 30 | ||||
-rwxr-xr-x | tests/ts/libmount/context | 19 |
6 files changed, 43 insertions, 31 deletions
diff --git a/configure.ac b/configure.ac index e0240b322..08e06ffab 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) diff --git a/libmount/src/context.c b/libmount/src/context.c index 87ccccfc6..44282c07b 100644 --- a/libmount/src/context.c +++ b/libmount/src/context.c @@ -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) diff --git a/libmount/src/libmount.h.in b/libmount/src/libmount.h.in index cbd4f000e..f191a52fe 100644 --- a/libmount/src/libmount.h.in +++ b/libmount/src/libmount.h.in @@ -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) diff --git a/libmount/src/optmap.c b/libmount/src/optmap.c index 114eb994e..0aa285f93 100644 --- a/libmount/src/optmap.c +++ b/libmount/src/optmap.c @@ -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 */ diff --git a/sys-utils/mount.8 b/sys-utils/mount.8 index f80b20252..54ad0d8d0 100644 --- a/sys-utils/mount.8 +++ b/sys-utils/mount.8 @@ -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. diff --git a/tests/ts/libmount/context b/tests/ts/libmount/context index ebb244110..2d85dbb59 100755 --- a/tests/ts/libmount/context +++ b/tests/ts/libmount/context @@ -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 |