Re: [PATCH v3] fs: Replace user_access_{begin/end} by scoped user access
From: Linus Torvalds
Date: Wed Mar 18 2026 - 12:22:15 EST
On Wed, 18 Mar 2026 at 08:49, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> #define dirent_size(dirent, len) offsetof(typeof(dirent), d_name[len])
That 'typeof(dirent)' needs to be 'typeof(*(dirent))' to be convenient.
It was correct in the patch I attached, but I'll just point it out anyway.
And we actually have a helper macro for that: struct_offset(). Which
wasn't what I used in that attached patch, but *should* have been.
IOW, the macro should look something like
#define dirent_size(dirent, len) struct_offset(dirent, d_name[len])
instead. That looks fairly clean, no?
Linus