the fsync() based approach - when it works - would give the following 
advantage: either the new records or the old records file is there. Thus at 
maximum one interval of uptime is lost. With checking sanity of 
configuration file everything since the last backup from uptimed is lost, 
which might be days, *weeks or more..

An idea comes to my mind: How about saving the *current* record in an own 
file in the same format, one line, thats no more than a sector. Either this 
thing is on disk or the old one is still there, fsync() or not.

Then when uptimed starts up from a fresh boot it generated a new bootid 
and integrated the old one into the records file. uprecords would be 
changed to read both "records" and "current-record", merging them.

This also makes saving records an O(1) operation. No matter how many 
records are stored in the records file, the current-records file just holds 
the current record.

-- 
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de
GPG: 03B0 0D6C 0040 0710 4AFA  B82F 991B EAAC A599 84C7

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to