Search code examples
makefiletimestampfilesystemsstat

Does make use stat? And is that data stored in the OS?


I know this might be a stupid question.

I know that make tests for file changes based on the timestamp of a dependency and if it's newer than a target.

1) Does make use stat?

2) Information for stat is stored somewhere on the filesystem, correct?


Solution

  • The answer to both your questions is "yes". The last modification time is an attribute of every file (and directory) and is maintained by the filesystem (it's part of the directory entry on most filesystems but that's not a requirement).

    The way this data is accessed is via the stat(2) call (at least on POSIX systems; on Windows stat() exists but is a helper function translating to Windows native calls underneath).