Skip to content

metadatainiwriter: move to metadata file naming v2

Harald Sitter requested to merge work/sitter/metadatav2 into master

v2 is inspired by the coredumpd naming style which includes the pid, the exe name, the bootid, and the time of crash. this should provide us with plenty of entropy to persistently store metadata on disk without running risk of mistaking one crash for another. this in turn allows drkonqi to report on crashes it hasn't yet seen without ever reporting on a crash that it has already seen.

for us constructing this is a bit of a challenge because we don't want heap allocations during the signal handler.

so...

during init kcrash now constructs a path of the form $exe.$bootid.$pid. it then asks the MetadataINIWriter to grow that path so it can fit v2 (meaning it will grow the path to fit all digits of time_t plus a .ini file extensions). we further get two spans one spanning the already filled "prefix" portion and one spanning the to be filled "suffix" portion. these will be passed to the metadatainiwriter upon crash.

inside the iniwriter is most of the awkward complexity. when a crash happens it fills the v2 path by first performing a poor man's itoa() conversion, in-place, on the suffix span. afterwards it simply sets the file ending in the remaining space of the suffix. once done the path memory contains the complete v2 format $exe.$bootid.$pid.$epoch.ini and gets passed into the existing constructor logic.

Merge request reports