Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!ub!boulder!gore!jacob From: jacob@gore.com (Jacob Gore) Newsgroups: comp.sys.next Subject: Re: Forks? Message-ID: <130124@gore.com> Date: 30 Nov 90 20:06:15 GMT References: Reply-To: jacob@gore.com (Jacob Gore) Organization: Gore Enterprises Lines: 68 / comp.sys.next / jjoshua@remus.rutgers.edu (J. Joshua) / Nov 28, 1990 / > where are the file's attributes stored? Are they contained in > the actual file (and are invisible to you and me) or are they located > somewhere else. Data files in Unix are typeless by design. Each is just a finite stream of bytes. However, type information is often helpful, so it is represented by programs and applications in two ways: 1. The filename "extension" (the last dot in the filename and all the characters that follow it). For example, ".c" for C files, ".m" for Objective-C files, ".wn" for WriteNow documents. The Unix file system treats the whole filename as one unit. NeXT Workspace Manager, however, uses the file extension to decide what application will process a file if you double-click on that file's icon. 2. The "magic number". This is, generally, the first few bytes of the file. (Not all files will have something meaningful there.) For example, a Mach-O executable will have the number 'feedface' (hexadecimal) there; shell scripts may have "#!" as the first two bytes to tell the loader that the filename that follows them is the program to load for execution of the script (e.g., "#!/bin/csh -b"). An archive will have the text "!\n" there ("\n" is a newline). Magic numbers are not used by the Workspace Manager in 1.0 (as far as I can tell), but the loader uses them when the file is executed as a program, and applications are free to use them. The 'file' command, which tries to determine the type of a file, also tends to use it... I don't know if the version in NeXT 1.0 does, and it is quite broken in 1.0 anyway (produces a segmentation fault on NeXTstep applications, which are quite common on the NeXT:-). By the way, just because something is stored in a data file, doesn't at all mean that it's "invisible to you and me". It's still just a data file, so you can pull it into Emacs -- I'd suggest you do it read-only (C-x C-r), unless you understand the file's format and are skilled at editing octal representations of bytes -- and look at it all you want. Here is the first four bytes of an application (converted to ASCII for posting -- in Emacs, each "\..." is one byte, represented in octal): \376\355\372\316 or, in hexadecimal: fe ed fa ce Or, you can just do a hex dump: jacob@blackbox> od -x /NextApps/Edit | head -2 0000000 feed face 0000 0006 0000 0001 0000 0002 0000020 0000 000b 0000 07ac 0000 0001 0000 0001 jacob@blackbox> od -x /bin/od | head -1 0000000 feed face 0000 0006 0000 0001 0000 0002 jacob@blackbox> od -h /usr/shlib/libsys_s.B.shlib | head -1 0000000 feed face 0000 0006 0000 0001 0000 0003 jacob@blackbox> Or a character dump: jacob@blackbox> od -c /lib/libc.a | head -1 0000000 ! < a r c h > \n _ _ . S Y M D E jacob@blackbox> Jacob -- Jacob Gore Jacob@Gore.Com boulder!gore!jacob