gaines@mars.njit.edu (Starman) (02/09/91)
Hi, I'm working on reading in the directory from the . file. I've broken up the structire so far as follows: Bytes 0-3 : file number Bytes 4-5 : File type Bytes 6-7 : filename length So far it's been working real well, except that at the end of one filename is the name of a file that's been deleted. The filename string is on a four word boundry and the 'extra' filestring is 5 chars long. I understand if there was an extra two or three bytes to make up for the 4word boundry, but why five characters? An exaple: alias.raycast0goofs00000 the zeros are '/0's. My first assumption was that filenames are on an eight word boundry rather than 4 word, but I have filenames 12 characters long total. The filename 'goofs' should not be in there. Also, there is one deleted file that has a four byte header rather than the eight byte (it has bytes 4-7) and other deleted files have the full eight byte headers. Any help? =========================================================================== "They can fly rings around the moon, | Mike but we're years ahead of them on the highway" | gaines@mars.njit.edu ===========================================================================
sef@kithrup.COM (Sean Eric Fagan) (02/09/91)
In article <2265@njitgw.njit.edu> gaines@mars.njit.edu (Starman) writes: >Hi, > I'm working on reading in the directory from the . file. I've >broken up the structire so far as follows: Use opendir(), readdir() and closedir(). If they are not available on your system, several pd or liberated versions exist in various places. >Bytes 0-3 : file number >Bytes 4-5 : File type >Bytes 6-7 : filename length Bzzt. I know of three unix directory formats, two of which are: Version 7: 2 bytes -- inode number 14 bytes -- file name, padded out with nuls BSD 4.2 and later: 4 bytes -- inode number 2 bytes -- directory entry length 2 btyes -- name length <x> bytes -- name and possible 0 padding Note that the byte counts are... well, they will probably be that size on all machines. The actual types for the BSD one are u_long, u_short, u_short, and char. BSD 4.3 and earlier do not allow filenames with 8-bit characters (i.e., *real* ascii only), in addition to the other limits. Whenever possible, try not to know the format of directories; it will only cause problems. In addition, if you have it, I also recommend the use of pathconf() and fpathconf(); these can be used to, among other things, find out the maximum filename length on the given (valid) path. See POSIX 1003.1... -- Sean Eric Fagan | "I made the universe, but please don't blame me for it; sef@kithrup.COM | I had a bellyache at the time." -----------------+ -- The Turtle (Stephen King, _It_) Any opinions expressed are my own, and generally unpopular with others.