xref: /netbsd-src/external/bsd/file/dist/doc/libmagic.3 (revision ddb176824c39fb0db5ceef3e9e40dcaa273aec38)
1*ddb17682Schristos.\"	$NetBSD: libmagic.3,v 1.21 2023/08/18 19:00:10 christos Exp $
21b108b8bSchristos.\"
3*ddb17682Schristos.\" $File: libmagic.man,v 1.49 2023/07/20 14:32:07 christos Exp $
41b108b8bSchristos.\"
51d4cb158Schristos.\" Copyright (c) Christos Zoulas 2003, 2018, 2022
61b108b8bSchristos.\" All Rights Reserved.
71b108b8bSchristos.\"
81b108b8bSchristos.\" Redistribution and use in source and binary forms, with or without
91b108b8bSchristos.\" modification, are permitted provided that the following conditions
101b108b8bSchristos.\" are met:
111b108b8bSchristos.\" 1. Redistributions of source code must retain the above copyright
121b108b8bSchristos.\"    notice immediately at the beginning of the file, without modification,
131b108b8bSchristos.\"    this list of conditions, and the following disclaimer.
141b108b8bSchristos.\" 2. Redistributions in binary form must reproduce the above copyright
151b108b8bSchristos.\"    notice, this list of conditions and the following disclaimer in the
161b108b8bSchristos.\"    documentation and/or other materials provided with the distribution.
171b108b8bSchristos.\"
181b108b8bSchristos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
191b108b8bSchristos.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
201b108b8bSchristos.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
211b108b8bSchristos.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
221b108b8bSchristos.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
231b108b8bSchristos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
241b108b8bSchristos.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
251b108b8bSchristos.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
261b108b8bSchristos.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
271b108b8bSchristos.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
281b108b8bSchristos.\" SUCH DAMAGE.
291b108b8bSchristos.\"
30*ddb17682Schristos.Dd June 16, 2023
31bd3e59b9Swiz.Dt LIBMAGIC 3
321b108b8bSchristos.Os
331b108b8bSchristos.Sh NAME
341b108b8bSchristos.Nm magic_open ,
351b108b8bSchristos.Nm magic_close ,
361b108b8bSchristos.Nm magic_error ,
37819e6405Schristos.Nm magic_errno ,
382344ff98Schristos.Nm magic_descriptor ,
39af4088ebSabhinav.Nm magic_file ,
401b108b8bSchristos.Nm magic_buffer ,
41051bdd9aSchristos.Nm magic_getflags ,
421b108b8bSchristos.Nm magic_setflags ,
431b108b8bSchristos.Nm magic_check ,
441b108b8bSchristos.Nm magic_compile ,
45c2e19894Schristos.Nm magic_list ,
46c2e19894Schristos.Nm magic_load ,
47fa9ee498Schristos.Nm magic_load_buffers ,
48fa9ee498Schristos.Nm magic_setparam ,
49fa9ee498Schristos.Nm magic_getparam ,
50c2e19894Schristos.Nm magic_version
5161e7e15eSwiz.Nd Magic number recognition library
521b108b8bSchristos.Sh LIBRARY
531b108b8bSchristos.Lb libmagic
541b108b8bSchristos.Sh SYNOPSIS
551b108b8bSchristos.In magic.h
561b108b8bSchristos.Ft magic_t
571b108b8bSchristos.Fn magic_open "int flags"
581b108b8bSchristos.Ft void
591b108b8bSchristos.Fn magic_close "magic_t cookie"
601b108b8bSchristos.Ft const char *
611b108b8bSchristos.Fn magic_error "magic_t cookie"
621b108b8bSchristos.Ft int
631b108b8bSchristos.Fn magic_errno "magic_t cookie"
641b108b8bSchristos.Ft const char *
65829ab771Snjoly.Fn magic_descriptor "magic_t cookie" "int fd"
662344ff98Schristos.Ft const char *
67829ab771Snjoly.Fn magic_file "magic_t cookie" "const char *filename"
681b108b8bSchristos.Ft const char *
6961e7e15eSwiz.Fn magic_buffer "magic_t cookie" "const void *buffer" "size_t length"
701b108b8bSchristos.Ft int
71051bdd9aSchristos.Fn magic_getflags "magic_t cookie"
72051bdd9aSchristos.Ft int
7361e7e15eSwiz.Fn magic_setflags "magic_t cookie" "int flags"
741b108b8bSchristos.Ft int
7561e7e15eSwiz.Fn magic_check "magic_t cookie" "const char *filename"
761b108b8bSchristos.Ft int
7761e7e15eSwiz.Fn magic_compile "magic_t cookie" "const char *filename"
781b108b8bSchristos.Ft int
79046a38ddSchristos.Fn magic_list "magic_t cookie" "const char *filename"
80046a38ddSchristos.Ft int
8161e7e15eSwiz.Fn magic_load "magic_t cookie" "const char *filename"
82c2e19894Schristos.Ft int
8358b7f199Schristos.Fn magic_load_buffers "magic_t cookie" "void **buffers" "size_t *sizes" "size_t nbuffers"
8458b7f199Schristos.Ft int
85fa9ee498Schristos.Fn magic_getparam "magic_t cookie" "int param" "void *value"
86fa9ee498Schristos.Ft int
87fa9ee498Schristos.Fn magic_setparam "magic_t cookie" "int param" "const void *value"
88fa9ee498Schristos.Ft int
89c2e19894Schristos.Fn magic_version "void"
90*ddb17682Schristos.Ft const char *
91*ddb17682Schristos.Fn magic_getpath "const char *magicfile" "int action"
921b108b8bSchristos.Sh DESCRIPTION
931b108b8bSchristosThese functions
941b108b8bSchristosoperate on the magic database file
951b108b8bSchristoswhich is described
961b108b8bSchristosin
971b108b8bSchristos.Xr magic 5 .
981b108b8bSchristos.Pp
991b108b8bSchristosThe function
1001b108b8bSchristos.Fn magic_open
10161e7e15eSwizcreates a magic cookie pointer and returns it.
10261e7e15eSwizIt returns
10361e7e15eSwiz.Dv NULL
10461e7e15eSwizif there was an error allocating the magic cookie.
10561e7e15eSwizThe
1061b108b8bSchristos.Ar flags
1071b108b8bSchristosargument specifies how the other magic functions should behave:
1081b108b8bSchristos.Bl -tag -width MAGIC_COMPRESS
1091b108b8bSchristos.It Dv MAGIC_NONE
1101b108b8bSchristosNo special handling.
1111b108b8bSchristos.It Dv MAGIC_DEBUG
1121b108b8bSchristosPrint debugging messages to stderr.
1131b108b8bSchristos.It Dv MAGIC_SYMLINK
1141b108b8bSchristosIf the file queried is a symlink, follow it.
1151b108b8bSchristos.It Dv MAGIC_COMPRESS
1161b108b8bSchristosIf the file is compressed, unpack it and look at the contents.
1171b108b8bSchristos.It Dv MAGIC_DEVICES
1181b108b8bSchristosIf the file is a block or character special device, then open the device
1191b108b8bSchristosand try to look in its contents.
1201b108b8bSchristos.It Dv MAGIC_MIME_TYPE
1211b108b8bSchristosReturn a MIME type string, instead of a textual description.
1221b108b8bSchristos.It Dv MAGIC_MIME_ENCODING
1231b108b8bSchristosReturn a MIME encoding, instead of a textual description.
1242344ff98Schristos.It Dv MAGIC_MIME
1252344ff98SchristosA shorthand for MAGIC_MIME_TYPE | MAGIC_MIME_ENCODING.
1261b108b8bSchristos.It Dv MAGIC_CONTINUE
1271b108b8bSchristosReturn all matches, not just the first.
1281b108b8bSchristos.It Dv MAGIC_CHECK
1291b108b8bSchristosCheck the magic database for consistency and print warnings to stderr.
1301b108b8bSchristos.It Dv MAGIC_PRESERVE_ATIME
1311b108b8bSchristosOn systems that support
13261e7e15eSwiz.Xr utime 3
1331b108b8bSchristosor
1341b108b8bSchristos.Xr utimes 2 ,
1352344ff98Schristosattempt to preserve the access time of files analysed.
1361b108b8bSchristos.It Dv MAGIC_RAW
1371b108b8bSchristosDon't translate unprintable characters to a \eooo octal representation.
1381b108b8bSchristos.It Dv MAGIC_ERROR
1391b108b8bSchristosTreat operating system errors while trying to open files and follow symlinks
1401b108b8bSchristosas real errors, instead of printing them in the magic buffer.
1412344ff98Schristos.It Dv MAGIC_APPLE
1422344ff98SchristosReturn the Apple creator and type.
14374db5203Schristos.It Dv MAGIC_EXTENSION
14474db5203SchristosReturn a slash-separated list of extensions for this file type.
14574db5203Schristos.It Dv MAGIC_COMPRESS_TRANSP
14674db5203SchristosDon't report on compression, only report about the uncompressed data.
1471b108b8bSchristos.It Dv MAGIC_NO_CHECK_APPTYPE
1482344ff98SchristosDon't check for
1491b108b8bSchristos.Dv EMX
1501b108b8bSchristosapplication type (only on EMX).
1511d4cb158Schristos.It Dv MAGIC_NO_COMPRESS_FORK
1521d4cb158SchristosDon't allow decompressors that use fork.
1532344ff98Schristos.It Dv MAGIC_NO_CHECK_CDF
1542344ff98SchristosDon't get extra information on MS Composite Document Files.
1551b108b8bSchristos.It Dv MAGIC_NO_CHECK_COMPRESS
1562344ff98SchristosDon't look inside compressed files.
1571b108b8bSchristos.It Dv MAGIC_NO_CHECK_ELF
1582344ff98SchristosDon't print ELF details.
1597b69fe6aSchristos.It Dv MAGIC_NO_CHECK_ENCODING
1602344ff98SchristosDon't check text encodings.
1611b108b8bSchristos.It Dv MAGIC_NO_CHECK_SOFT
1621b108b8bSchristosDon't consult magic files.
1631b108b8bSchristos.It Dv MAGIC_NO_CHECK_TAR
1641b108b8bSchristosDon't examine tar files.
1652344ff98Schristos.It Dv MAGIC_NO_CHECK_TEXT
1662344ff98SchristosDon't check for various types of text files.
1671b108b8bSchristos.It Dv MAGIC_NO_CHECK_TOKENS
1681b108b8bSchristosDon't look for known tokens inside ascii files.
169c02f7f97Schristos.It Dv MAGIC_NO_CHECK_JSON
17078a23c3aSchristosDon't examine JSON files.
17178a23c3aSchristos.It Dv MAGIC_NO_CHECK_CSV
17278a23c3aSchristosDon't examine CSV files.
173*ddb17682Schristos.It Dv MAGIC_NO_CHECK_SIMH
174*ddb17682SchristosDon't examine SIMH tape files.
1751b108b8bSchristos.El
1761b108b8bSchristos.Pp
1771b108b8bSchristosThe
1781b108b8bSchristos.Fn magic_close
1791b108b8bSchristosfunction closes the
1801b108b8bSchristos.Xr magic 5
1811b108b8bSchristosdatabase and deallocates any resources used.
1821b108b8bSchristos.Pp
1831b108b8bSchristosThe
1841b108b8bSchristos.Fn magic_error
18561e7e15eSwizfunction returns a textual explanation of the last error, or
18661e7e15eSwiz.Dv NULL
18761e7e15eSwizif there was no error.
1881b108b8bSchristos.Pp
1891b108b8bSchristosThe
1901b108b8bSchristos.Fn magic_errno
1911b108b8bSchristosfunction returns the last operating system error number
1921b108b8bSchristos.Pq Xr errno 2
1931b108b8bSchristosthat was encountered by a system call.
1941b108b8bSchristos.Pp
1951b108b8bSchristosThe
1961b108b8bSchristos.Fn magic_file
1971b108b8bSchristosfunction returns a textual description of the contents of the
1981b108b8bSchristos.Ar filename
19961e7e15eSwizargument, or
20061e7e15eSwiz.Dv NULL
20161e7e15eSwizif an error occurred.
2021b108b8bSchristosIf the
2031b108b8bSchristos.Ar filename
20461e7e15eSwizis
20561e7e15eSwiz.Dv NULL ,
20661e7e15eSwizthen stdin is used.
2071b108b8bSchristos.Pp
2081b108b8bSchristosThe
2092344ff98Schristos.Fn magic_descriptor
2102344ff98Schristosfunction returns a textual description of the contents of the
2112344ff98Schristos.Ar fd
21279bb278aSchristosargument, or
21379bb278aSchristos.Dv NULL
21479bb278aSchristosif an error occurred.
2152344ff98Schristos.Pp
2162344ff98SchristosThe
2171b108b8bSchristos.Fn magic_buffer
2181b108b8bSchristosfunction returns a textual description of the contents of the
2191b108b8bSchristos.Ar buffer
2201b108b8bSchristosargument with
2211b108b8bSchristos.Ar length
2221b108b8bSchristosbytes size.
2231b108b8bSchristos.Pp
2241b108b8bSchristosThe
225051bdd9aSchristos.Fn magic_getflags
226051bdd9aSchristosfunctions returns a value representing current
227051bdd9aSchristos.Ar flags
228051bdd9aSchristosset.
229051bdd9aSchristos.Pp
230051bdd9aSchristosThe
2311b108b8bSchristos.Fn magic_setflags
2321b108b8bSchristosfunction sets the
2331b108b8bSchristos.Ar flags
23461e7e15eSwizdescribed above.
23561e7e15eSwizNote that using both MIME flags together can also
2361b108b8bSchristosreturn extra information on the charset.
2371b108b8bSchristos.Pp
2381b108b8bSchristosThe
2391b108b8bSchristos.Fn magic_check
2401b108b8bSchristosfunction can be used to check the validity of entries in the colon
2411b108b8bSchristosseparated database files passed in as
2421b108b8bSchristos.Ar filename ,
24361e7e15eSwizor
24461e7e15eSwiz.Dv NULL
24561e7e15eSwizfor the default database.
24661e7e15eSwizIt returns 0 on success and \-1 on failure.
2471b108b8bSchristos.Pp
2481b108b8bSchristosThe
2491b108b8bSchristos.Fn magic_compile
25074db5203Schristosfunction can be used to compile the colon
2511b108b8bSchristosseparated list of database files passed in as
2521b108b8bSchristos.Ar filename ,
25361e7e15eSwizor
25461e7e15eSwiz.Dv NULL
25561e7e15eSwizfor the default database.
25661e7e15eSwizIt returns 0 on success and \-1 on failure.
25761e7e15eSwizThe compiled files created are named from the
2581b108b8bSchristos.Xr basename 1
2591b108b8bSchristosof each file argument with
2601b108b8bSchristos.Dq .mgc
2611b108b8bSchristosappended to it.
2621b108b8bSchristos.Pp
2631b108b8bSchristosThe
264046a38ddSchristos.Fn magic_list
265046a38ddSchristosfunction dumps all magic entries in a human readable format,
266046a38ddSchristosdumping first the entries that are matched against binary files and then the
267046a38ddSchristosones that match text files.
268046a38ddSchristosIt takes and optional
269046a38ddSchristos.Fa filename
270046a38ddSchristosargument which is a colon separated list of database files, or
271046a38ddSchristos.Dv NULL
272046a38ddSchristosfor the default database.
273046a38ddSchristos.Pp
274046a38ddSchristosThe
2751b108b8bSchristos.Fn magic_load
27674db5203Schristosfunction must be used to load the colon
2771b108b8bSchristosseparated list of database files passed in as
2781b108b8bSchristos.Ar filename ,
27961e7e15eSwizor
28061e7e15eSwiz.Dv NULL
28161e7e15eSwizfor the default database file before any magic queries can performed.
2821b108b8bSchristos.Pp
28361e7e15eSwizThe default database file is named by the MAGIC environment variable.
28461e7e15eSwizIf that variable is not set, the default database file name is
28561e7e15eSwiz.Pa /usr/share/misc/magic .
2861b108b8bSchristos.Fn magic_load
2871b108b8bSchristosadds
2881b108b8bSchristos.Dq .mgc
2891b108b8bSchristosto the database filename as appropriate.
290c2e19894Schristos.Pp
291c2e19894SchristosThe
29258b7f199Schristos.Fn magic_load_buffers
29358b7f199Schristosfunction takes an array of size
29458b7f199Schristos.Fa nbuffers
29558b7f199Schristosof
29658b7f199Schristos.Fa buffers
29758b7f199Schristoswith a respective size for each in the array of
29858b7f199Schristos.Fa sizes
29958b7f199Schristosloaded with the contents of the magic databases from the filesystem.
30058b7f199SchristosThis function can be used in environment where the magic library does
30158b7f199Schristosnot have direct access to the filesystem, but can access the magic
30258b7f199Schristosdatabase via shared memory or other IPC means.
30358b7f199Schristos.Pp
30458b7f199SchristosThe
305fa9ee498Schristos.Fn magic_getparam
306fa9ee498Schristosand
307fa9ee498Schristos.Fn magic_setparam
30874db5203Schristosallow getting and setting various limits related to the magic
309fa9ee498Schristoslibrary.
310fa9ee498Schristos.Bl -column "MAGIC_PARAM_ELF_PHNUM_MAX" "size_t" "Default" -offset indent
311fa9ee498Schristos.It Sy "Parameter" Ta Sy "Type" Ta Sy "Default"
312fa9ee498Schristos.It Li MAGIC_PARAM_INDIR_MAX Ta size_t Ta 15
313fa9ee498Schristos.It Li MAGIC_PARAM_NAME_MAX Ta size_t Ta 30
314fa9ee498Schristos.It Li MAGIC_PARAM_ELF_NOTES_MAX Ta size_t Ta 256
315fa9ee498Schristos.It Li MAGIC_PARAM_ELF_PHNUM_MAX Ta size_t Ta 128
316fa9ee498Schristos.It Li MAGIC_PARAM_ELF_SHNUM_MAX Ta size_t Ta 32768
31774db5203Schristos.It Li MAGIC_PARAM_REGEX_MAX Ta size_t Ta 8192
31874db5203Schristos.It Li MAGIC_PARAM_BYTES_MAX Ta size_t Ta 1048576
319fa9ee498Schristos.El
320fa9ee498Schristos.Pp
321fa9ee498SchristosThe
322fa9ee498Schristos.Dv MAGIC_PARAM_INDIR_RECURSION
323fa9ee498Schristosparameter controls how many levels of recursion will be followed for
324fa9ee498Schristosindirect magic entries.
325fa9ee498Schristos.Pp
326fa9ee498SchristosThe
327fa9ee498Schristos.Dv MAGIC_PARAM_NAME_RECURSION
328fa9ee498Schristosparameter controls how many levels of recursion will be followed for
329fa9ee498Schristosfor name/use calls.
330fa9ee498Schristos.Pp
331fa9ee498SchristosThe
332fa9ee498Schristos.Dv MAGIC_PARAM_NAME_MAX
333fa9ee498Schristosparameter controls the maximum number of calls for name/use.
334fa9ee498Schristos.Pp
335fa9ee498SchristosThe
336fa9ee498Schristos.Dv MAGIC_PARAM_NOTES_MAX
337fa9ee498Schristosparameter controls how many ELF notes will be processed.
338fa9ee498Schristos.Pp
339fa9ee498SchristosThe
340fa9ee498Schristos.Dv MAGIC_PARAM_PHNUM_MAX
341fa9ee498Schristosparameter controls how many ELF program sections will be processed.
342fa9ee498Schristos.Pp
343fa9ee498SchristosThe
344fa9ee498Schristos.Dv MAGIC_PARAM_SHNUM_MAX
345fa9ee498Schristosparameter controls how many ELF sections will be processed.
346fa9ee498Schristos.Pp
347fa9ee498SchristosThe
348c2e19894Schristos.Fn magic_version
349c2e19894Schristoscommand returns the version number of this library which is compiled into
350c2e19894Schristosthe shared library using the constant
351c2e19894Schristos.Dv MAGIC_VERSION
352c2e19894Schristosfrom
353c2e19894Schristos.In magic.h .
354c2e19894SchristosThis can be used by client programs to verify that the version they compile
355c2e19894Schristosagainst is the same as the version that they run against.
356*ddb17682Schristos.Pp
357*ddb17682SchristosThe
358*ddb17682Schristos.Fn magic_getpath
359*ddb17682Schristoscommand returns the colon separated list of magic database locations.
360*ddb17682SchristosIf the
361*ddb17682Schristos.Fa filename
362*ddb17682Schristosis non-NULL, then it is returned.
363*ddb17682SchristosOtherwise, if the
364*ddb17682Schristos.Dv MAGIC
365*ddb17682Schristosenvironment variable is defined, then it is returned.
366*ddb17682SchristosOtherwise, if
367*ddb17682Schristos.Fa action
368*ddb17682Schristosis 0 (meaning "file load"), then any user-specific magic database file is included.
369*ddb17682SchristosOtherwise, only the system default magic database path is included.
3701b108b8bSchristos.Sh RETURN VALUES
3711b108b8bSchristosThe function
3721b108b8bSchristos.Fn magic_open
37361e7e15eSwizreturns a magic cookie on success and
37461e7e15eSwiz.Dv NULL
37561e7e15eSwizon failure setting errno to an appropriate value.
37661e7e15eSwizIt will set errno to
37761e7e15eSwiz.Er EINVAL
37861e7e15eSwizif an unsupported value for flags was given.
3791b108b8bSchristosThe
380046a38ddSchristos.Fn magic_list ,
3811b108b8bSchristos.Fn magic_load ,
3821b108b8bSchristos.Fn magic_compile ,
3831b108b8bSchristosand
3841b108b8bSchristos.Fn magic_check
38561e7e15eSwizfunctions return 0 on success and \-1 on failure.
3861b108b8bSchristosThe
387046a38ddSchristos.Fn magic_buffer ,
388046a38ddSchristos.Fn magic_getpath ,
3891b108b8bSchristosand
390046a38ddSchristos.Fn magic_file ,
39161e7e15eSwizfunctions return a string on success and
39261e7e15eSwiz.Dv NULL
39361e7e15eSwizon failure.
39461e7e15eSwizThe
3951b108b8bSchristos.Fn magic_error
3961b108b8bSchristosfunction returns a textual description of the errors of the above
39761e7e15eSwizfunctions, or
39861e7e15eSwiz.Dv NULL
39961e7e15eSwizif there was no error.
400c2e19894SchristosThe
401c2e19894Schristos.Fn magic_version
402c2e19894Schristosalways returns the version number of the library.
4031b108b8bSchristosFinally,
4041b108b8bSchristos.Fn magic_setflags
40561e7e15eSwizreturns \-1 on systems that don't support
40661e7e15eSwiz.Xr utime 3 ,
4071b108b8bSchristosor
4081b108b8bSchristos.Xr utimes 2
4091b108b8bSchristoswhen
4101b108b8bSchristos.Dv MAGIC_PRESERVE_ATIME
4111b108b8bSchristosis set.
4121b108b8bSchristos.Sh FILES
4131b108b8bSchristos.Bl -tag -width /usr/share/misc/magic.mgc -compact
4141b108b8bSchristos.It Pa /usr/share/misc/magic
4151b108b8bSchristosThe non-compiled default magic database.
4161b108b8bSchristos.It Pa /usr/share/misc/magic.mgc
4171b108b8bSchristosThe compiled default magic database.
4181b108b8bSchristos.El
4191b108b8bSchristos.Sh SEE ALSO
4201b108b8bSchristos.Xr file 1 ,
4211b108b8bSchristos.Xr magic 5
422c02f7f97Schristos.Sh BUGS
423c02f7f97SchristosThe results from
424c02f7f97Schristos.Fn magic_buffer
425c02f7f97Schristosand
426c02f7f97Schristos.Fn magic_file
427c02f7f97Schristoswhere the buffer and the file contain the same data
428c02f7f97Schristoscan produce different results, because in the
429c02f7f97Schristos.Fn magic_file
430c02f7f97Schristoscase, the program can
431c02f7f97Schristos.Xr lseek 2
432c02f7f97Schristosand
433c02f7f97Schristos.Xr stat 2
434c02f7f97Schristosthe file descriptor.
4351b108b8bSchristos.Sh AUTHORS
4361a718ba5Sjoerg.An M\(oans Rullg\(oard
43761e7e15eSwizInitial libmagic implementation, and configuration.
43861e7e15eSwiz.An Christos Zoulas
43961e7e15eSwizAPI cleanup, error code and allocation handling.
440