[Toybox] [PATCH] Fix uptime.c to build when CFG_TOYBOX_UTMPX is false.

enh enh at google.com
Sat Aug 29 13:58:03 PDT 2015


ping. i can't try switching Android over (to see if anyone notices)
until i can actually build toybox uptime...

On Mon, Aug 17, 2015 at 11:12 AM, enh <enh at google.com> wrote:
> 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);



-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.

 1440881883.0


More information about the Toybox mailing list