|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1982, 1986, 1989 The Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution is only permitted until one year after the first shipment ! 6: * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and ! 7: * binary forms are permitted provided that: (1) source distributions retain ! 8: * this entire copyright notice and comment, and (2) distributions including ! 9: * binaries display the following acknowledgement: This product includes ! 10: * software developed by the University of California, Berkeley and its ! 11: * contributors'' in the documentation or other materials provided with the ! 12: * distribution and in all advertising materials mentioning features or use ! 13: * of this software. Neither the name of the University nor the names of ! 14: * its contributors may be used to endorse or promote products derived from ! 15: * this software without specific prior written permission. ! 16: * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 17: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 18: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 19: * ! 20: * @(#)dir.h 7.9 (Berkeley) 6/28/90 ! 21: */ ! 22: ! 23: #ifndef _DIR_ ! 24: #define _DIR_ ! 25: ! 26: /* ! 27: * A directory consists of some number of blocks of DIRBLKSIZ ! 28: * bytes, where DIRBLKSIZ is chosen such that it can be transferred ! 29: * to disk in a single atomic operation (e.g. 512 bytes on most machines). ! 30: * ! 31: * Each DIRBLKSIZ byte block contains some number of directory entry ! 32: * structures, which are of variable length. Each directory entry has ! 33: * a struct direct at the front of it, containing its inode number, ! 34: * the length of the entry, and the length of the name contained in ! 35: * the entry. These are followed by the name padded to a 4 byte boundary ! 36: * with null bytes. All names are guaranteed null terminated. ! 37: * The maximum length of a name in a directory is MAXNAMLEN. ! 38: * ! 39: * The macro DIRSIZ(dp) gives the amount of space required to represent ! 40: * a directory entry. Free space in a directory is represented by ! 41: * entries which have dp->d_reclen > DIRSIZ(dp). All DIRBLKSIZ bytes ! 42: * in a directory block are claimed by the directory entries. This ! 43: * usually results in the last entry in a directory having a large ! 44: * dp->d_reclen. When entries are deleted from a directory, the ! 45: * space is returned to the previous entry in the same directory ! 46: * block by increasing its dp->d_reclen. If the first entry of ! 47: * a directory block is free, then its dp->d_ino is set to 0. ! 48: * Entries other than the first in a directory do not normally have ! 49: * dp->d_ino set to 0. ! 50: */ ! 51: #define DIRBLKSIZ DEV_BSIZE ! 52: #define MAXNAMLEN 255 ! 53: ! 54: struct direct { ! 55: u_long d_ino; /* inode number of entry */ ! 56: u_short d_reclen; /* length of this record */ ! 57: u_short d_namlen; /* length of string in d_name */ ! 58: char d_name[MAXNAMLEN + 1]; /* name with length <= MAXNAMLEN */ ! 59: }; ! 60: ! 61: /* ! 62: * The DIRSIZ macro gives the minimum record length which will hold ! 63: * the directory entry. This requires the amount of space in struct direct ! 64: * without the d_name field, plus enough space for the name with a terminating ! 65: * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. ! 66: */ ! 67: #define DIRSIZ(dp) \ ! 68: ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) ! 69: ! 70: /* ! 71: * Template for manipulating directories. ! 72: * Should use struct direct's, but the name field ! 73: * is MAXNAMLEN - 1, and this just won't do. ! 74: */ ! 75: struct dirtemplate { ! 76: u_long dot_ino; ! 77: short dot_reclen; ! 78: short dot_namlen; ! 79: char dot_name[4]; /* must be multiple of 4 */ ! 80: u_long dotdot_ino; ! 81: short dotdot_reclen; ! 82: short dotdot_namlen; ! 83: char dotdot_name[4]; /* ditto */ ! 84: }; ! 85: #endif /* _DIR_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.