LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Magic Number in linux (https://www.linuxquestions.org/questions/linux-general-1/magic-number-in-linux-4175456959/)

svhost2 04-05-2013 08:00 AM

Magic Number in linux
 
Hi,
I want to know why a special files have the magic number in end of it?(most files have their magic number on top of the file)
Thanks

colucix 04-05-2013 12:39 PM

Maybe because the first bytes of those files are reserved for other uses. On the other hand, the magic number specification provides the ability to specify an offset and the offset can be retrieved from the file, as clearly stated in man magic:
Quote:

Offsets do not need to be constant, but can also be read from the file being examined. If the first character following the last > is a ( then the string after the parenthesis is interpreted as an indirect offset.
Just take in mind that magic numbers in many cases are not there to be... magic numbers. They are unique sequences of bytes that help programs in *nix systems (along with the file command) to identify the file type, but they could have been inserted originally for other purposes.

pan64 04-05-2013 12:52 PM

yes, the first answer is correct, probably you can show us an interesting example.....


All times are GMT -5. The time now is 06:47 AM.