8000 Merge branch 'PR/mount-hint-tty' of https://github.com/karelzak/util-… · util-linux/util-linux@36f9f45 · GitHub
[go: up one dir, main page]

Skip to content

Commit 36f9f45

Browse files
committed
Merge branch 'PR/mount-hint-tty' of https://github.com/karelzak/util-linux-work
* 'PR/mount-hint-tty' of https://github.com/karelzak/util-linux-work: mount: check for stdout for fstab reload hint
2 parents 090d8ca + cdc8b26 commit 36f9f45

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sys-utils/mount.c

+11
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