I am currently working on a custom kernel for a project, and one of the things I need is to create a new custom file flag(s), similar to this question: Passing custom flags to "open" in a device driver
I have been able to create them, and compile the kernel with no problems, however, I don't really get how these flags work in practice. Most of them seem to collide with each other, for example:
[DEC] [BIN]
O_CREAT: 00000100 | 01100100
O_EXCL: 00000200 | 11001000
-x------
As pointed out in that question, for testing whether the flags are unique it uses the Hamming weight of all the flags. However, I don't fully understand how to set and unset individual flags and how to test them properly, and why not use something much more trivial as bit flags, that can easily be distinguished with simple, cheap, bitwise operations.