fs(4) —
NAME
fs (ufs) − format of ufs file system volume
SYNOPSIS
#include <sys/param.h>
#include <sys/types.h>
#include <sys/fs/ufs_fs.h>
DESCRIPTION
Each disk drive contains some number of file systems. A file system consists of a number of cylinder groups. Each cylinder group has inodes and data.
A file system is described by its super-block, and by the information in the cylinder group blocks. The super-block is critical data and is replicated before each cylinder group block to protect against catastrophic loss. This is done at mkfs time; the critical super-block data does not change, so the copies need not normally be referenced further.
/∗
∗ Super block for a file system.
∗/
#define FS_MAGIC 0x011954
#define FSACTIVE 0x5e72d81a /∗ fs_state: mounted ∗/
#define FSOKAY 0x7c269d38 /∗ fs_state: clean ∗/
#define FSBAD 0xcb096f43/∗ fs_state: bad root ∗/
struct fs {
struct fs ∗fs_link;/∗ linked list of file systems ∗/
struct fs ∗fs_rlink;/∗ used for incore super blocks ∗/
daddr_t fs_sblkno;/∗ addr of super-block in filesys ∗/
daddr_t fs_cblkno;/∗ offset of cyl-block in filesys ∗/
daddr_t fs_iblkno;/∗ offset of inode-blocks in filesys ∗/
daddr_t fs_dblkno;/∗ offset of first data after cg ∗/
long fs_cgoffset;/∗ cylinder group offset in cylinder ∗/
long fs_cgmask;/∗ used to calc mod fs_ntrak ∗/
time_t fs_time;/∗ last time written ∗/
long fs_size;/∗ number of blocks in fs ∗/
long fs_dsize;/∗ number of data blocks in fs ∗/
long fs_ncg;/∗ number of cylinder groups ∗/
long fs_bsize;/∗ size of basic blocks in fs ∗/
long fs_fsize;/∗ size of frag blocks in fs ∗/
long fs_frag;/∗ number of frags in a block in fs ∗/
/∗ these are configuration parameters ∗/
long fs_minfree;/∗ minimum percentage of free blocks ∗/
long fs_rotdelay;/∗ num of ms for optimal next block ∗/
long fs_rps;/∗ disk revolutions per second ∗/
/∗ these fields can be computed from the others ∗/
long fs_bmask;/∗ “blkoff” calc of blk offsets ∗/
long fs_fmask;/∗ “fragoff” calc of frag offsets ∗/
long fs_bshift;/∗ “lblkno” calc of logical blkno ∗/
long fs_fshift;/∗ “numfrags” calc number of frags ∗/
/∗ these are configuration parameters ∗/
long fs_maxcontig;/∗ max number of contiguous blks ∗/
long fs_maxbpg;/∗ max number of blks per cyl group ∗/
/∗ these fields can be computed from the others ∗/
long fs_fragshift;/∗ block to frag shift ∗/
long fs_fsbtodb;/∗ fsbtodb and dbtofsb shift constant ∗/
long fs_sbsize;/∗ actual size of super block ∗/
long fs_csmask;/∗ csum block offset ∗/
long fs_csshift;/∗ csum block number ∗/
long fs_nindir;/∗ value of NINDIR ∗/
long fs_inopb;/∗ value of INOPB ∗/
long fs_nspf;/∗ value of NSPF ∗/
long fs_optim;/∗ optimization preference, see below ∗/
long fs_state;/∗ file system state ∗/
long fs_sparecon[2];/∗ reserved for future constants ∗/
/∗ a unique id for this filesystem (currently unused and unmaintained) ∗/
long fs_id[2];/∗ file system id ∗/
/∗ sizes determined by number of cylinder groups and their sizes ∗/
daddr_t fs_csaddr;/∗ blk addr of cyl grp summary area ∗/
long fs_cssize;/∗ size of cyl grp summary area ∗/
long fs_cgsize;/∗ cylinder group size ∗/
/∗ these fields should be derived from the hardware ∗/
long fs_ntrak;/∗ tracks per cylinder ∗/
long fs_nsect;/∗ sectors per track ∗/
long fs_spc;/∗ sectors per cylinder ∗/
/∗ this comes from the disk driver slicing ∗/
long fs_ncyl;/∗ cylinders in file system ∗/
/∗ these fields can be computed from the others ∗/
long fs_cpg;/∗ cylinders per group ∗/
long fs_ipg;/∗ inodes per group ∗/
long fs_fpg;/∗ blocks per group ∗ fs_frag ∗/
/∗ this data must be re-computed after crashes ∗/
struct csum fs_cstotal;/∗ cylinder summary information ∗/
/∗ these fields are cleared at mount time ∗/
char fs_fmod;/∗ super block modified flag ∗/
char fs_clean;/∗ file system is clean flag ∗/
char fs_ronly;/∗ mounted read-only flag ∗/
char fs_flags;/∗ currently unused flag ∗/
char fs_fsmnt[MAXMNTLEN]; /∗ name mounted on ∗/
/∗ these fields retain the current block allocation info ∗/
long fs_cgrotor;/∗ last cg searched ∗/
struct csum ∗fs_csp[MAXCSBUFS]; /∗ list of fs_cs info buffers ∗/
long fs_cpc;/∗ cyl per cycle in postbl ∗/
short fs_postbl[MAXCPG][NRPOS]; /∗ head of blocks for each rotation ∗/
long fs_magic;/∗ magic number ∗/
u_char fs_rotbl[1];/∗ list of blocks for each rotation ∗/
};
/∗
∗ Cylinder group block for a file system.
∗/
#define CG_MAGIC 0x090255
struct cg {
struct cg ∗cg_link;/∗ linked list of cyl groups ∗/
struct cg ∗cg_rlink;/∗ used for incore cyl groups ∗/
time_t cg_time;/∗ time last written ∗/
long cg_cgx;/∗ we are the cgx’th cylinder group ∗/
short cg_ncyl;/∗ number of cyl’s this cg ∗/
short cg_niblk;/∗ number of inode blocks this cg ∗/
long cg_ndblk;/∗ number of data blocks this cg ∗/
struct csum cg_cs;/∗ cylinder summary information ∗/
long cg_rotor;/∗ position of last used block ∗/
long cg_frotor;/∗ position of last used frag ∗/
long cg_irotor;/∗ position of last used inode ∗/
long cg_frsum[MAXFRAG]; /∗ counts of available frags ∗/
long cg_btot[MAXCPG];/∗ block totals per cylinder ∗/
short cg_b[MAXCPG][NRPOS]; /∗ positions of free blocks ∗/
char cg_iused[MAXIPG/NBBY]; /∗ used inode map ∗/
long cg_magic;/∗ magic number ∗/
u_char cg_free[1];/∗ free block map ∗/
};
SEE ALSO
ufs-specific inode(4)
— UFS