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

enh enh at google.com
Mon Aug 31 11:44:07 PDT 2015


On Sun, Aug 30, 2015 at 4:06 AM, Rob Landley <rob at landley.net> wrote:
> On 08/29/2015 03:58 PM, enh wrote:
>> ping. i can't try switching Android over (to see if anyone notices)
>> until i can actually build toybox uptime...
>
> Sorry, turns out after presenting at three conferences in one week, I
> might spend the next week in zombie-like recovery. (Who knew?)
>
>> 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.
>
> I actually have a half-finished commit here that modifies uptime to have
> -al options for the android and linux output formats, and selects the
> default based on CFG_TOYBOX_ANDROID.
>
> The android format is arguably more useful for android than the linux
> one. For one thing, the "X users" field is meaningless on android, since
> you repurposed UID to mean something else.

yeah, that's clearly meaningless, but the load average isn't
completely useless (but is missing in the Android output), and the
idle/sleep output while theoretically useful is pretty confusing at
the best of times. right now, for example, my N9 says:

$ adb shell uptime
up time: 2 days, 13:49:13, idle time: 5 days, 03:29:06, sleep time: 00:00:00

i'd like to try the traditional output first and see if anyone even notices.

"adb shell dumpsys batterystats" is far more detailed (perhaps
excessively so), and i've no idea whether anyone actually uses uptime
for a rough idea of what's been going on (nor whether they actually
learn anything useful or are just left even more confused).

> So I think the right fix is to extend toybox uptime, but we also need to
> fix the android build issue and if I want to avoid #ifdefs in the code
> (yup) that means I add stubs to portability.h.
>
> I just checked in portability.h glue to make it build, if that's enough
> for you let me know, but if you want the -al options it's not a big deal.
>
> Thanks,
>
> Rob
>
> (I still need to set up a standalone android build environment...)
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net



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

 1441046647.0


More information about the Toybox mailing list