Re: [PATCH v6 6/6] fs: introduce file_getattr and file_setattr syscalls

From
Amir Goldstein <amir73il@gmail.com>
Date
2025-07-02 09:14:01
Also in
linux-fsdevel, linux-xfs, lkml, selinux
Reply to
Christian Brauner, 2025-07-01
quoted
+/*
+ * Variable size structure for file_[sg]et_attr().
+ *
+ * Note. This is alternative to the structure 'struct fileattr'/'struct fsxattr'.
+ * As this structure is passed to/from userspace with its size, this can
+ * be versioned based on the size.
+ */
+struct fsx_fileattr {
+     __u32   fsx_xflags;     /* xflags field value (get/set) */
+     __u32   fsx_extsize;    /* extsize field value (get/set)*/
+     __u32   fsx_nextents;   /* nextents field value (get)   */
+     __u32   fsx_projid;     /* project identifier (get/set) */
+     __u32   fsx_cowextsize; /* CoW extsize field value (get/set) */
This misses a:

__u32 __spare;

so there's no holes in the struct. :)
Adding __spare and not verifying that it is zeroed gets us to the
point that we are not able to replace __spare with a real field later.

I suggest to resolve this hole as Darrick and Pali suggested by making it
__u64 fsx_xflags

w.r.t Darrick's comment, I kind of like it that the name for the UAPI
struct (fsxattr)
differs from the name of the kernel internal representation (fileattr), but
I agree that fsx_fileattr does not give a good hint on what it is.

I think that renaming struct fsx_fileattr to struct fsxattr64 along
with changing the
width of fsx_xflags will help reduce the confusion of users.

What do you guys think?

Thanks,
Amir.
Thread (52 messages) 52 messages, 8 authors, last reply 2025-10-07
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help