Going through the man page of stasfs( http://man7.org/linux/man-pages/man2/statfs.2.html) I see in the Filesystem types SUPER_MAGIC, FS_MAGIC and TEST_MAGIC.
Filesystem types:
ADFS_SUPER_MAGIC 0xadf5
.
.
.
BTRFS_SUPER_MAGIC 0x9123683e
BTRFS_TEST_MAGIC 0x73727279
BPF_FS_MAGIC 0xcafe4a11
I know that the magic numbers are used to identify the format of file system.
But then what is the difference between SUPER_MAGIC, FS_MAGIC and TEST_MAGIC?
To answer your question, there is a difference in naming and in values of these macros. There is no difference in the purpose of these macros, as they all are used in identifying a format of a filesystem.
Constants *_MAGIC are defined in linux/magic.h file from linux kernel.
So BPF_FS_MAGIC is used to identify BPS filesystem, BTRFS_TEST_MAGIC is used to identify some testing btrfs filesystem, while BTRFS_MAGIC_NUMBER is used to identify (production-ready) btrfs filesystem and so on. The naming of these macros may be not consistent, but they all share the same purpose.
The naming of a constant may be a hint to programmers and/or may be confusing to programmers, since we all think differently. I would expect constants named *_MAGIC to have the value of some magic number constant, macros named *_TEST_MAGIC to identify some testing filesystem of some format, while constants named *_FS_MAGIC and/or *_MAGIC_NUMBER mean exactly the same for me. So someone (probably the author of BPS kernel driver) named the BPS magic number macro as BPS_FS_MAGIC and that was his choice, others named they magic number constants differently.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With