Repository navigation
Conversation
| static bool tryStatxBtime(const char* path, uint64_t* resultMs, const char** source) | ||
| { | ||
| struct statx stx; | ||
| if (syscall(SYS_statx, 0, path, 0, STATX_BTIME, &stx) == 0 |
There was a problem hiding this comment.
This breaks Android.
On Android, calling unsupported syscall raises SIGSYS, see #1993
| static const char* candidates[] = { | ||
| "/etc/machine-id", | ||
| "/var/log/installer", | ||
| "/root/anaconda-ks.cfg", |
| * | ||
| * 1. statx() birth time of /etc/machine-id | ||
| * The most reliable signal: machine-id is generated once at install time | ||
| * (by systemd-machine-id-setup or equivalent) and never rewritten. |
There was a problem hiding this comment.
So this works only on systemd distros.
| * The most reliable signal: machine-id is generated once at install time | ||
| * (by systemd-machine-id-setup or equivalent) and never rewritten. | ||
| * statx() with STATX_BTIME retrieves the inode birth timestamp, which | ||
| * survives file copies and permission changes — unlike mtime or ctime. |
There was a problem hiding this comment.
survives file copies
I don't think so. Copying files recreates inodes.
| * | ||
| * 3. mtime of /var/log/installer (Debian/Ubuntu) or /root/anaconda-ks.cfg (RHEL/Fedora) | ||
| * Installer artifacts left by distro-specific installers. Less universal | ||
| * but useful when machine-id has been regenerated. |
There was a problem hiding this comment.
Even if machine-id has been regenerated, it's still there, and statx(machine-id) still works, so /var/log/installer path never reaches.
| FF_ARG(age.daysOfYear, "days-of-year"), | ||
| FF_ARG(age.yearsFraction, "years-fraction"), | ||
| { FF_ARG_TYPE_STRING, ffTimeToShortStr(result.installTime), "install-date" }, | ||
| { FF_ARG_TYPE_STRING, ffTimeToFullStr(result.installTime), "install-date-full" }, |
There was a problem hiding this comment.
ffTimeToShortStr and ffTimeToFullStr share the same static buffer, so in this case they are always the same.
|
I don't like the change. I don't think any of the methods are fully reliable, and it's Linux-only. I think this suits best for Command module, or just use |
Adds a native InstallDate module that shows when the OS was installed and how long ago. Uses statx() birth time of /etc/machine-id as the primary probe, with stat() mtime and distro-specific installer artifacts as fallbacks. Linux-only for now; other platforms get a nosupport stub. Reuses existing ffTimeGetAge() for calendar-aware age computation.
Checklist