SIGN IN SIGN UP
google / gvisor UNCLAIMED

Application Kernel for Containers

0 0 259 Go

tmpfs: Update mtime/ctime on open(O_TRUNC) for zero-length files

Linux unconditionally updates mtime and ctime when handling O_TRUNC via handle_truncate() -> do_truncate() with ATTR_MTIME|ATTR_CTIME, regardless of whether the file size actually changes.

gVisor's tmpfs truncateLocked() returns early when newSize == oldSize, skipping the timestamp update. This causes programs that rely on mtime changes (e.g. file sync tools, make) to malfunction when repeatedly truncating an already-empty file.

Fix by calling d.inode.touchCMtime() after truncate(0) in the O_TRUNC path of dentry.open(), ensuring timestamps are always updated consistent with Linux behavior.

FUTURE_COPYBARA_INTEGRATE_REVIEW=https://github.com/google/gvisor/pull/12771 from tanyifeng:tmpfs-otrunc-mtime d5da431bbdc2b2a87b942edae1ac1df1fcc392b3
PiperOrigin-RevId: 890945858
Y
yiftan committed
22ad7ba254e4923e807d564c400a7580cbc54517
Parent: 101d811
Committed by gVisor bot <gvisor-bot@google.com> on 3/30/2026, 9:01:53 PM