Skip to content

Feature/installdate module - #2764

Closed
DavCyril wants to merge 2 commits into
fastfetch-cli:devfrom
DavCyril:feature/installdate-module
Closed

DavCyril wants to merge 2 commits into
fastfetch-cli:devfrom
DavCyril:feature/installdate-module

Conversation

@DavCyril

@DavCyril DavCyril commented Nov 28, 2026 •

Copy link
Copy Markdown

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

  • I have tested my changes locally.

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

@CarterLi CarterLi Nov 29, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires root

*
* 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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" },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ffTimeToShortStr and ffTimeToFullStr share the same static buffer, so in this case they are always the same.

@CarterLi

Copy link
Copy Markdown
Member

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 Disk module with create-time (also not reliable).

@CarterLi CarterLi closed this Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants