file.man 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. .\" $File: file.man,v 1.144 2021/02/05 22:08:31 christos Exp $
  2. .Dd February 5, 2021
  3. .Dt FILE __CSECTION__
  4. .Os
  5. .Sh NAME
  6. .Nm file
  7. .Nd determine file type
  8. .Sh SYNOPSIS
  9. .Nm
  10. .Bk -words
  11. .Op Fl bcdEhiklLNnprsSvzZ0
  12. .Op Fl Fl apple
  13. .Op Fl Fl exclude-quiet
  14. .Op Fl Fl extension
  15. .Op Fl Fl mime-encoding
  16. .Op Fl Fl mime-type
  17. .Op Fl e Ar testname
  18. .Op Fl F Ar separator
  19. .Op Fl f Ar namefile
  20. .Op Fl m Ar magicfiles
  21. .Op Fl P Ar name=value
  22. .Ar
  23. .Ek
  24. .Nm
  25. .Fl C
  26. .Op Fl m Ar magicfiles
  27. .Nm
  28. .Op Fl Fl help
  29. .Sh DESCRIPTION
  30. This manual page documents version __VERSION__ of the
  31. .Nm
  32. command.
  33. .Pp
  34. .Nm
  35. tests each argument in an attempt to classify it.
  36. There are three sets of tests, performed in this order:
  37. filesystem tests, magic tests, and language tests.
  38. The
  39. .Em first
  40. test that succeeds causes the file type to be printed.
  41. .Pp
  42. The type printed will usually contain one of the words
  43. .Em text
  44. (the file contains only
  45. printing characters and a few common control
  46. characters and is probably safe to read on an
  47. .Dv ASCII
  48. terminal),
  49. .Em executable
  50. (the file contains the result of compiling a program
  51. in a form understandable to some
  52. .Tn UNIX
  53. kernel or another),
  54. or
  55. .Em data
  56. meaning anything else (data is usually
  57. .Dq binary
  58. or non-printable).
  59. Exceptions are well-known file formats (core files, tar archives)
  60. that are known to contain binary data.
  61. When modifying magic files or the program itself, make sure to
  62. .Em preserve these keywords .
  63. Users depend on knowing that all the readable files in a directory
  64. have the word
  65. .Dq text
  66. printed.
  67. Don't do as Berkeley did and change
  68. .Dq shell commands text
  69. to
  70. .Dq shell script .
  71. .Pp
  72. The filesystem tests are based on examining the return from a
  73. .Xr stat 2
  74. system call.
  75. The program checks to see if the file is empty,
  76. or if it's some sort of special file.
  77. Any known file types appropriate to the system you are running on
  78. (sockets, symbolic links, or named pipes (FIFOs) on those systems that
  79. implement them)
  80. are intuited if they are defined in the system header file
  81. .In sys/stat.h .
  82. .Pp
  83. The magic tests are used to check for files with data in
  84. particular fixed formats.
  85. The canonical example of this is a binary executable (compiled program)
  86. .Dv a.out
  87. file, whose format is defined in
  88. .In elf.h ,
  89. .In a.out.h
  90. and possibly
  91. .In exec.h
  92. in the standard include directory.
  93. These files have a
  94. .Dq magic number
  95. stored in a particular place
  96. near the beginning of the file that tells the
  97. .Tn UNIX
  98. operating system
  99. that the file is a binary executable, and which of several types thereof.
  100. The concept of a
  101. .Dq magic number
  102. has been applied by extension to data files.
  103. Any file with some invariant identifier at a small fixed
  104. offset into the file can usually be described in this way.
  105. The information identifying these files is read from the compiled
  106. magic file
  107. .Pa __MAGIC__.mgc ,
  108. or the files in the directory
  109. .Pa __MAGIC__
  110. if the compiled file does not exist.
  111. In addition, if
  112. .Pa $HOME/.magic.mgc
  113. or
  114. .Pa $HOME/.magic
  115. exists, it will be used in preference to the system magic files.
  116. .Pp
  117. If a file does not match any of the entries in the magic file,
  118. it is examined to see if it seems to be a text file.
  119. ASCII, ISO-8859-x, non-ISO 8-bit extended-ASCII character sets
  120. (such as those used on Macintosh and IBM PC systems),
  121. UTF-8-encoded Unicode, UTF-16-encoded Unicode, and EBCDIC
  122. character sets can be distinguished by the different
  123. ranges and sequences of bytes that constitute printable text
  124. in each set.
  125. If a file passes any of these tests, its character set is reported.
  126. ASCII, ISO-8859-x, UTF-8, and extended-ASCII files are identified
  127. as
  128. .Dq text
  129. because they will be mostly readable on nearly any terminal;
  130. UTF-16 and EBCDIC are only
  131. .Dq character data
  132. because, while
  133. they contain text, it is text that will require translation
  134. before it can be read.
  135. In addition,
  136. .Nm
  137. will attempt to determine other characteristics of text-type files.
  138. If the lines of a file are terminated by CR, CRLF, or NEL, instead
  139. of the Unix-standard LF, this will be reported.
  140. Files that contain embedded escape sequences or overstriking
  141. will also be identified.
  142. .Pp
  143. Once
  144. .Nm
  145. has determined the character set used in a text-type file,
  146. it will
  147. attempt to determine in what language the file is written.
  148. The language tests look for particular strings (cf.
  149. .In names.h )
  150. that can appear anywhere in the first few blocks of a file.
  151. For example, the keyword
  152. .Em .br
  153. indicates that the file is most likely a
  154. .Xr troff 1
  155. input file, just as the keyword
  156. .Em struct
  157. indicates a C program.
  158. These tests are less reliable than the previous
  159. two groups, so they are performed last.
  160. The language test routines also test for some miscellany
  161. (such as
  162. .Xr tar 1
  163. archives, JSON files).
  164. .Pp
  165. Any file that cannot be identified as having been written
  166. in any of the character sets listed above is simply said to be
  167. .Dq data .
  168. .Sh OPTIONS
  169. .Bl -tag -width indent
  170. .It Fl Fl apple
  171. Causes the
  172. .Nm
  173. command to output the file type and creator code as
  174. used by older MacOS versions.
  175. The code consists of eight letters,
  176. the first describing the file type, the latter the creator.
  177. This option works properly only for file formats that have the
  178. apple-style output defined.
  179. .It Fl b , Fl Fl brief
  180. Do not prepend filenames to output lines (brief mode).
  181. .It Fl C , Fl Fl compile
  182. Write a
  183. .Pa magic.mgc
  184. output file that contains a pre-parsed version of the magic file or directory.
  185. .It Fl c , Fl Fl checking-printout
  186. Cause a checking printout of the parsed form of the magic file.
  187. This is usually used in conjunction with the
  188. .Fl m
  189. option to debug a new magic file before installing it.
  190. .It Fl d
  191. Prints internal debugging information to stderr.
  192. .It Fl E
  193. On filesystem errors (file not found etc), instead of handling the error
  194. as regular output as POSIX mandates and keep going, issue an error message
  195. and exit.
  196. .It Fl e , Fl Fl exclude Ar testname
  197. Exclude the test named in
  198. .Ar testname
  199. from the list of tests made to determine the file type.
  200. Valid test names are:
  201. .Bl -tag -width compress
  202. .It apptype
  203. .Dv EMX
  204. application type (only on EMX).
  205. .It ascii
  206. Various types of text files (this test will try to guess the text
  207. encoding, irrespective of the setting of the
  208. .Sq encoding
  209. option).
  210. .It encoding
  211. Different text encodings for soft magic tests.
  212. .It tokens
  213. Ignored for backwards compatibility.
  214. .It cdf
  215. Prints details of Compound Document Files.
  216. .It compress
  217. Checks for, and looks inside, compressed files.
  218. .It csv
  219. Checks Comma Separated Value files.
  220. .It elf
  221. Prints ELF file details, provided soft magic tests are enabled and the
  222. elf magic is found.
  223. .It json
  224. Examines JSON (RFC-7159) files by parsing them for compliance.
  225. .It soft
  226. Consults magic files.
  227. .It tar
  228. Examines tar files by verifying the checksum of the 512 byte tar header.
  229. Excluding this test can provide more detailed content description by using
  230. the soft magic method.
  231. .It text
  232. A synonym for
  233. .Sq ascii .
  234. .El
  235. .It Fl Fl exclude-quiet
  236. Like
  237. .Fl Fl exclude
  238. but ignore tests that
  239. .Nm
  240. does not know about.
  241. This is intended for compatibility with older versions of
  242. .Nm .
  243. .It Fl Fl extension
  244. Print a slash-separated list of valid extensions for the file type found.
  245. .It Fl F , Fl Fl separator Ar separator
  246. Use the specified string as the separator between the filename and the
  247. file result returned.
  248. Defaults to
  249. .Sq \&: .
  250. .It Fl f , Fl Fl files-from Ar namefile
  251. Read the names of the files to be examined from
  252. .Ar namefile
  253. (one per line)
  254. before the argument list.
  255. Either
  256. .Ar namefile
  257. or at least one filename argument must be present;
  258. to test the standard input, use
  259. .Sq -
  260. as a filename argument.
  261. Please note that
  262. .Ar namefile
  263. is unwrapped and the enclosed filenames are processed when this option is
  264. encountered and before any further options processing is done.
  265. This allows one to process multiple lists of files with different command line
  266. arguments on the same
  267. .Nm
  268. invocation.
  269. Thus if you want to set the delimiter, you need to do it before you specify
  270. the list of files, like:
  271. .Dq Fl F Ar @ Fl f Ar namefile ,
  272. instead of:
  273. .Dq Fl f Ar namefile Fl F Ar @ .
  274. .It Fl h , Fl Fl no-dereference
  275. This option causes symlinks not to be followed
  276. (on systems that support symbolic links).
  277. This is the default if the environment variable
  278. .Dv POSIXLY_CORRECT
  279. is not defined.
  280. .It Fl i , Fl Fl mime
  281. Causes the
  282. .Nm
  283. command to output mime type strings rather than the more
  284. traditional human readable ones.
  285. Thus it may say
  286. .Sq text/plain; charset=us-ascii
  287. rather than
  288. .Dq ASCII text .
  289. .It Fl Fl mime-type , Fl Fl mime-encoding
  290. Like
  291. .Fl i ,
  292. but print only the specified element(s).
  293. .It Fl k , Fl Fl keep-going
  294. Don't stop at the first match, keep going.
  295. Subsequent matches will be
  296. have the string
  297. .Sq "\[rs]012\- "
  298. prepended.
  299. (If you want a newline, see the
  300. .Fl r
  301. option.)
  302. The magic pattern with the highest strength (see the
  303. .Fl l
  304. option) comes first.
  305. .It Fl l , Fl Fl list
  306. Shows a list of patterns and their strength sorted descending by
  307. .Xr magic __FSECTION__
  308. strength
  309. which is used for the matching (see also the
  310. .Fl k
  311. option).
  312. .It Fl L , Fl Fl dereference
  313. This option causes symlinks to be followed, as the like-named option in
  314. .Xr ls 1
  315. (on systems that support symbolic links).
  316. This is the default if the environment variable
  317. .Ev POSIXLY_CORRECT
  318. is defined.
  319. .It Fl m , Fl Fl magic-file Ar magicfiles
  320. Specify an alternate list of files and directories containing magic.
  321. This can be a single item, or a colon-separated list.
  322. If a compiled magic file is found alongside a file or directory,
  323. it will be used instead.
  324. .It Fl N , Fl Fl no-pad
  325. Don't pad filenames so that they align in the output.
  326. .It Fl n , Fl Fl no-buffer
  327. Force stdout to be flushed after checking each file.
  328. This is only useful if checking a list of files.
  329. It is intended to be used by programs that want filetype output from a pipe.
  330. .It Fl p , Fl Fl preserve-date
  331. On systems that support
  332. .Xr utime 3
  333. or
  334. .Xr utimes 2 ,
  335. attempt to preserve the access time of files analyzed, to pretend that
  336. .Nm
  337. never read them.
  338. .It Fl P , Fl Fl parameter Ar name=value
  339. Set various parameter limits.
  340. .Bl -column "elf_phnum" "Default" "XXXXXXXXXXXXXXXXXXXXXXXXXXX" -offset indent
  341. .It Sy "Name" Ta Sy "Default" Ta Sy "Explanation"
  342. .It Li bytes Ta 1048576 Ta max number of bytes to read from file
  343. .It Li elf_notes Ta 256 Ta max ELF notes processed
  344. .It Li elf_phnum Ta 2048 Ta max ELF program sections processed
  345. .It Li elf_shnum Ta 32768 Ta max ELF sections processed
  346. .It Li encoding Ta 65536 Ta max number of bytes to scan for encoding evaluation
  347. .It Li indir Ta 50 Ta recursion limit for indirect magic
  348. .It Li name Ta 50 Ta use count limit for name/use magic
  349. .It Li regex Ta 8192 Ta length limit for regex searches
  350. .El
  351. .It Fl r , Fl Fl raw
  352. Don't translate unprintable characters to \eooo.
  353. Normally
  354. .Nm
  355. translates unprintable characters to their octal representation.
  356. .It Fl s , Fl Fl special-files
  357. Normally,
  358. .Nm
  359. only attempts to read and determine the type of argument files which
  360. .Xr stat 2
  361. reports are ordinary files.
  362. This prevents problems, because reading special files may have peculiar
  363. consequences.
  364. Specifying the
  365. .Fl s
  366. option causes
  367. .Nm
  368. to also read argument files which are block or character special files.
  369. This is useful for determining the filesystem types of the data in raw
  370. disk partitions, which are block special files.
  371. This option also causes
  372. .Nm
  373. to disregard the file size as reported by
  374. .Xr stat 2
  375. since on some systems it reports a zero size for raw disk partitions.
  376. .It Fl S , Fl Fl no-sandbox
  377. On systems where libseccomp
  378. .Pa ( https://github.com/seccomp/libseccomp )
  379. is available, the
  380. .Fl S
  381. option disables sandboxing which is enabled by default.
  382. This option is needed for
  383. .Nm
  384. to execute external decompressing programs,
  385. i.e. when the
  386. .Fl z
  387. option is specified and the built-in decompressors are not available.
  388. On systems where sandboxing is not available, this option has no effect.
  389. .It Fl v , Fl Fl version
  390. Print the version of the program and exit.
  391. .It Fl z , Fl Fl uncompress
  392. Try to look inside compressed files.
  393. .It Fl Z , Fl Fl uncompress-noreport
  394. Try to look inside compressed files, but report information about the contents
  395. only not the compression.
  396. .It Fl 0 , Fl Fl print0
  397. Output a null character
  398. .Sq \e0
  399. after the end of the filename.
  400. Nice to
  401. .Xr cut 1
  402. the output.
  403. This does not affect the separator, which is still printed.
  404. .Pp
  405. If this option is repeated more than once, then
  406. .Nm
  407. prints just the filename followed by a NUL followed by the description
  408. (or ERROR: text) followed by a second NUL for each entry.
  409. .It Fl -help
  410. Print a help message and exit.
  411. .El
  412. .Sh ENVIRONMENT
  413. The environment variable
  414. .Ev MAGIC
  415. can be used to set the default magic file name.
  416. If that variable is set, then
  417. .Nm
  418. will not attempt to open
  419. .Pa $HOME/.magic .
  420. .Nm
  421. adds
  422. .Dq Pa .mgc
  423. to the value of this variable as appropriate.
  424. The environment variable
  425. .Ev POSIXLY_CORRECT
  426. controls (on systems that support symbolic links), whether
  427. .Nm
  428. will attempt to follow symlinks or not.
  429. If set, then
  430. .Nm
  431. follows symlink, otherwise it does not.
  432. This is also controlled by the
  433. .Fl L
  434. and
  435. .Fl h
  436. options.
  437. .Sh FILES
  438. .Bl -tag -width __MAGIC__.mgc -compact
  439. .It Pa __MAGIC__.mgc
  440. Default compiled list of magic.
  441. .It Pa __MAGIC__
  442. Directory containing default magic files.
  443. .El
  444. .Sh EXIT STATUS
  445. .Nm
  446. will exit with
  447. .Dv 0
  448. if the operation was successful or
  449. .Dv >0
  450. if an error was encountered.
  451. The following errors cause diagnostic messages, but don't affect the program
  452. exit code (as POSIX requires), unless
  453. .Fl E
  454. is specified:
  455. .Bl -bullet -compact -offset indent
  456. .It
  457. A file cannot be found
  458. .It
  459. There is no permission to read a file
  460. .It
  461. The file type cannot be determined
  462. .El
  463. .Sh EXAMPLES
  464. .Bd -literal -offset indent
  465. $ file file.c file /dev/{wd0a,hda}
  466. file.c: C program text
  467. file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
  468. dynamically linked (uses shared libs), stripped
  469. /dev/wd0a: block special (0/0)
  470. /dev/hda: block special (3/0)
  471. $ file -s /dev/wd0{b,d}
  472. /dev/wd0b: data
  473. /dev/wd0d: x86 boot sector
  474. $ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10}
  475. /dev/hda: x86 boot sector
  476. /dev/hda1: Linux/i386 ext2 filesystem
  477. /dev/hda2: x86 boot sector
  478. /dev/hda3: x86 boot sector, extended partition table
  479. /dev/hda4: Linux/i386 ext2 filesystem
  480. /dev/hda5: Linux/i386 swap file
  481. /dev/hda6: Linux/i386 swap file
  482. /dev/hda7: Linux/i386 swap file
  483. /dev/hda8: Linux/i386 swap file
  484. /dev/hda9: empty
  485. /dev/hda10: empty
  486. $ file -i file.c file /dev/{wd0a,hda}
  487. file.c: text/x-c
  488. file: application/x-executable
  489. /dev/hda: application/x-not-regular-file
  490. /dev/wd0a: application/x-not-regular-file
  491. .Ed
  492. .Sh SEE ALSO
  493. .Xr hexdump 1 ,
  494. .Xr od 1 ,
  495. .Xr strings 1 ,
  496. .Xr magic __FSECTION__
  497. .Sh STANDARDS CONFORMANCE
  498. This program is believed to exceed the System V Interface Definition
  499. of FILE(CMD), as near as one can determine from the vague language
  500. contained therein.
  501. Its behavior is mostly compatible with the System V program of the same name.
  502. This version knows more magic, however, so it will produce
  503. different (albeit more accurate) output in many cases.
  504. .\" URL: http://www.opengroup.org/onlinepubs/009695399/utilities/file.html
  505. .Pp
  506. The one significant difference
  507. between this version and System V
  508. is that this version treats any white space
  509. as a delimiter, so that spaces in pattern strings must be escaped.
  510. For example,
  511. .Bd -literal -offset indent
  512. \*[Gt]10 string language impress\ (imPRESS data)
  513. .Ed
  514. .Pp
  515. in an existing magic file would have to be changed to
  516. .Bd -literal -offset indent
  517. \*[Gt]10 string language\e impress (imPRESS data)
  518. .Ed
  519. .Pp
  520. In addition, in this version, if a pattern string contains a backslash,
  521. it must be escaped.
  522. For example
  523. .Bd -literal -offset indent
  524. 0 string \ebegindata Andrew Toolkit document
  525. .Ed
  526. .Pp
  527. in an existing magic file would have to be changed to
  528. .Bd -literal -offset indent
  529. 0 string \e\ebegindata Andrew Toolkit document
  530. .Ed
  531. .Pp
  532. SunOS releases 3.2 and later from Sun Microsystems include a
  533. .Nm
  534. command derived from the System V one, but with some extensions.
  535. This version differs from Sun's only in minor ways.
  536. It includes the extension of the
  537. .Sq \*[Am]
  538. operator, used as,
  539. for example,
  540. .Bd -literal -offset indent
  541. \*[Gt]16 long\*[Am]0x7fffffff \*[Gt]0 not stripped
  542. .Ed
  543. .Sh SECURITY
  544. On systems where libseccomp
  545. .Pa ( https://github.com/seccomp/libseccomp )
  546. is available,
  547. .Nm
  548. is enforces limiting system calls to only the ones necessary for the
  549. operation of the program.
  550. This enforcement does not provide any security benefit when
  551. .Nm
  552. is asked to decompress input files running external programs with
  553. the
  554. .Fl z
  555. option.
  556. To enable execution of external decompressors, one needs to disable
  557. sandboxing using the
  558. .Fl S
  559. option.
  560. .Sh MAGIC DIRECTORY
  561. The magic file entries have been collected from various sources,
  562. mainly USENET, and contributed by various authors.
  563. Christos Zoulas (address below) will collect additional
  564. or corrected magic file entries.
  565. A consolidation of magic file entries
  566. will be distributed periodically.
  567. .Pp
  568. The order of entries in the magic file is significant.
  569. Depending on what system you are using, the order that
  570. they are put together may be incorrect.
  571. If your old
  572. .Nm
  573. command uses a magic file,
  574. keep the old magic file around for comparison purposes
  575. (rename it to
  576. .Pa __MAGIC__.orig ) .
  577. .Sh HISTORY
  578. There has been a
  579. .Nm
  580. command in every
  581. .Dv UNIX since at least Research Version 4
  582. (man page dated November, 1973).
  583. The System V version introduced one significant major change:
  584. the external list of magic types.
  585. This slowed the program down slightly but made it a lot more flexible.
  586. .Pp
  587. This program, based on the System V version,
  588. was written by Ian Darwin
  589. .Aq ian@darwinsys.com
  590. without looking at anybody else's source code.
  591. .Pp
  592. John Gilmore revised the code extensively, making it better than
  593. the first version.
  594. Geoff Collyer found several inadequacies
  595. and provided some magic file entries.
  596. Contributions of the
  597. .Sq \*[Am]
  598. operator by Rob McMahon,
  599. .Aq cudcv@warwick.ac.uk ,
  600. 1989.
  601. .Pp
  602. Guy Harris,
  603. .Aq guy@netapp.com ,
  604. made many changes from 1993 to the present.
  605. .Pp
  606. Primary development and maintenance from 1990 to the present by
  607. Christos Zoulas
  608. .Aq christos@astron.com .
  609. .Pp
  610. Altered by Chris Lowth
  611. .Aq chris@lowth.com ,
  612. 2000: handle the
  613. .Fl i
  614. option to output mime type strings, using an alternative
  615. magic file and internal logic.
  616. .Pp
  617. Altered by Eric Fischer
  618. .Aq enf@pobox.com ,
  619. July, 2000,
  620. to identify character codes and attempt to identify the languages
  621. of non-ASCII files.
  622. .Pp
  623. Altered by Reuben Thomas
  624. .Aq rrt@sc3d.org ,
  625. 2007-2011, to improve MIME support, merge MIME and non-MIME magic,
  626. support directories as well as files of magic, apply many bug fixes,
  627. update and fix a lot of magic, improve the build system, improve the
  628. documentation, and rewrite the Python bindings in pure Python.
  629. .Pp
  630. The list of contributors to the
  631. .Sq magic
  632. directory (magic files)
  633. is too long to include here.
  634. You know who you are; thank you.
  635. Many contributors are listed in the source files.
  636. .Sh LEGAL NOTICE
  637. Copyright (c) Ian F. Darwin, Toronto, Canada, 1986-1999.
  638. Covered by the standard Berkeley Software Distribution copyright; see the file
  639. COPYING in the source distribution.
  640. .Pp
  641. The files
  642. .Pa tar.h
  643. and
  644. .Pa is_tar.c
  645. were written by John Gilmore from his public-domain
  646. .Xr tar 1
  647. program, and are not covered by the above license.
  648. .Sh BUGS
  649. Please report bugs and send patches to the bug tracker at
  650. .Pa https://bugs.astron.com/
  651. or the mailing list at
  652. .Aq file@astron.com
  653. (visit
  654. .Pa https://mailman.astron.com/mailman/listinfo/file
  655. first to subscribe).
  656. .Sh TODO
  657. Fix output so that tests for MIME and APPLE flags are not needed all
  658. over the place, and actual output is only done in one place.
  659. This needs a design.
  660. Suggestion: push possible outputs on to a list, then pick the
  661. last-pushed (most specific, one hopes) value at the end, or
  662. use a default if the list is empty.
  663. This should not slow down evaluation.
  664. .Pp
  665. The handling of
  666. .Dv MAGIC_CONTINUE
  667. and printing \e012- between entries is clumsy and complicated; refactor
  668. and centralize.
  669. .Pp
  670. Some of the encoding logic is hard-coded in encoding.c and can be moved
  671. to the magic files if we had a !:charset annotation.
  672. .Pp
  673. Continue to squash all magic bugs.
  674. See Debian BTS for a good source.
  675. .Pp
  676. Store arbitrarily long strings, for example for %s patterns, so that
  677. they can be printed out.
  678. Fixes Debian bug #271672.
  679. This can be done by allocating strings in a string pool, storing the
  680. string pool at the end of the magic file and converting all the string
  681. pointers to relative offsets from the string pool.
  682. .Pp
  683. Add syntax for relative offsets after current level (Debian bug #466037).
  684. .Pp
  685. Make file -ki work, i.e. give multiple MIME types.
  686. .Pp
  687. Add a zip library so we can peek inside Office2007 documents to
  688. print more details about their contents.
  689. .Pp
  690. Add an option to print URLs for the sources of the file descriptions.
  691. .Pp
  692. Combine script searches and add a way to map executable names to MIME
  693. types (e.g. have a magic value for !:mime which causes the resulting
  694. string to be looked up in a table).
  695. This would avoid adding the same magic repeatedly for each new
  696. hash-bang interpreter.
  697. .Pp
  698. When a file descriptor is available, we can skip and adjust the buffer
  699. instead of the hacky buffer management we do now.
  700. .Pp
  701. Fix
  702. .Dq name
  703. and
  704. .Dq use
  705. to check for consistency at compile time (duplicate
  706. .Dq name ,
  707. .Dq use
  708. pointing to undefined
  709. .Dq name
  710. ).
  711. Make
  712. .Dq name
  713. /
  714. .Dq use
  715. more efficient by keeping a sorted list of names.
  716. Special-case ^ to flip endianness in the parser so that it does not
  717. have to be escaped, and document it.
  718. .Pp
  719. If the offsets specified internally in the file exceed the buffer size
  720. (
  721. .Dv HOWMANY
  722. variable in file.h), then we don't seek to that offset, but we give up.
  723. It would be better if buffer managements was done when the file descriptor
  724. is available so we can seek around the file.
  725. One must be careful though because this has performance and thus security
  726. considerations, because one can slow down things by repeateadly seeking.
  727. .Pp
  728. There is support now for keeping separate buffers and having offsets from
  729. the end of the file, but the internal buffer management still needs an
  730. overhaul.
  731. .Sh AVAILABILITY
  732. You can obtain the original author's latest version by anonymous FTP
  733. on
  734. .Pa ftp.astron.com
  735. in the directory
  736. .Pa /pub/file/file-X.YZ.tar.gz .