Monday, November 23, 2009  
Google
Web pcquest.com

CIOL Network sites

Search by Issue | Sitemap | Advanced Search

• For most updated version of DQ TOP 20 issue, visit dqindia.com • Ad : Play and Plug ERP by IBM


 
    Enterprise Solutions
    Hands On
    ITstrategy

    Developer

    Tech Forum

    SMB Forum

    Trends

    Shootout

    Reviews
    Editorials
    Linux and Open Source
    Technology
    Extraedge

    IT Careers

    Vertical Focus

Subscribe to Print magazine.


now!


Newsletter

 

Home > > Linux Hands On > File Associations in Linux


File Associations in Linux




Continued from Page 1

Registering a binary format

The kernel has two ways of identifying a file as being of a particular binary format:

Magic numbers

A sequence of bytes that occur near the beginning of a binary file, and is unique for every binary format. To identify a binary using this method, you must know the offset from the beginning of the file from where the magic number begins, and what exactly the magic number is. A good place to find out is "/usr/share/magic" and the "magic" man page.

File name extensions

A simpler alternative is to identify a file format by its filename extension. While this saves you from the hassle of finding out magic numbers, using magic numbers for identification has the advantage that a file will be recognized even if it doesn’t have the proper extension.

Every binary format that you want to use must be registered with the kernel, that is, the kernel must be told how to identify the file format, and what interpreter to use for it. This is done using the "/proc/sys/fs/binfmt_misc/register" file.

To register a file format, echo a string of the form:

:name:type:offset:magic:mask:
interpreter: to /proc/sys/fs/binfmt_ misc/register.

The fields are:

name The name by which this format will be identified.

type The method to use for recognizing the file format. This is "M" for magic number, or "E" for extension.

offset Offset in bytes from the beginning of the file to the position where the magic pattern begins.

magic The magic number, if you’re using magic numbers for recognition, or the file extension otherwise.

mask Mask with which the magic number is bitwise ended. This defaults to all 1s.

interpreter The full path name of the program which should be invoked with the name of the binary as the first argument.


Page(s)   1   2   3   

End of the article

PC Problems? Get a solution in 24 hours. Ask Tech Expert

Related CIOL links   External links  

--None--

 

none



Read Previous Linux Hands On...

   




Untitled Document



ZTE:Leading CDMA Technology






Previous Stories

MagicPoint

Backup in Linux

A Transparent Proxy With Squid

Message boards

Discuss this and many other IT topics at the
CIOL message board



   
 

 
 

Magazine Subscription | RQS | Contact Us | Team PCQuest | Advertising - Print | jobs@cybermedia