1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-12 15:06:44 +02:00

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.
This commit is contained in:
Bruno Haible
2023-08-10 13:50:57 +02:00
committed by Pádraig Brady
parent ad82336026
commit d70d55c0a4
3 changed files with 4 additions and 1 deletions

View File

@@ -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);

View File

@@ -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));

View File

@@ -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));