10000 mount: check for stdout for fstab reload hint · util-linux/util-linux@cdc8b26 · GitHub
[go: up one dir, main page]

Skip to content

Commit cdc8b26

Browse files
committed
mount: check for stdout for fstab reload hint
Fixes: #3558 Signed-off-by: Karel Zak <kzak@redhat.com>
1 parent 4e41733 commit cdc8b26

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sys-utils/mount.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,16 @@ static void selinux_warning(struct libmnt_context *cxt, const char *tgt)
334334

335335

336336
#ifdef USE_SYSTEMD
337+
/*
338+
* Note that this mount(8) message may generate thousands of lines of output
339+
* when mount(8) is called from any script in systems with large fstab, etc.
340+
*
341+
* The goal is to avoid spamming system logs (don't print on stderr) and hide
342+
* the hint if stderr is redirected/piped (in this case mount(8) is probably
343+
* executed in a script).
344+
*
345+
* The target audience is users on a terminal who directly use mount(8).
346+
*/
337347
static void systemd_hint(void)
338348
{
339349
static int fstab_check_done = 0;
@@ -342,6 +352,7 @@ static void systemd_hint(void)
342352
struct stat a, b;
343353

344354
if (isatty(STDERR_FILENO) &&
355+
isatty(STDOUT_FILENO) &&
345356
stat(_PATH_SD_UNITSLOAD, &a) == 0 &&
346357
stat(_PATH_MNTTAB, &b) == 0 &&
347358
cmp_stat_mtime(&a, &b, <))

0 commit comments

Comments
 (0)
0