home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / bugs / sys5 / 174 < prev    next >
Encoding:
Text File  |  1993-01-11  |  3.5 KB  |  86 lines

  1. Newsgroups: comp.bugs.sys5
  2. Path: sparky!uunet!spool.mu.edu!uwm.edu!linac!att!att!dptg!ulysses!ulysses.att.com!gsf
  3. From: gsf@ulysses.att.com (Glenn S. Fowler)
  4. Subject: Re: Improving "file" (was Re: Making Solaris 2.1 smarter...)
  5. Message-ID: <1993Jan11.183955.17911@ulysses.att.com>
  6. Date: Mon, 11 Jan 1993 18:39:55 GMT
  7. Distribution: na
  8. References: <16320@auspex-gw.auspex.com> <1993Jan10.143907.12860@ulysses.att.com> <16329@auspex-gw.auspex.com>
  9. Organization: AT&T Bell Labs
  10. Lines: 74
  11.  
  12. In article <16329@auspex-gw.auspex.com> guy@Auspex.COM (Guy Harris) writes:
  13. >>instead of changing the magic file format to handle BE/LE,
  14. >Too late, I've *already* changed it, and nobody's yet shown any
  15. >disadvantages to doing so....
  16.  
  17. well, too late for someone
  18.  
  19. there are two methods being advocated
  20. one changes the magic file data (guy)
  21. and one changes the file command (gsf)
  22. both are valid approaches based on different assumptions
  23.  
  24. (guy) requires a-priori partitioning of file formats into
  25. big and little endian classes -- the problem here is that
  26. there are some formats that are architecture independent
  27. but still byte order dependent, like the binary cpio format
  28. the solution is to provide duplicate magic file entries:
  29.  
  30. 0    short        070707        cpio archive
  31. 0    short        0143561        cpio archive
  32.  
  33. -or-
  34.  
  35. 0    beshort        070707        cpio archive
  36. 0    leshort        070707        cpio archive
  37.  
  38. (gsf) is based on the assumtion that a byte swapped binary magic number
  39. will not clash with other magic file magic numbers (not a problem so far)
  40. and that the byte order of the first binary test determines the byte
  41. order for the remaining fields for that magic file entry
  42. this method avoids most magic file duplication for formats that cannot
  43. be a-priori labeled BE or LE -- it also handles byte orderings other
  44. then BE and LE (pdp shorts were LE but longs were half LE half BE)
  45.  
  46. >I just changed all the magic numbers for VAX and i386 "a.out" and COFF
  47. >executables to use "le{short,long}" and all the "a.out" and COFF magic
  48. >numbers for architectures I knew were big-endian to "be{short,long}"; no
  49. >duplication was required there.
  50.  
  51. you must provide a duplicate entry for binary cpio, no?
  52.  
  53. >ELF required a little duplication, so that it extracts the various
  54. >fields in the right byte order for the architecture.
  55.  
  56. elf uses a byte order independent magic string with byte order
  57. dependent fields -- it did require 5 extra lines in our magic file
  58.  
  59. >That was the *only* duplication required; the same "magic" file works on
  60. >big-endian and little-endian architectures (although you may want to
  61. >change what entries appear if, say, some particular magic number is used
  62. >both for TLA, Inc.'s "a.out" files and FroboTech PLC's "a.out" files).
  63.  
  64. what about cpu's with byte swap HW jumpers -- does the format change
  65. or just the byte order (not a trick question, I really don't know about
  66. this)
  67.  
  68. >What happens if you have a field whose value you don't test at all, or
  69. >test with a test other than one for equality or inequality, and whose
  70. >value you later print?
  71.  
  72. the first magic number in each magic file entry determines the byte
  73. order for all other fields for that entry -- the remaining fields are
  74. swapped to the same order as the magic number as they are snarfed
  75. from the subject file
  76.  
  77. for example, our cpio magic file entry could be
  78.  
  79. 0    short        070707        cpio archive (magic=0%lo)
  80.  
  81. and the magic number would be printed 070707 for subject archives
  82. generated on either BE or LE architectures
  83.  
  84. Glenn Fowler    (908)-582-2195    AT&T Bell Laboratories, Murray Hill, NJ
  85. uucp: {att,ucbvax}!ulysses!gsf              internet: gsf@ulysses.att.com
  86.