Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#197882 - 11/01/2004 04:47 PowerOnSeconds
tman
carpal tunnel

Registered: 24/12/2001
Posts: 5528
Does anybody actually have a valid PowerOnSeconds value in /empeg/empeg_state on a Mk2+? Mine has always been invalid. There seems to be a bug in the kernel code which basically makes it not calculate it correctly. It's not particularly important as it's not used anywhere but it's been bugging me

It's supposed to work out the number of power on seconds by getting the current time, subtracting the bootup time and then adding the previously saved value of poweronseconds. The problem is that on a Mk2+ (Well. Anything greater than revision 5) it won't ever set the bootup time value (unixtime). This means that each time there is a powerfail it will add the number of seconds since the epoch. So you'll get 30ish years added on each time...

The problem is that even fixing this bug won't recover the correct poweronseconds value as it's been long lost. I've attached a patch anyway.


Attachments
196304-poweronseconds.patch (826 downloads)


Top
#197883 - 11/01/2004 11:12 Re: PowerOnSeconds [Re: tman]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14493
Loc: Canada
Just trying to read through that incredibly strange code in empeg_state.c confuses me.. What the heck is it trying to do there, anyway?


Top
#197884 - 11/01/2004 12:05 Re: PowerOnSeconds [Re: mlord]
tman
carpal tunnel

Registered: 24/12/2001
Posts: 5528
There are two important variables, unixtime and powerontime. unixtime is supposed to be when the empeg was booted in seconds since the epoch. powerontime is the cumulative number of seconds that the empeg has been on for at the exact moment it was booted.

It does this to calculate the new powerontime value at power fail:

new_powerontime = (current_time - unixtime) + old_powerontime

The problem is that unixtime is never set on a Mk2+ and you're getting this instead:

new_powerontime = current_time + old_powerontime

So on each powerfail, you'll increase powerontime by about 946080000.

Hopefully this is a better explanation than my first attempt!

Top
#197885 - 11/01/2004 12:55 Re: PowerOnSeconds [Re: tman]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14493
Loc: Canada
Clear as mud.

Does it now work for you, with the patch?

Top
#197886 - 11/01/2004 12:59 Re: PowerOnSeconds [Re: mlord]
tman
carpal tunnel

Registered: 24/12/2001
Posts: 5528
It works in that it does what it's supposed to and now properly keeps track of the value. However, the real PowerOnTime has been long lost due to this bug so whether the patch particularly useful or not is another thing. It's a small patch anyway.

Top
#197887 - 11/01/2004 13:05 Re: PowerOnSeconds [Re: tman]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14493
Loc: Canada
Well, if you say so. I still get a headache trying to figure out that code.

I've added the two line patch to my kernel tree, so whenever v354 of Hijack appears, those two lines will be part of it.

Cheers

Top