Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fsck(1M)

fstatf(2)

fsdb(1M)

inode(4)

mkfs(1M)

mount(2)

statf(2)

FS(4)  —  Stardent Computer Inc.

NAME

fs: file system − format of system volume

SYNOPSIS

#include <sys/types.h>
#include <sys/param.h>
#include <sys/sys5/filsys.h>

DESCRIPTION

This description covers System V file system formats.  Formats for the Fast File System will be included in a later release of this document. 

Every System V file system volume uses a common format for certain vital information.  Every such volume is divided into 512-byte long sectors; sector 0 is unused and is available to contain a bootstrap program or other information.  Sector 1 is the super-block. The format of a super-block is:

structfilsys
{
ushorts_isize;/∗ size in blocks of i-list ∗/
daddr_ts_fsize;/∗ size in blocks of entire volume ∗/
shorts_nfree;/∗ number of addresses in s_free ∗/
daddr_ts_free[NICFREE];/∗ free block list ∗/
shorts_ninode;/∗ number of i-nodes in s_inode ∗/
ushorts_inode[NICINOD];/∗ free i-node list ∗/
chars_flock;/∗ lock during free list manipulation ∗/
chars_ilock;/∗ lock during i-list manipulation ∗/
char  s_fmod; /∗ super block modified flag ∗/
chars_ronly;/∗ mounted read-only flag ∗/
time_ts_time; /∗ last super block update ∗/
shorts_dinfo[4];/∗ device information ∗/
daddr_ts_tfree;/∗ total free blocks∗/
ushorts_tinode;/∗ total free i-nodes ∗/
chars_fname[6];/∗ file system name ∗/
chars_fpack[6];/∗ file system pack name ∗/
longs_fill[12];/∗ ADJUST to make sizeof filsys
be 512 bytes ∗/
longs_state;/∗ file system state ∗/
longs_magic;/∗ magic number to denote new
file system ∗/
longs_type;/∗ type of new file system ∗/
};
#defineFsMAGIC0xfd187e20 /∗ s_magic number ∗/
 #defineFs1b1 /∗ 512-byte block ∗/
#defineFs2b2 /∗ 1024-byte block ∗/
#defineFs8b8 /∗ 4096-byte block ∗/
 #defineFsOKAY0x7c269d38 /∗ s_state: clean ∗/
#defineFsACTIVE0x5e72d81a /∗ s_state: active ∗/
#defineFsBAD0xcb096f43 /∗ s_state: bad root ∗/
#defineFsBADBLK0xbadbc14b /∗ s_state: bad block corrupted it ∗/

s_type indicates the file system type.  Currently, only the 4096-byte file system is supported.  s_magic distinguishes the original 512-byte and 1024-byte oriented file systems from the newer file systems.  If this field is not equal to the magic number, FsMAGIC, the volume is not considered a System V file system; otherwise the s_type field is used.  In the following description, a block is then determined by the type.  Stardent 1500/3000 disk drives are formatted with 1024-byte sectors.  For the 4096-byte system, a block is 4096 bytes or 4 sectors.  The operating system takes care of all conversions from logical block numbers to physical sector numbers. 

s_state indicates the state of the file system.  A cleanly unmounted, not damaged file system is indicated by the FsOKAY state.  After a file system has been mounted for update, the state changes to FsACTIVE.  A special case is used for the root file system.  If the root file system appears damaged at boot time, it is mounted but marked FsBAD.  After a file system has been unmounted, the state reverts to FsOKAY. 

s_isize is the address of the first data block after the i-list; the i-list starts just after the super-block, namely in block 2; thus the i-list is s_isize−2 blocks long. s_fsize is the first block not potentially available for allocation to a file.  These numbers are used by the system to check for bad block numbers; if an “impossible” block number is allocated from the free list or is freed, a diagnostic is written on the on-line console.  Moreover, the free array is cleared, 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 49 numbers of free blocks. s_free[0] is the block number of the head of a chain of blocks constituting the free list. The first long in each free-chain block is the number (up to 50) of free-block numbers listed in the next 50 longs of this chain member. The first of these 50 blocks is the link to the next member of the chain. To allocate a block: decrement s_nfree, and the new block is s_free[s_nfree]. If the new block number is 0, there are no blocks left, so give an error. If s_nfree became 0, read in the block named by the new block number, replace s_nfree by its first word, and copy the block numbers in the next 50 longs into the s_free array.  To free a block, check if s_nfree is 50; 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 number and increment s_nfree.

s_tfree is the total free blocks available in the file system. 

s_ninode is the number of free i-numbers in the s_inode array.  To allocate an i-node: if s_ninode is greater than 0, decrement it and return s_inode[s_ninode]. If it was 0, read the i-list and place the numbers of all free i-nodes (up to 100) into the s_inode array, then try again.  To free an i-node, provided s_ninode is less than 100, place its number into s_inode[s_ninode] and increment s_ninode. If s_ninode is already 100, do not bother to enter the freed i-node into any table.  This list of i-nodes is only to speed up the allocation process; the information as to whether the i-node is really free or not is maintained in the i-node itself. 

s_tinode is the total free i-nodes available in the file system. 

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 likewise 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 read-only flag to indicate write-protection. 

s_time is the last time the super-block of the file system was changed, and is the number of seconds that have elapsed since 00:00 Jan. 1, 1970 (GMT).  During a reboot, the s_time of the super-block for the root file system is used to set the system’s idea of the time. 

s_fname is the name of the file system and s_fpack is the name of the pack. 

I-numbers begin at 1, and the storage for i-nodes begins in block 2.  Also, i-nodes are 64 bytes long.  I-node 1 is reserved for future use.  I-node 2 is reserved for the root directory of the file system, but no other i-number has a built-in meaning.  Each i-node represents one file.  For the format of an i-node and its flags, see inode(4).

SEE ALSO

fsck(1M), fstatf(2), fsdb(1M), inode(4), mkfs(1M), mount(2), statf(2)

September 29, 2021

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