10000 mount: check for stdout for fstab reload hint by karelzak · Pull Request #3561 · util-linux/util-linux · GitHub
[go: up one dir, main page]

Skip to content

mount: check for stdout for fstab reload hint #3561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions sys-utils/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,16 @@ static void selinux_warning(struct libmnt_context *cxt, const char *tgt)


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

if (isatty(STDERR_FILENO) &&
isatty(STDOUT_FILENO) &&
stat(_PATH_SD_UNITSLOAD, &a) == 0 &&
stat(_PATH_MNTTAB, &b) == 0 &&
cmp_stat_mtime(&a, &b, <))
Expand Down
0