4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
40 #ifndef _SYS_FS_UFS_FSDIR_H
41 #define _SYS_FS_UFS_FSDIR_H
48 * A directory consists of some number of blocks of DIRBLKSIZ
49 * bytes, where DIRBLKSIZ is chosen such that it can be transferred
50 * to disk in a single atomic operation (e.g. 512 bytes on most machines).
52 * Each DIRBLKSIZ byte block contains some number of directory entry
53 * structures, which are of variable length. Each directory entry has
54 * a struct direct at the front of it, containing its inode number,
55 * the length of the entry, and the length of the name contained in
56 * the entry. These are followed by the name padded to a 4 byte boundary
57 * with null bytes. All names are guaranteed null terminated.
58 * The maximum length of a name in a directory is MAXNAMLEN.
60 * The macro DIRSIZ(dp) gives the amount of space required to represent
61 * a directory entry. Free space in a directory is represented by
62 * entries which have dp->d_reclen > DIRSIZ(dp). All DIRBLKSIZ bytes
63 * in a directory block are claimed by the directory entries. This
64 * usually results in the last entry in a directory having a large
65 * dp->d_reclen. When entries are deleted from a directory, the
66 * space is returned to the previous entry in the same directory
67 * block by increasing its dp->d_reclen. If the first entry of
68 * a directory block is free, then its dp->d_ino is set to 0.
69 * Entries other than the first in a directory do not normally have
72 #define DIRBLKSIZ DEV_BSIZE
76 uint32_t d_ino
; /* inode number of entry */
77 ushort_t d_reclen
; /* length of this record */
78 ushort_t d_namlen
; /* length of string in d_name */
79 char d_name
[MAXNAMLEN
+ 1]; /* name must be no longer than this */
83 * The DIRSIZ macro gives the minimum record length which will hold
84 * the directory entry. This requires the amount of space in struct direct
85 * without the d_name field, plus enough space for the name with a terminating
86 * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
90 ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1+3) &~ 3))
94 * Template for manipulating directories.
95 * Should use struct direct's, but the name field
96 * is MAXNAMLEN - 1, and this just won't do.
102 char dot_name
[4]; /* must be multiple of 4 */
106 char dotdot_name
[4]; /* ditto */
114 #endif /* _SYS_FS_UFS_FSDIR_H */