]> git.ipfire.org Git - thirdparty/linux.git/commit
fs: make plain ->i_state access fail to compile
authorMateusz Guzik <mjguzik@gmail.com>
Thu, 9 Oct 2025 07:59:28 +0000 (09:59 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 20 Oct 2025 18:22:28 +0000 (20:22 +0200)
commit2ed81b4bef9b74ae0f095ad4667dbe2ae0b86a91
tree25b85b1460f196b0d6c1f2ccffb860edf4863a65
parent18c61399f6b9bae796e0a4a88e96967639fa8218
fs: make plain ->i_state access fail to compile

... to make sure all accesses are properly validated.

Merely renaming the var to __i_state still lets the compiler make the
following suggestion:
error: 'struct inode' has no member named 'i_state'; did you mean '__i_state'?

Unfortunately some people will add the __'s and call it a day.

In order to make it harder to mess up in this way, hide it behind a
struct. The resulting error message should be convincing in terms of
checking what to do:
error: invalid operands to binary & (have 'struct inode_state_flags' and 'int')

Of course people determined to do a plain access can still do it, but
nothing can be done for that case.

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
include/linux/fs.h