From: Bruno Haible Date: Thu, 10 Aug 2023 11:50:57 +0000 (+0200) Subject: pinky,users,who: optimize read_utmp invocation X-Git-Tag: v9.4~36 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d70d55c0a4756f7f9d82c331b0797f1ebcfcbb7c;p=thirdparty%2Fcoreutils.git pinky,users,who: optimize read_utmp invocation When we are only interested in entries of type USER_PROCESS, tell read_utmp that it does not need to determine the boot time. * src/pinky.c (short_pinky): Pass option READ_UTMP_USER_PROCESS. * src/users.c (users): Likewise. * src/who.c (who): Likewise, if calling list_entries_who. --- diff --git a/src/pinky.c b/src/pinky.c index 5ad05e5539..3427fb12b0 100644 --- a/src/pinky.c +++ b/src/pinky.c @@ -466,7 +466,7 @@ short_pinky (char const *filename, { idx_t n_users; struct gl_utmp *utmp_buf; - if (read_utmp (filename, &n_users, &utmp_buf, 0) != 0) + if (read_utmp (filename, &n_users, &utmp_buf, READ_UTMP_USER_PROCESS) != 0) error (EXIT_FAILURE, errno, "%s", quotef (filename)); scan_entries (n_users, utmp_buf, argc_names, argv_names); diff --git a/src/users.c b/src/users.c index cdb7660042..f89fe65f19 100644 --- a/src/users.c +++ b/src/users.c @@ -84,6 +84,7 @@ users (char const *filename, int options) { idx_t n_users; struct gl_utmp *utmp_buf; + options |= READ_UTMP_USER_PROCESS; if (read_utmp (filename, &n_users, &utmp_buf, options) != 0) error (EXIT_FAILURE, errno, "%s", quotef (filename)); diff --git a/src/who.c b/src/who.c index 293e3b7705..c235f943d9 100644 --- a/src/who.c +++ b/src/who.c @@ -619,6 +619,8 @@ who (char const *filename, int options) { idx_t n_users; struct gl_utmp *utmp_buf; + if (short_list) + options |= READ_UTMP_USER_PROCESS; if (read_utmp (filename, &n_users, &utmp_buf, options) != 0) error (EXIT_FAILURE, errno, "%s", quotef (filename));