About File systems magic numbers
Manish Katiyar
mkatiyar at gmail.com
Wed Jan 17 12:04:54 EST 2018
On Wed, Jan 17, 2018 at 8: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
>
>
You need to understand the reason for having the magic number first. Why is
it needed and then most of the below questions can be answered.
> 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 is no rule for it and it totally depends on the will of the
filesystem developer. If he wants, he can put a magic number in every
file/block etc. even though it might be stupid to do so. Magic numbers are
just a way to identify something you already know. They are used during
filesystem recovery, to verify that things are ok before mounting etc. etc.
If you can't find your known pattern at the place you wrote or where you
expect then something is wrong.
> 2. I assume, magic number will be assigned to files by the tools which we
> use to create the files(like vi, cat, etc). Is this correct?
>
Do not assume :-). Look at the code. Tools don't decide what or where to
put the magic number. It is the FS code which decides irrespective of tool.
> 3. It seems, windows files also have the magic numbers. let's say I copy
> some files from windows to Linux. We should have the common magic numbers
> between different Operating systems, so there won't be confusions. I mean,
> is there any standards common for all os's files magic numbers?!?
>
>
Nope. Magic numbers are a personal (somewhat) choice. They aren't preserved
across filesystems. It would actually be wrong if you can read the magic
number of the FS while doing 'cat' on a file.
Thanks -
Manish
>
> Best regards
> Sekar
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20180117/85e3f202/attachment.html>
More information about the Kernelnewbies
mailing list