---
name: "xfm_magic"
section: "5"
platform: "linux"
package: "xfm"
version: "1.5.4-3"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/xfm_magic"
---

# xfm\_magic(5)

xfm's magic file format

## NAME

xfm\_magic - xfm's magic file format

## DESCRIPTION

[**xfm**(1)](/xfm/1.md) and [**xfmtype**(1)](/xfmtype/1.md) read files in this format to determine the mime type of a file, which again is used to determine what command to open it with.

The format of the configuration file is the same as the [**magic**(5)](/magic/5.md) with the following additions and differences:

- **include:** directive

  If a line starts with **include:** the rest of the line is treated as filename of another magic file to be read and processed before processing this file continues.

  Included files can be include files again. Thus a user specific file can\
   **include: /etc/X11/xfm/xfm\_magic**\
   to get the system wide xfm defaults and this file again\
   **include: /usr/share/file/magic.mime**\
   to get the system wide system defaults.

- **mode** type field.

  Similar to **long** type, but *offset* is ignored.  The test is performed against the **st\_mode** field of the *stat* structure obtained using [**stat**(2)](/stat/2.md) system call. This allows testing for  directories, fifos ... as well as for file permissions.

- **lmode** type field.

  Similar to **mode** type, but using [*lstat*(2)](/lstat/2.md) instead of [**stat**(2)](/stat/2.md). This allows testing for symbolic links.

- **regexp** type field.

  The *value* field must be a proper regular expression. The bytes starting at *offset* are matched against it. If the match succeeds, then a **regsub**(3) is performed on *message* yielding the final message. If the type field is of the form **regexp&nnn** where **nnn** is a positive number, then that number controls the amount of data scanned for the matching, otherwise a compile defined value (currently 256) is used.

- **long** and **short** byte order.

  *xfmtype* always reads **long**s and **short**s using MSB-first order. This makes configuration files portable to all architectures, but some entries in original [**magic**(5)](/magic/5.md) files might be wrong.

- Continuation lines.

  If a line ends with a *backslash* character (*\\*), it is continued with the following line. The maximum length of a line is 1024 characters (counting also characters in continuation lines).

## FILES

- *$HOME***/.xfm/xfm\_magic**

  Default location [**xfm**(1)](/xfm/1.md) looks for a file of this format. (Note that [**xfmtype**(1)](/xfmtype/1.md) only reads files specified with **-m** on the command line.)

- **/etc/X11/xfm/xfm\_magic**

  System wide default file if there is no user specific one.

## SEE ALSO

[**xfm**(1)](/xfm/1.md), [**xfmtype**(1)](/xfmtype/1.md), [**file**(1)](/file/1.md), [**magic**(5)](/magic/5.md), [**stat**(2)](/stat/2.md), [**lstat**(2)](/lstat/2.md).

## COPYRIGHT

Copyright (c) 1995 CNM-US\
 Copyright (c) 1995 Juan D. Martin

## AUTHOR

Juan D. Martin (juando@cnm.us.es)\
 (but modified heavily by Bernhard R. Link)
