Description
While parsing tar entries, we are most probably not taking into account the latest modification time for a directory.
Issue in detail
The layers of a certain image
The directory in question is /usr/share/zoneinfo/Etc
mtime
of said directory in layer adad76f273c267201338df472d73aa2bfd8e5c5cdb72bd3abfe9a07de1b5d592
is 1 Jan 1970
.
mtime
of said directory in layer 0c31ce11ea42f8eabc0e18d7887bda77fea345403fe4ee9f5e2325f0e0bd85ef
is 20 May 2025
.
In the final generated EROFS image, the mtime
of said directory is recorded as 1 Jan 1970
, which is incorrect as 0c31...
is the newer layer.
This happens with other directories as well, not just the one mentioned above.
On an initial observation, this seems to only happen for directories and not for files.
The diff between an EROFS image generated by parsing an OCI image vs mounting a filesystem.
1c1
< / 0 40755 14 0 0 0 0.0 - - - security.selinux=system_u:object_r:root_t:s0
---
> / 0 40555 14 0 0 0 1747671178.0 - - - security.selinux=system_u:object_r:root_t:s0
10c10
< /etc/NetworkManager 0 40755 7 0 0 0 0.0 - - - security.selinux=system_u:object_r:NetworkManager_etc_t:s0
---
> /etc/NetworkManager 0 40755 7 0 0 0 1747211423.0 - - - security.selinux=system_u:object_r:NetworkManager_etc_t:s0
13c13
< /etc/NetworkManager/dispatcher.d 0 40755 5 0 0 0 0.0 - - - security.selinux=system_u:object_r:NetworkManager_dispatcher_script_t:s0
---
> /etc/NetworkManager/dispatcher.d 0 40755 5 0 0 0 1747211423.0 - - - security.selinux=system_u:object_r:NetworkManager_dispatcher_script_t:s0
21c21
< /etc/X11 0 40755 5 0 0 0 0.0 - - - security.selinux=system_u:object_r:etc_t:s0
---
> /etc/X11 0 40755 5 0 0 0 1747211422.0 - - - security.selinux=system_u:object_r:etc_t:s0
24,25c24,25
< /etc/X11/xinit 0 40755 4 0 0 0 0.0 - - - security.selinux=system_u:object_r:bin_t:s0
< /etc/X11/xinit/xinitrc.d 0 40755 2 0 0 0 0.0 - - - security.selinux=system_u:object_r:bin_t:s0
---
> /etc/X11/xinit 0 40755 4 0 0 0 1747211422.0 - - - security.selinux=system_u:object_r:bin_t:s0
> /etc/X11/xinit/xinitrc.d 0 40755 2 0 0 0 1747211422.0 - - - security.selinux=system_u:object_r:bin_t:s0
30c30
< /etc/alternatives 0 40755 2 0 0 0 0.0 - - - security.selinux=system_u:object_r:etc_t:s0
... goes on for a while