Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ filsys(5) — Ultrix-11 3.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

stat(2)

dir(5)

types(5)

dcheck(8)

icheck(8)

mount(8)

filsys(5)

NAME

filsys, flblk, ino − format of file system volume

SYNTAX

#include <sys/types.h>
#include <sys/flbk.h>
#include <sys/filsys.h>
#include <sys/ino.h>

DESCRIPTION

Every file system storage volume (for example, RL disk, RP disk, HP disk, DECtape reel) has a common format for certain vital information.  Every such volume is divided into a certain number of 1024-byte blocks.  Block 0 is unused and is available to contain a bootstrap program, pack label, or other information. 

Block 1 is the superblock.  The layout of the super block as defined by the include file <sys/filsys.h> is:

 #include<sys/localopts.h>
 /*
 * Structure of the super-block
 */
struct  filsys {
    unsigned short s_isize;  /* size in blocks of i-list */
    daddr_t s_fsize;  /* size in blocks of entire volume */
    short   s_nfree;  /* number of addresses in s_free */
    daddr_t s_free[NICFREE];/* free block list */
    short   s_ninode;  /* number of i-nodes in s_inode */
    ino_t   s_inode[NICINOD];/* free i-node list */
    char    s_flock;  /* lock during free list manipulation */
    char    s_ilock;  /* lock during i-list manipulation */
    char    s_fmod;   /* super block modified flag */
    char    s_ronly;  /* mounted read-only flag */
    time_t  s_time;   /* last super block update */
    daddr_t s_tfree;  /* total free blocks */
    ino_t   s_tinode; /* total free inodes */
    short   s_m;      /* interleave - free list spacing */
    short   s_n;      /* interleave - blocks per cylinder */
    char    s_fname[6];/* file system name */
    char    s_fpack[6];/* file system pack name */
    ino_t   s_lasti;   /* start place for circular search */
    ino_t   s_nbehind; /* est # free inodes before s_lasti */
    char    s_fill[60];/* pad...to 512 bytes (444+60+8) */
    short   s_magic[4];/* identifies new...1K file system */
};
 /*
 * flags to avoid locking problems in alloc, free, ialloc
 */
#defineS_BUSY01/* alloc in progress */
#defineS_WANTED02/* want to alloc */
 /*
 * ULTRIX-11 1K file system ID magic numbers
 */
#defineS_0MAGIC0102464
#defineS_1MAGIC071000
#defineS_2MAGIC02367
#defineS_3MAGIC02343

S_isize is the address of the first block after the ilist, which starts in block 2, just after the superblock.  Thus ilist is s_isize −2 blocks long.  S_fsize is the address of the first block not potentially available for allocation to a file.  These numbers are used by the system to check for bad block addresses.  If an “impossible(rq block address is allocated from the free list or is freed, a diagnostic is written on the on-line console.  Moreover, the free array is cleared, so as to prevent further allocation from a presumably corrupted free list. 

The free list for each volume is maintained as follows.  The s_free array contains, in s_free[1], ... , s_free[s_nfree−1], up to NICFREE free block numbers.  NICFREE is a configuration constant.  S_free[0] is the block address of the head of a chain of blocks constituting the free list.  The layout of each block of the free chain as defined in the include file <sys/fblk.h> is:

struct fblk
{
        int       df_nfree;
        daddr_t   df_free[NICFREE];
};

The fields df_nfree and df_free in a free block are used exactly like s_nfree and s_free in the super block.  To allocate a block: decrement s_nfree, and the new block number is s_free[s_nfree].  If the new block address is 0, there are no blocks left, so give an error.  If s_nfree became 0, read the new block into s_nfree and s_free.  To free a block, check if s_nfree is NICFREE; if so, copy s_nfree and the s_free array into it, write it out, and set s_nfree to 0.  In any event set s_free[s_nfree] to the freed block’s address and increment s_nfree. 

S_ninode is the number of free inumbers in the s_inode array.  To allocate an inode: if s_ninode is greater than 0, decrement it and return s_inode[s_ninode].  If it was 0, read the ilist and place the numbers of all free inodes (up to NICINOD) into the s_inode array, then try again.  To free an inode, provided s_ninode is less than NICINODE, place its number into s_inode[s_ninode] and increment s_ninode.  If s_ninode is already NICINODE, do not bother to enter the freed inode into any table.  This list of inodes is only to speed up the allocation process.  The inode itself maintains information about whether the inode is really free or not. 

S_flock and s_ilock are flags maintained in the core copy of the file system while it is mounted and their values on disk are immaterial.  The value of s_fmod on disk is also immaterial.  It is used as a flag to indicate that the super-block has changed and should be copied to the disk during the next periodic update of file system information.  S_ronly is a write-protection indicator; its disk value is also immaterial. 

S_time is the last time the super-block of the file system was changed.  During a reboot, s_time of the super-block for the root file system is used to set the system’s idea of the time. 

The fields s_tfree, s_tinode, s_fname and s_fpack are not currently maintained. 

I-numbers begin at 1, and the storage for i-nodes begins in block 2.  Inodes are 64 bytes long, so 8 of them fit into a block.  Inode 2 is reserved for the root directory of the file system, but no other i-number has a built-in meaning.  Each inode represents one file.  The format of an inode as given in the include file <sys/ino.h> is:

/*
 * Inode structure as it appears on
 * a disk block.
 */
struct dinode
{
    unsigned short   di_mode; /* mode and type of file */
    short    di_nlink;    /* number of links to file */
    short    di_uid;      /* owner’s user id */
    short    di_gid;      /* owner’s group id */
    off_t    di_size;     /* number of bytes in file */
    char     di_addr[40]; /* disk block addresses */
    time_t   di_atime;    /* time last accessed */
    time_t   di_mtime;    /* time last modified */
    time_t   di_ctime;    /* time created */
};
#ifndef UCB_NKB
#define INOPB    8        /* 8 inodes per block */
/*
 * the 40 address bytes:
 *39 used; 13 addresses
 *of 3 bytes each.
 */
#endif
 #if UCB_NKB  ==  1
#define INOPB    16       /* 16 inodes per BSIZE block */
/*
 *21 of the address bytes are used;
 *7 addresses of 3 bytes each.
 */
#endif

Di_mode tells the kind of file; it is encoded identically to the st_mode field of stat(2).  Di_nlink is the number of directory entries (links) that refer to this i-node.  Di_uid and di_gid are the owner’s user and group IDs.  Size is the number of bytes in the file.  Di_atime and di_mtime are the times of last access and modification of the file contents (read, write or create).  For further information, see times(2).  Di_ctime records the time of last modification to the inode or to the file, and is used to determine whether it should be dumped. 

Special files are recognized by their modes and not by inumber.  A block-type special file is one which can potentially be mounted as a file system.  A character-type special file cannot, though it is not necessarily character-oriented.  For special files, the di_addr field is occupied by the device code.  For further information, see types(5).  The device codes of block and character special files overlap. 

Disk addresses of plain files and directories are kept in the array di_addr packed into 3 bytes each.  The first 10 addresses specify device blocks directly.  The last 3 addresses are singly, doubly, and triply indirect and point to blocks of 128 block pointers.  Pointers in indirect blocks have the type daddr_t.  For further information, see types(5). 

For block b in a file to exist, it is not necessary that all blocks less than b exist.  A zero block number either in the address words of the i-node or in an indirect block indicates that the corresponding block has never been allocated.  Such a missing block reads as if it contained all zero words. 

SEE ALSO

stat(2), dir(5), types(5), dcheck(8), icheck(8), mount(8)
ULTRIX-11 System Management Guide

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026