I stumbled into clang 12 halting on ‘major’ call, which is not defined anywhere (as “error: implicit declaration of function ‘major’ is invalid in C99”).
Now I see on haiku that definition is missing, as well as ‘minor’ and ‘makedev’ (freebsd has those).
As into ‘sys/types.h’ I see dev_t is defined as
typedef __haiku_int32 dev_t;
I wonder, is there no concept of class (major) and instance (minor) of a device ID in haiku?
There are no major/minor concept in Haiku. dev_t is just an identifier that is allocated by kernel and it has no extra structure. dev_t values are not preserved on reboot.
Unlike usual UNIX-like systems, Haiku can’t create character devices using mknod function, character devices can be only created from kernel mode code and exposed in dedicated file system “devfs” (usually mounted at /dev). It is impossible to create block/character devices outside of devfs.
This is basically how I understood it as well, just that to me it sounded like what it is, not what it should be (e.g. a more stable variant being possible if anyone would write a high quality patch).
What this meant to me was that the classical way of matching st_dev and st_rdev did not work as expected.
So at this point I would warn about using those values at all in userland. So depending on what @topolinik tries to do, it might not be as easy as having some dummy macros or checking the value in another way (e.g. memcmp(3)).
As discussed on IRC, with a quick check, it doesn’t seem matching works as expected on my side. Happy to have another look another time (just ping me on IRC).