fs(4) fs(4)
NAME
fs (ufs) - format of ufs file system volume
SYNOPSIS
#include <sys/param.h>
#include <sys/types.h>
#include <sys/fs/ufsfs.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 FSMAGIC 0x011954
#define FSACTIVE 0x5e72d81a /* fsstate: mounted */
#define FSOKAY 0x7c269d38 /* fsstate: clean */
#define FSBAD 0xcb096f43 /* fsstate: bad root */
struct fs {
struct fs *fslink; /* linked list of file systems */
struct fs *fsrlink; /* used for incore super blocks */
daddrt fssblkno; /* addr of super-block in filesys */
daddrt fscblkno; /* offset of cyl-block in filesys */
daddrt fsiblkno; /* offset of inode-blocks in filesys */
daddrt fsdblkno; /* offset of first data after cg */
long fscgoffset; /* cylinder group offset in cylinder */
long fscgmask; /* used to calc mod fsntrak */
timet fstime; /* last time written */
long fssize; /* number of blocks in fs */
long fsdsize; /* number of data blocks in fs */
long fsncg; /* number of cylinder groups */
long fsbsize; /* size of basic blocks in fs */
long fsfsize; /* size of frag blocks in fs */
long fsfrag; /* number of frags in a block in fs */
/* these are configuration parameters */
long fsminfree; /* minimum percentage of free blocks */
long fsrotdelay; /* num of ms for optimal next block */
long fsrps; /* disk revolutions per second */
/* these fields can be computed from the others */
long fsbmask; /* ``blkoff'' calc of blk offsets */
long fsfmask; /* ``fragoff'' calc of frag offsets */
1
fs(4) fs(4)
long fsbshift; /* ``lblkno'' calc of logical blkno */
long fsfshift; /* ``numfrags'' calc number of frags */
/* these are configuration parameters */
long fsmaxcontig; /* max number of contiguous blks */
long fsmaxbpg; /* max number of blks per cyl group */
/* these fields can be computed from the others */
long fsfragshift; /* block to frag shift */
long fsfsbtodb; /* fsbtodb and dbtofsb shift constant */
long fssbsize; /* actual size of super block */
long fscsmask; /* csum block offset */
long fscsshift; /* csum block number */
long fsnindir; /* value of NINDIR */
long fsinopb; /* value of INOPB */
long fsnspf; /* value of NSPF */
long fsoptim; /* optimization preference, see below */
long fsstate; /* fiel system state */
long fssparecon[2]; /* reserved for future constants */
/* a unique id for this filesystem (currently unused and unmaintained) */
long fsid[2]; /* file system id */
/* sizes determined by number of cylinder groups and their sizes */
daddrt fscsaddr; /* blk addr of cyl grp summary area */
long fscssize; /* size of cyl grp summary area */
long fscgsize; /* cylinder group size */
/* these fields should be derived from the hardware */
long fsntrak; /* tracks per cylinder */
long fsnsect; /* sectors per track */
long fsspc; /* sectors per cylinder */
/* this comes from the disk driver partitioning */
long fsncyl; /* cylinders in file system */
/* these fields can be computed from the others */
long fscpg; /* cylinders per group */
long fsipg; /* inodes per group */
long fsfpg; /* blocks per group * fsfrag */
/* this data must be re-computed after crashes */
struct csum fscstotal; /* cylinder summary information */
/* these fields are cleared at mount time */
char fsfmod; /* super block modified flag */
char fsclean; /* file system is clean flag */
char fsronly; /* mounted read-only flag */
char fsflags; /* currently unused flag */
char fsfsmnt[MAXMNTLEN]; /* name mounted on */
/* these fields retain the current block allocation info */
long fscgrotor; /* last cg searched */
struct csum *fscsp[MAXCSBUFS];/* list of fscs info buffers */
long fscpc; /* cyl per cycle in postbl */
short fspostbl[MAXCPG][NRPOS];/* head of blocks for each rotation */
long fsmagic; /* magic number */
uchar fsrotbl[1]; /* list of blocks for each rotation */
};
/*
* Cylinder group block for a file system.
2
fs(4) fs(4)
*/
#define CGMAGIC 0x090255
struct cg {
struct cg *cglink; /* linked list of cyl groups */
struct cg *cgrlink; /* used for incore cyl groups */
timet cgtime; /* time last written */
long cgcgx; /* we are the cgx'th cylinder group */
short cgncyl; /* number of cyl's this cg */
short cgniblk; /* number of inode blocks this cg */
long cgndblk; /* number of data blocks this cg */
struct csum cgcs; /* cylinder summary information */
long cgrotor; /* position of last used block */
long cgfrotor; /* position of last used frag */
long cgirotor; /* position of last used inode */
long cgfrsum[MAXFRAG]; /* counts of available frags */
long cgbtot[MAXCPG]; /* block totals per cylinder */
short cgb[MAXCPG][NRPOS]; /* positions of free blocks */
char cgiused[MAXIPG/NBBY]; /* used inode map */
long cgmagic; /* magic number */
uchar cgfree[1]; /* free block map */
};
SEE ALSO
ufs-specific inode(4)
3