99 lines
3.0 KiB
Groff
99 lines
3.0 KiB
Groff
'\"macro stdmacro
|
|
.if n .pH g4.dir @(#)dir 30.3 of 3/10/86
|
|
.nr X
|
|
.if \nX=0 .ds x} DIR 4 "" "\&"
|
|
.if \nX=1 .ds x} DIR 4 ""
|
|
.if \nX=2 .ds x} DIR 4 "" "\&"
|
|
.if \nX=3 .ds x} DIR "" "" "\&"
|
|
.TH \*(x}
|
|
.SH NAME
|
|
dir \- format of EFS directories
|
|
.SH SYNOPSIS
|
|
.B #include <sys/fs/efs_dir.h>
|
|
.SH 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
|
|
.IR inode (4)].
|
|
The EFS directory format supports
|
|
variable length names of up to 255 characters.
|
|
.SH "DIRECTORY BLOCKS"
|
|
Each EFS directory is segmented into directory blocks
|
|
defined by the following data structure:
|
|
.RS
|
|
.ta 8n +6n +6n
|
|
.PP
|
|
.nf
|
|
#define \s-1EFS_DIRBLK_HEADERSIZE 4\s+1
|
|
struct efs_dirblk {
|
|
/* begin header */
|
|
ushort magic;
|
|
unchar firstused;
|
|
unchar slots;
|
|
/* end header */
|
|
|
|
/* rest is space for efs_dent's */
|
|
unchar space\s-1[EFS_DIRBSIZE - EFS_DIRBLK_HEADERSIZE]\s+1;
|
|
};
|
|
.fi
|
|
.RE
|
|
.PP
|
|
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.
|
|
.PP
|
|
The header area contains a \f2magic\f1 number to identify the block
|
|
as being a directory block. If the \f2magic\f1 number is incorrect,
|
|
the operating system will refuse to manipulate the directory, thus
|
|
avoiding further corruption.
|
|
.PP
|
|
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 \f2slots\f1.
|
|
The \f2firstused\f1 field contains a compacted offset which positions
|
|
the first byte of the directory entries.
|
|
.PP
|
|
The space between the
|
|
end of the entry array and the beginning of the directory entries
|
|
(\f2firstused\f1) 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 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 \f2slots\f1 is reduced. Directory entries never change which entry
|
|
offset they use.
|
|
.SH "DIRECTORY ENTRIES"
|
|
Directory entries have the following structure:
|
|
.RS
|
|
.ta 8n +6n +6n
|
|
.PP
|
|
.nf
|
|
struct efs_dent {
|
|
union {
|
|
ulong l;
|
|
ushort s[2];
|
|
} ud_inum;
|
|
unchar d_namelen;
|
|
char d_name[3];
|
|
};
|
|
.fi
|
|
.RE
|
|
.PP
|
|
The \f2d_name\f1 field is actually of variable size, depending upon
|
|
the value contained in \f2d_namelen\f1. The system pads out the
|
|
directory entry to insure that it begins on a short boundary in
|
|
the directory block. The \f2ud_inum\f1 field contains the entries
|
|
inode number.
|
|
.SH "SEE ALSO"
|
|
fs(4), inode(4).
|
|
.\" @(#)dir.4 6.2 of 10/20/83
|
|
.Ee
|
|
'\".so /pubs/tools/origin.sgi
|