package snapshot import ( "os" "syscall" "time" ) // getCTime extracts the inode change time (ctime) from os.FileInfo. // // On Linux, this returns the inode change time (Ctim) from the underlying // syscall.Stat_t. Linux ctime is updated whenever file metadata (permissions, // ownership, link count) or content changes. It is NOT the file creation // (birth) time. // // Note: Linux ext4 (kernel 4.11+) and btrfs do track birth time via the // statx() syscall, but this is not exposed through Go's os.FileInfo.Sys(). // The inode change time is the best available approximation through standard // Go APIs. // // Falls back to modification time if the underlying Sys() data is not a // *syscall.Stat_t (e.g. when using in-memory filesystems for testing). func getCTime(info os.FileInfo) time.Time { stat, ok := info.Sys().(*syscall.Stat_t) if !ok { return info.ModTime() } return time.Unix(stat.Ctim.Sec, stat.Ctim.Nsec).UTC() }