inode(4) DG/UX 5.4R3.00 inode(4)
NAME
inode - file node structure
SYNOPSIS
#include <ufs/inode.h>
DESCRIPTION
The inode table for a file system is distributed across the disk: a
table exists in each disk allocation region (DAR). For more
information about the file system layout, refer to fs(4).
The file node's purpose is to provide access to data blocks
associated with the file. The data blocks are allocated in chunks of
contiguous physical blocks called data elements. In the case that
the file is less than the data element size, the file is fragmented.
In this case, the file has only one data element and its size is
determined by the fragment exponent field. If the file grows, the
fragmented data element is copied to a full sized element, and the
allocation to the file will always be in data element sized chunks,
causing the actual size of the file to be less than or equal to the
blocks allocated to it.
Data elements are accessed directly or indirectly depending on the
size of the file. The file node has an array of direct data
elements, pointing to the first block of the data element. If the
size of the file is greater than the number of direct data element
pointers, then indirect access is used.
Indirect data element access is provided through indexing. An index
structure consists of index blocks containing pointers to data
elements. Depending on the depth of the index structure, index
entries point to data elements or other index blocks. There are
three index structures rooted in the file node; each of the three
differs in the levels of indexing. If the file node represents a
directory, only the first index level is used.
In the case of the first index structure, the pointer in the file
node points to the first block containing the index entries (an index
may span blocks); the entries at this level point to data elements.
The second index structure points to the first block containing index
entries. Each index entry at this level points to the first block of
an index containing the same number of entries as the previous level.
These index entries contain pointers to data elements. The third
index structure is similar to the previous two but has another level
of indexing before the index containing the data element pointers.
This expansion of index levels produces a tree, where the leaves of
the tree are data elements. The number at each level multiplies
itself by the number of index entries.
To access a data block, it must be determined if it is accessible
directly or through indexing. If direct access is possible, the data
element needs to be determined along with the particular block within
the data element. If the block is deep enough in the file to require
Licensed material--property of copyright holder(s) 1
inode(4) DG/UX 5.4R3.00 inode(4)
indexing, the level of indexing must be determined by finding what
range of blocks each index covers. After the index structure is
determined, the path of entries through the index structure is
required.
The inode table in the DAR is made up of entries of the following
structure:
typedef struct
{
booleanfieldtype isallocated : 1;
booleanfieldtype isfragmented : 1;
fieldtype fragmentsizeexponent : 3;
fieldtype desexponent : 5;
fieldtype iesexponent : 4;
fieldtype padtodoubleword : 9;
fieldtype partialblockbytecount : 9;
uint32etype wholeblockcount;
uint32etype generationnumber;
uint32etype darindex;
dffilenodenumbertype spaceparent;
uint32etype maximumspaceusage;
uint32etype currentspaceusage;
uint32etype maximumfilenodeusage;
uint32etype currentfilenodeusage;
dffilemodetype mode;
uint16etype userid;
uint16etype groupid;
int16etype linkcount;
dftimetype timelastaccessed;
dftimetype timelastmodified;
dftimetype timeattributeslastchanged;
union
{
struct
{
uint32etype data[DFDIRECTELEMENTCOUNT];
union
{
struct
{
uint32etype indexarray[DFMAXDIRINDEXLEVEL];
dfdintype din;
} directory;
struct
{
uint32type indexarray[DFMAXINDEXLEVEL];
} regular;
} index;
} elementaddresses;
struct
{
uint16etype majordevicenumber;
uint16etype minordevicenumber;
Licensed material--property of copyright holder(s) 2
inode(4) DG/UX 5.4R3.00 inode(4)
byte8etype padtounionsize[48];
} representeddevice;
} contents;
byte8etype reserved[DFRESERVEDBYTESPERFILENODE];
} dffilenodetype;
isallocated indicates whether this is a free file node or not. If
FALSE it is a free file node; if TRUE, then this is a valid file
node.
isfragmented is TRUE when the first (and only) element of the file
is reduced in size from the data element size to the fragment size
specified by fragment_size_exponent; otherwise, all data elements (if
any) are the full data element size and fragment_size_exponent is
invalid.
fragmentsizeexponent specifies, when valid, the size of the
fragmented data element which contains the file's data. The size in
blocks of the fragment is 2 raised to the fragment_size_exponent
power. It must be large enough to fit the total size of the file in
the fragment. Because all fragments must fit into a single file
system buffer, the maximum fragment size is:
#define DFMAXFRAGMENTSIZE 16
blocks, although the fragment_size_exponent field is large enough to
support fragment sizes up to 128 (2 ^ 7) blocks.
desexponent specifies the data element size. The data element size
in blocks is 2 raised to the des_exponent power. The maximum data
element size is therefore 2 ^ 31 blocks. The maximum value for this
field is:
#define DFMAXDESEXPONENT 31
although it is also limited to the base 2 logarithm of the largest
power of 2 that is less than or equal to:
#define DFUSERBLOCKSPERDAR(darsize, filenodesperdar)
iesexponent specifies the index element size. The index element
size in blocks is 2 raised to the ies_exponent power. The maximum
index element size is therefore 2 ^ 15 blocks. The maximum value for
this field is:
#define DFMAXIESEXPONENT 15
although it is also limited to the base 2 logarithm of the largest
power of 2 that is less than or equal to:
#define DFUSERBLOCKSPERDAR(darsize, filenodesperdar)
partialblockbytecount is the count of the number of bytes to the
end of file following the last whole block. All possible values,
Licensed material--property of copyright holder(s) 3
inode(4) DG/UX 5.4R3.00 inode(4)
i.e., 0 to 511, are legal.
wholeblockcount is the number of 512 byte blocks logically in the
file before EOF. The file size as reported by stat(2) is:
((wholeblockcount * 512) + partialblockbytecount).
generationnumber is incremented each time an inode is freed and is
kept valid on free nodes so that subsequent uses of the same file
node number are guaranteed to have different UFID values.
darindex is the current allocation hint (index of a DAR to use for
data and file node allocation). DAR indexes are zero based.
spaceparent is the parent file node number. In the file node for
the root of the filesystem, the value of space_parent is:
#define DFROOTFILENODENUMBER 2
therefore, the filesystem root is its own space parent.
maximumspaceusage is the maximum usage limit in blocks for the file
plus all its space descendants. It must be set to UINT32_MAX for
non-CPD directories and other non-directory files, as well as for
CPD's which have no allocation limit. On the root of each
filesystem, this limit is not applied to the superuser.
currentspaceusage is the current usage in blocks for the file plus
all its space descendants, if any. If not a CPD, then it is the
number of blocks actually used to store the file's contents on disk,
including both index and data elements. For a CPD, it is that plus
the current_space_allocation fields of all files which name this CPD
as their space parent.
maximumfilenodeusage is the maximum file node usage limit for the
file plus all its space descendants. Must be UINT32_MAX for non-CPD
directories and other non-directory files, as well as for CPDs with
no file node allocation limit. On the root of each filesystem, this
limit is not applied to the superuser. On all other CPD's it is
applied equally to all users.
currentfilenodeusage is the current file node usage count for the
file plus all its space descendants. It must be 1 for non-CPD
directories and other non-directory files. For a CPD, it is 1 plus
the current_file_node_usage fields of all files which name this CPD
as their space parent.
mode is the file's mode. See stat(2).
userid is user id of the file.
groupid is the group id of the file.
linkcount is the number of links (directory entries) to the file.
Licensed material--property of copyright holder(s) 4
inode(4) DG/UX 5.4R3.00 inode(4)
Must be greater than zero.
timelastaccessed is the time the file's contents were last accessed
(i.e., read or executed).
timelastmodified is the time the file's contents were last modified
(i.e., written or truncated).
timeattributeslastchanged is the time one of the file's attributes
(mode, user_id, group_id, link_count, child_count, etc.) was last
changed.
contents is a union containing represented_device for block-special
or character-special files, and containing element_addresses for all
other file types.
representeddevice is the device numbers of the device represented by
a character or block special file. The padding bytes
(pad_to_union_size) must be set to zero.
elementaddresses are the disk addresses of the data elements and
index elements of the file. The "data" field contains the addresses
of the first:
#define DFDIRECTELEMENTCOUNT 10
data elements in the file. The "index" field contains the addresses
of the first index element of each level for regular files. For
directory files, we only have 1 level of indexing, with the other two
index fields being used to store the directory manager information.
Since all the file nodes in a DAR are not necessarily allocated, a
list of free file nodes must be maintained. The head of the list is
contained in each DAR entry. The DAR entry contains the file node
number of a file node in the DAR, that file node should be
unallocated and the following structure contains the fields for a
free file node:
typedef struct
{
booleanfieldtype isallocated : 1;
dffilenodenumbertype nextfreefilenodenumber;
uint32etype generationnumber;
byte8etype padtofilenodesize[DFFREEFILENODEPADDING];
} dffreefilenodetype;
isallocated is TRUE when this is a valid file_node. If FALSE, then
this is a free file_node.
generationnumber is kept valid on free nodes so that subsequent uses
of the same file node number are guaranteed to have different UFID
values.
nextfreefilenodenumber is the file node number of next free
Licensed material--property of copyright holder(s) 5
inode(4) DG/UX 5.4R3.00 inode(4)
file_node on the DAR free file_node list.
SEE ALSO
stat(2), dgstat(2), fs(4); fsck(1M), mkfs(1M).
Licensed material--property of copyright holder(s) 6