About File systems magic numbers

Jim Davis jim.epost at gmail.com
Wed Jan 17 12:56:59 EST 2018


n Wed, Jan 17, 2018 at 9:05 AM, inventsekar <inventsekar at gmail.com> wrote:
> Hi All, i have been reading
> Unix filesystem - evolution, design and implementation by Steve D. Pate
>
> and it provides a simple file system source code for learning and playing
> with.
> On the header file, it defines the fs magic number as
> #define UX_MAGIC 0x58494e55
>
> 1. which means, will it assign this magic number to ALL files created on
> this sample fs? That can't be so. Otherwise, why we need to define a magic
> number?

There can be many different types of filesystems on a Linux computer;
the magic number can be used to distinguish which type a particular
filesystem is. If you look at usr/include/linux/magic.h you'll see,
for example,

#define EXT2_SUPER_MAGIC    0xEF53

and as an example of using that particular magic number, check out
arch/blackfin/kernel/setup.c or fs/ext2/super.c.

-- 
Jim



More information about the Kernelnewbies mailing list