DIR(4) DIR(4)
NAME
dir - format of EFS directories
SYNOPSIS
#include <sys/fs/efsdir.h>
DESCRIPTION
A directory behaves exactly like an ordinary file, save that
no user may write into a directory. The fact that a file is
a directory is indicated by a bit in the flag word of its
i-node entry [see efsinode(4)]. The EFS directory format
supports variable length names of up to 255 characters.
DIRECTORY BLOCKS
Each EFS directory is segmented into directory blocks
defined by the following data structure:
#define EFS_DIRBLK_HEADERSIZE 4
struct efs_dirblk {
/* begin header */
ushort magic;
unchar firstused;
unchar slots;
/* end header */
/* rest is space for efs_dent's */
unchar space[EFS_DIRBSIZE - EFS_DIRBLK_HEADERSIZE];
};
Each directory block is subdivided into three separate
areas: a header, an array of entry offsets and an array of
directory entries. The system restricts directory entries
to short boundaries and stores offsets in the directory
block compacted by shifting them right by one.
The header area contains a magic number to identify the
block as being a directory block. If the magic number is
incorrect, the operating system will refuse to manipulate
the directory, thus avoiding further corruption.
The array of entry offsets immediately follows the header
and is sized according to the directories contents and
contains compacted offsets which point to each directory
entry. The number of entry offsets available is kept in
slots. The firstused field contains a compacted offset
which positions the first byte of the directory entries.
The space between the end of the entry array and the
beginning of the directory entries (firstused) is free space
which the system uses for allocating new directory entries
and entry offsets. The system keeps the free space in a
directory block compacted by coalescing holes created by
Page 1 (last mod. 8/20/87)
DIR(4) DIR(4)
entry removal. When a directory entry is removed, the
system adjusts the entry offsets for all entries that move.
Also, the entry offset for the removed entry is zeroed. If
the removed entry was the last in the entry offset array,
the number of slots is reduced. Directory entries never
change which entry offset they use.
DIRECTORY ENTRIES
Directory entries have the following structure:
struct efs_dent {
union {
ulong l;
ushorts[2];
} ud_inum;
unchar d_namelen;
char d_name[3];
};
The d_name field is actually of variable size, depending
upon the value contained in d_namelen. The system pads out
the directory entry to insure that it begins on a short
boundary in the directory block. The ud_inum field contains
the entries inode number.
SEE ALSO
fs(4), inode(4).
ORIGIN
Silicon Graphics, Inc.
Page 2 (last mod. 8/20/87)