On Tue Nov 3, 2026 at 4:14 PM CET, Amir Goldstein wrote: > On Tue, Nov 3, 2026 at 12:13 PM koraynilay wrote: >> >> On Mon Nov 2, 2026 at 3:00 PM CET, Amir Goldstein wrote: >> > On Sun, Nov 1, 2026 at 2:57 AM koraynilay wrote: >> >> >> >> Add provenance time (ptime), indicating the time when a file or >> >> directory was created. This is user-settable via file_setattr() and >> >> retrievable via statx(2) (using STATX_PTIME) or file_getattr(). >> >> >> >> The semantics of when to preserve this new timestamp are the same as >> >> mtime, the idea being that there is a correspondence like this: >> >> >> >> ctime <-> btime >> >> mtime <-> ptime >> >> >> >> so every operation (copying, moving, ...) that currently preserves mtime >> >> should also preserve ptime. >> >> >> >> Furthermore, in order to avoid the legacy FS_IOC_FSSETXATTR accepting >> >> FS_XFLAG_PTIME, add an FS_FILE_ATTR_XFLAGS_MASK mask to support new >> >> xflags, and use it in fileattr_to_file_attr()/file_attr_to_fileattr() to >> >> allow ptime to be used with the file_setattr()/file_getattr() syscalls. >> >> >> >> [ This is a re-implementation of the initial patch[1] by Sean Smith >> >> , following the advice[2] from Darrick J. >> >> Wong of using file_setattr() instead of updating >> >> utimensat() ] >> >> >> >> [1]: https://lore.kernel.org/20260405195007.1306-2-DefendTheDisabled@gmail.com >> >> [2]: https://lore.kernel.org/20260407014129.GC6192@frogsfrogsfrogs >> >> >> >> Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.4.7 >> >> Signed-off-by: koraynilay >> >> --- >> >> fs/file_attr.c | 33 +++++++++++++++++++++++++++++++-- >> >> fs/stat.c | 2 ++ >> >> include/linux/fileattr.h | 5 +++++ >> >> include/linux/stat.h | 1 + >> >> include/uapi/linux/fs.h | 8 +++++++- >> >> include/uapi/linux/stat.h | 7 ++++++- >> >> 6 files changed, 52 insertions(+), 4 deletions(-) >> >> >> >> diff --git a/fs/file_attr.c b/fs/file_attr.c >> >> index 833e03810b24..c0645cb22bf3 100644 >> >> --- a/fs/file_attr.c >> >> +++ b/fs/file_attr.c >> >> @@ -102,7 +102,7 @@ EXPORT_SYMBOL(vfs_fileattr_get); >> >> static void fileattr_to_file_attr(const struct file_kattr *fa, >> >> struct file_attr *fattr) >> >> { >> >> - __u32 mask = FS_XFLAGS_MASK; >> >> + __u32 mask = FS_FILE_ATTR_XFLAGS_MASK; >> >> >> >> memset(fattr, 0, sizeof(struct file_attr)); >> >> fattr->fa_xflags = fa->fsx_xflags & mask; >> >> @@ -110,6 +110,8 @@ static void fileattr_to_file_attr(const struct file_kattr *fa, >> >> fattr->fa_nextents = fa->fsx_nextents; >> >> fattr->fa_projid = fa->fsx_projid; >> >> fattr->fa_cowextsize = fa->fsx_cowextsize; >> >> + fattr->fa_ptime_sec = fa->fsx_ptime.tv_sec; >> >> + fattr->fa_ptime_nsec = fa->fsx_ptime.tv_nsec; >> >> } >> >> >> >> /** >> >> @@ -141,15 +143,20 @@ EXPORT_SYMBOL(copy_fsxattr_to_user); >> >> static int file_attr_to_fileattr(const struct file_attr *fattr, >> >> struct file_kattr *fa) >> >> { >> >> - __u64 mask = FS_XFLAGS_MASK; >> >> + __u64 mask = FS_FILE_ATTR_XFLAGS_MASK; >> > >> > That is not the correct way to extend this API. >> > This fixed mask was added as a placeholder for >> > "We intend to add support for more xflags to selective filesystems": >> > https://lore.kernel.org/linux-fsdevel/20250329143312.1350603-2-amir73il@gmail.com/ >> > >> > Please see this POC patch for filesystems to publish their supported >> > xflags mask: >> > https://lore.kernel.org/linux-fsdevel/20250329143312.1350603-3-amir73il@gmail.com/ >> >> Thanks, I did not think of adding a dynamic mask like that, I will look >> into it and implement it for v4. >> >> > This will allow callers of file_getattr() to know if the filesystem >> > supports ptime >> > without trying to set it and failing. >> >> So after adding fsx_xflags_mask to file_kattr, every filesystem would >> populate fsx_xflags_mask with all the returned (== supported) FS_XFLAG_* >> in their own specific .fileattr_get, correct? > > Not all filesystems. Just the ones that wish to extend the constant > legacy FS_XFLAGS_MASK. > So just the ones that you change to support XFLAGS_PTIME Ah ok yeah that makes more sense, so like the fileattr_has_fsx_mask() (that checks if fa has fsx, ignoring the suppored/allowed ones specified as second arg) that I added, but in the opposite way: "I advertise only the extra fsx (so only 0 or FS_XFLAG_PTIME rn) that I support". Thanks, koraynilay > Thanks, > Amir.