On Thu, Nov 30, 2023 at 03:46:55PM +0000, Benno Lossin wrote: > >>> + pub const O_APPEND: u32 = bindings::O_APPEND; > >> > >> Why do all of these constants begin with `O_`? > > > > Because that is how they are defined in the kernel in the C code. Why > > would they not be the same here? > > Then why does the C side name them that way? Is it because `O_*` is > supposed to mean something, or is it done due to namespacing? It's because these sets of constants were flags passed to the open(2) system call, and so they are dictated by the POSIX specification. So O_ means that they are a set of integer values which are used by open(2), and they are defined when userspace #include's the fcntl.h header file. One could consider it be namespacing --- we need to distinguish these from other constants: MAY_APPEND, RWF_APPEND, ESCAPE_APPEND, STATX_ATTR_APPEND, BTRFS_INODE_APPEND. But it's also a convention that dates back for ***decades*** and if we want code to be understandable by kernel programmers, we need to obey standard kernel naming conventions. > In Rust we have namespacing, so we generally drop common prefixes. I don't know about Rust namespacing, but in other languages, how you have to especify namespaces tend to be ***far*** more verbose than just adding an O_ prefix. Cheers, - Ted