]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
pinky,users,who: optimize read_utmp invocation
authorBruno Haible <bruno@clisp.org>
Thu, 10 Aug 2023 11:50:57 +0000 (13:50 +0200)
committerPádraig Brady <P@draigBrady.com>
Fri, 11 Aug 2023 13:07:37 +0000 (14:07 +0100)
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.

src/pinky.c
src/users.c
src/who.c

index 5ad05e5539867268feeb140dfb24e48b68bb1d9b..3427fb12b05b90c3759865eee43e3a5f55a0e59f 100644 (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);
index cdb7660042d1c17b98895c2aa2bd7c734cafd877..f89fe65f19de279339dda4ce0caecd964af305df 100644 (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));
 
index 293e3b77050cc1209a4b69a5d02ca0bc0dfe9804..c235f943d956d528086e64dbff95c77902ec48bd 100644 (file)
--- 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));