[Toybox] [PATCH] Fix uptime.c to build when CFG_TOYBOX_UTMPX is false.
enh
enh at google.com
Mon Aug 17 11:12:19 PDT 2015
Fix uptime.c to build when CFG_TOYBOX_UTMPX is false.
The alternative is to provide dummy setutxent, getutxent, endutxent,
struct utmpx, and USER_PROCESS in portability.h, but that seems more
distasteful (and is the reason bionic is unlikely to ever have
<utmpx.h>).
Note that there's an equivalent problem with CFG_TOYBOX_SHADOW, but
Android doesn't build the affected toybox commands because they're
useless on Android for the same reason Android doesn't have
<shadow.h>: our concept of user is fundamentally different.
diff --git a/toys/other/uptime.c b/toys/other/uptime.c
index 91887df..a0e7831 100644
--- a/toys/other/uptime.c
+++ b/toys/other/uptime.c
@@ -34,10 +34,12 @@ void uptime_main(void)
time(&tmptime);
now = localtime(&tmptime);
+#if CFG_TOYBOX_UTMPX
// Obtain info about logged on users
setutxent();
while ((entry = getutxent())) if (entry->ut_type == USER_PROCESS) users++;
endutxent();
+#endif
// Time
xprintf(" %02d:%02d:%02d up ", now->tm_hour, now->tm_min, now->tm_sec);
1439835139.0
More information about the Toybox
mailing list