The source for this is interesting to read to say the least.
*FIXED SEE EDIT: I tried to compile it but was missing a link reference to the major function.
I will keep poking around but it is definitely a fun source read.
[edit] If you are wanting to compile this on WSL you will need to add an include for <sys/sysmacros.h> to pickup the reference to major.