|
|
2610e7 |
From 5d150964f0b2fbcaa9f9d11809eede9255159a5d Mon Sep 17 00:00:00 2001
|
|
|
2610e7 |
From: Karel Zak <kzak@redhat.com>
|
|
|
2610e7 |
Date: Mon, 13 Dec 2021 13:22:56 +0100
|
|
|
2610e7 |
Subject: mount: add hint about systemctl daemon-reload
|
|
|
2610e7 |
|
|
|
2610e7 |
This commit implements an extra hint for systemd based distros to
|
|
|
2610e7 |
inform users that units currently used by systemd are older than
|
|
|
2610e7 |
fstab. This situation is usually unwanted, and 'systemctl
|
|
|
2610e7 |
daemon-reload' is recommended.
|
|
|
2610e7 |
|
|
|
2610e7 |
The message is printed only on terminal to avoid extra messages in
|
|
|
2610e7 |
logs, etc.
|
|
|
2610e7 |
|
|
|
2610e7 |
Addresses: https://github.com/systemd/systemd/pull/20476
|
|
|
2610e7 |
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2180414
|
|
|
2610e7 |
Upstream: http://github.com/util-linux/util-linux/commit/1db0715169954a8f3898f7ca9d3902cd6c27084d
|
|
|
2610e7 |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
2610e7 |
---
|
|
|
2610e7 |
include/pathnames.h | 2 ++
|
|
|
2610e7 |
sys-utils/mount.c | 23 +++++++++++++++++++++++
|
|
|
2610e7 |
2 files changed, 25 insertions(+)
|
|
|
2610e7 |
|
|
|
2610e7 |
diff --git a/include/pathnames.h b/include/pathnames.h
|
|
|
2610e7 |
index 7e7d9053f..8c3c36477 100644
|
|
|
2610e7 |
--- a/include/pathnames.h
|
|
|
2610e7 |
+++ b/include/pathnames.h
|
|
|
2610e7 |
@@ -82,6 +82,8 @@
|
|
|
2610e7 |
#define _PATH_NUMLOCK_ON _PATH_RUNSTATEDIR "/numlock-on"
|
|
|
2610e7 |
#define _PATH_LOGINDEFS "/etc/login.defs"
|
|
|
2610e7 |
|
|
|
2610e7 |
+#define _PATH_SD_UNITSLOAD _PATH_RUNSTATEDIR "/systemd/systemd-units-load"
|
|
|
2610e7 |
+
|
|
|
2610e7 |
/* misc paths */
|
|
|
2610e7 |
#define _PATH_WORDS "/usr/share/dict/words"
|
|
|
2610e7 |
#define _PATH_WORDS_ALT "/usr/share/dict/web2"
|
|
|
2610e7 |
diff --git a/sys-utils/mount.c b/sys-utils/mount.c
|
|
|
2610e7 |
index ce1de16dc..90a0331c3 100644
|
|
|
2610e7 |
--- a/sys-utils/mount.c
|
|
|
2610e7 |
+++ b/sys-utils/mount.c
|
|
|
2610e7 |
@@ -38,6 +38,7 @@
|
|
|
2610e7 |
#include "strutils.h"
|
|
|
2610e7 |
#include "closestream.h"
|
|
|
2610e7 |
#include "canonicalize.h"
|
|
|
2610e7 |
+#include "pathnames.h"
|
|
|
2610e7 |
|
|
|
2610e7 |
#define XALLOC_EXIT_CODE MNT_EX_SYSERR
|
|
|
2610e7 |
#include "xalloc.h"
|
|
|
2610e7 |
@@ -336,6 +337,25 @@ static void selinux_warning(struct libmnt_context *cxt, const char *tgt)
|
|
|
2610e7 |
# define selinux_warning(_x, _y)
|
|
|
2610e7 |
#endif
|
|
|
2610e7 |
|
|
|
2610e7 |
+static void systemd_hint(void)
|
|
|
2610e7 |
+{
|
|
|
2610e7 |
+ static int fstab_check_done = 0;
|
|
|
2610e7 |
+
|
|
|
2610e7 |
+ if (fstab_check_done == 0) {
|
|
|
2610e7 |
+ struct stat a, b;
|
|
|
2610e7 |
+
|
|
|
2610e7 |
+ if (isatty(STDERR_FILENO) &&
|
|
|
2610e7 |
+ stat(_PATH_SD_UNITSLOAD, &a) == 0 &&
|
|
|
2610e7 |
+ stat(_PATH_MNTTAB, &b) == 0 &&
|
|
|
2610e7 |
+ cmp_stat_mtime(&a, &b, <))
|
|
|
2610e7 |
+ printf(_(
|
|
|
2610e7 |
+ "mount: (hint) your fstab has been modified, but systemd still uses\n"
|
|
|
2610e7 |
+ " the old version; use 'systemctl daemon-reload' to reload.\n"));
|
|
|
2610e7 |
+
|
|
|
2610e7 |
+ fstab_check_done = 1;
|
|
|
2610e7 |
+ }
|
|
|
2610e7 |
+}
|
|
|
2610e7 |
+
|
|
|
2610e7 |
/*
|
|
|
2610e7 |
* Returns exit status (MNT_EX_*) and/or prints error message.
|
|
|
2610e7 |
*/
|
|
|
2610e7 |
@@ -359,6 +379,9 @@ static int mk_exit_code(struct libmnt_context *cxt, int rc)
|
|
|
2610e7 |
if (rc == MNT_EX_SUCCESS && mnt_context_get_status(cxt) == 1) {
|
|
|
2610e7 |
selinux_warning(cxt, tgt);
|
|
|
2610e7 |
}
|
|
|
2610e7 |
+
|
|
|
2610e7 |
+ systemd_hint();
|
|
|
2610e7 |
+
|
|
|
2610e7 |
return rc;
|
|
|
2610e7 |
}
|
|
|
2610e7 |
|
|
|
2610e7 |
--
|
|
|
2610e7 |
2.39.2
|
|
|
2610e7 |
|