⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fs.h

📁 i386的bootloader源码grub
💻 H
📖 第 1 页 / 共 2 页
字号:
    long fs_state;		/* validate fs_clean field */    int fs_postblformat;	/* format of positional layout tables */    int fs_nrpos;		/* number of rotaional positions */    int fs_postbloff;		/* (short) rotation block list head */    int fs_rotbloff;		/* (u_char) blocks for each rotation */    int fs_magic;		/* magic number */    u_char fs_space[1];		/* list of blocks for each rotation *//* actually longer */  };/* * Preference for optimization. */#define FS_OPTTIME	0	/* minimize allocation time */#define FS_OPTSPACE	1	/* minimize disk fragmentation *//* * Rotational layout table format types */#define FS_42POSTBLFMT		-1	/* 4.2BSD rotational table format */#define FS_DYNAMICPOSTBLFMT	1	/* dynamic rotational table format *//* * Macros for access to superblock array structures */#define fs_postbl(fs, cylno) \    (((fs)->fs_postblformat == FS_42POSTBLFMT) \    ? ((fs)->fs_opostbl[cylno]) \    : ((short *)((char *)(fs) + (fs)->fs_postbloff) + (cylno) * (fs)->fs_nrpos))#define fs_rotbl(fs) \    (((fs)->fs_postblformat == FS_42POSTBLFMT) \    ? ((fs)->fs_space) \    : ((u_char *)((char *)(fs) + (fs)->fs_rotbloff)))/* * Convert cylinder group to base address of its global summary info. * * N.B. This macro assumes that sizeof(struct csum) is a power of two. */#define fs_cs(fs, indx) \	fs_csp[(indx) >> (fs)->fs_csshift][(indx) & ~(fs)->fs_csmask]/* * Cylinder group block for a file system. */#define	CG_MAGIC	0x090255struct cg  {    int xxx1;			/* struct       cg *cg_link; */    int cg_magic;		/* magic number */    mach_time_t cg_time;		/* time last written */    int 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 */    int cg_ndblk;		/* number of data blocks this cg */    struct csum cg_cs;		/* cylinder summary information */    int cg_rotor;		/* position of last used block */    int cg_frotor;		/* position of last used frag */    int cg_irotor;		/* position of last used inode */    int cg_frsum[MAXFRAG];	/* counts of available frags */    int cg_btotoff;		/* (long) block totals per cylinder */    int cg_boff;		/* (short) free block positions */    int cg_iusedoff;		/* (char) used inode map */    int cg_freeoff;		/* (u_char) free block map */    int cg_nextfreeoff;		/* (u_char) next available space */    int cg_sparecon[16];	/* reserved for future use */    u_char cg_space[1];		/* space for cylinder group maps *//* actually longer */  };/* * Macros for access to cylinder group array structures */#define cg_blktot(cgp) \    (((cgp)->cg_magic != CG_MAGIC) \    ? (((struct ocg *)(cgp))->cg_btot) \    : ((int *)((char *)(cgp) + (cgp)->cg_btotoff)))#define cg_blks(fs, cgp, cylno) \    (((cgp)->cg_magic != CG_MAGIC) \    ? (((struct ocg *)(cgp))->cg_b[cylno]) \    : ((short *)((char *)(cgp) + (cgp)->cg_boff) + (cylno) * (fs)->fs_nrpos))#define cg_inosused(cgp) \    (((cgp)->cg_magic != CG_MAGIC) \    ? (((struct ocg *)(cgp))->cg_iused) \    : ((char *)((char *)(cgp) + (cgp)->cg_iusedoff)))#define cg_blksfree(cgp) \    (((cgp)->cg_magic != CG_MAGIC) \    ? (((struct ocg *)(cgp))->cg_free) \    : ((u_char *)((char *)(cgp) + (cgp)->cg_freeoff)))#define cg_chkmagic(cgp) \    ((cgp)->cg_magic == CG_MAGIC || ((struct ocg *)(cgp))->cg_magic == CG_MAGIC)/* * The following structure is defined * for compatibility with old file systems. */struct ocg  {    int xxx1;			/* struct       ocg *cg_link; */    int xxx2;			/* struct       ocg *cg_rlink; */    mach_time_t cg_time;	/* time last written */    int 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 */    int cg_ndblk;		/* number of data blocks this cg */    struct csum cg_cs;		/* cylinder summary information */    int cg_rotor;		/* position of last used block */    int cg_frotor;		/* position of last used frag */    int cg_irotor;		/* position of last used inode */    int cg_frsum[8];		/* counts of available frags */    int cg_btot[32];		/* block totals per cylinder */    short cg_b[32][8];		/* positions of free blocks */    char cg_iused[256];		/* used inode map */    int cg_magic;		/* magic number */    u_char cg_free[1];		/* free block map *//* actually longer */  };/* * Turn file system block numbers into disk block addresses. * This maps file system blocks to device size blocks. */#define fsbtodb(fs, b)	((b) << (fs)->fs_fsbtodb)#define	dbtofsb(fs, b)	((b) >> (fs)->fs_fsbtodb)/* * Cylinder group macros to locate things in cylinder groups. * They calc file system addresses of cylinder group data structures. */#define	cgbase(fs, c)	((mach_daddr_t)((fs)->fs_fpg * (c)))#define cgstart(fs, c) \	(cgbase(fs, c) + (fs)->fs_cgoffset * ((c) & ~((fs)->fs_cgmask)))#define	cgsblock(fs, c)	(cgstart(fs, c) + (fs)->fs_sblkno)	/* super blk */#define	cgtod(fs, c)	(cgstart(fs, c) + (fs)->fs_cblkno)	/* cg block */#define	cgimin(fs, c)	(cgstart(fs, c) + (fs)->fs_iblkno)	/* inode blk */#define	cgdmin(fs, c)	(cgstart(fs, c) + (fs)->fs_dblkno)	/* 1st data *//* * Macros for handling inode numbers: *     inode number to file system block offset. *     inode number to cylinder group number. *     inode number to file system block address. */#define	itoo(fs, x)	((x) % INOPB(fs))#define	itog(fs, x)	((x) / (fs)->fs_ipg)#define	itod(fs, x) \	((mach_daddr_t)(cgimin(fs, itog(fs, x)) + \	(blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs))))))/* * Give cylinder group number for a file system block. * Give cylinder group block number for a file system block. */#define	dtog(fs, d)	((d) / (fs)->fs_fpg)#define	dtogd(fs, d)	((d) % (fs)->fs_fpg)/* * Extract the bits for a block from a map. * Compute the cylinder and rotational position of a cyl block addr. */#define blkmap(fs, map, loc) \    (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - (fs)->fs_frag)))#define cbtocylno(fs, bno) \    ((bno) * NSPF(fs) / (fs)->fs_spc)#define cbtorpos(fs, bno) \    (((bno) * NSPF(fs) % (fs)->fs_spc / (fs)->fs_nsect * (fs)->fs_trackskew + \     (bno) * NSPF(fs) % (fs)->fs_spc % (fs)->fs_nsect * (fs)->fs_interleave) % \     (fs)->fs_nsect * (fs)->fs_nrpos / (fs)->fs_npsect)/* * The following macros optimize certain frequently calculated * quantities by using shifts and masks in place of divisions * modulos and multiplications. */#define blkoff(fs, loc)		/* calculates (loc % fs->fs_bsize) */ \	((loc) & ~(fs)->fs_bmask)#define fragoff(fs, loc)	/* calculates (loc % fs->fs_fsize) */ \	((loc) & ~(fs)->fs_fmask)#define lblkno(fs, loc)		/* calculates (loc / fs->fs_bsize) */ \	((loc) >> (fs)->fs_bshift)#define numfrags(fs, loc)	/* calculates (loc / fs->fs_fsize) */ \	((loc) >> (fs)->fs_fshift)#define blkroundup(fs, size)	/* calculates roundup(size, fs->fs_bsize) */ \	(((size) + (fs)->fs_bsize - 1) & (fs)->fs_bmask)#define fragroundup(fs, size)	/* calculates roundup(size, fs->fs_fsize) */ \	(((size) + (fs)->fs_fsize - 1) & (fs)->fs_fmask)#define fragstoblks(fs, frags)	/* calculates (frags / fs->fs_frag) */ \	((frags) >> (fs)->fs_fragshift)#define blkstofrags(fs, blks)	/* calculates (blks * fs->fs_frag) */ \	((blks) << (fs)->fs_fragshift)#define fragnum(fs, fsb)	/* calculates (fsb % fs->fs_frag) */ \	((fsb) & ((fs)->fs_frag - 1))#define blknum(fs, fsb)		/* calculates rounddown(fsb, fs->fs_frag) */ \	((fsb) &~ ((fs)->fs_frag - 1))/* * Determine the number of available frags given a * percentage to hold in reserve */#define freespace(fs, percentreserved) \	(blkstofrags((fs), (fs)->fs_cstotal.cs_nbfree) + \	(fs)->fs_cstotal.cs_nffree - ((fs)->fs_dsize * (percentreserved) / 100))/* * Determining the size of a file block in the file system. */#define blksize(fs, ip, lbn) \	(((lbn) >= NDADDR || (ip)->i_size >= ((lbn) + 1) << (fs)->fs_bshift) \	    ? (fs)->fs_bsize \	    : (fragroundup(fs, blkoff(fs, (ip)->i_size))))#define dblksize(fs, dip, lbn) \	(((lbn) >= NDADDR || (dip)->di_size >= ((lbn) + 1) << (fs)->fs_bshift) \	    ? (fs)->fs_bsize \	    : (fragroundup(fs, blkoff(fs, (dip)->di_size))))/* * Number of disk sectors per block; assumes DEV_BSIZE byte sector size. */#define	NSPB(fs)	((fs)->fs_nspf << (fs)->fs_fragshift)#define	NSPF(fs)	((fs)->fs_nspf)/* * INOPB is the number of inodes in a secondary storage block. */#define	INOPB(fs)	((fs)->fs_inopb)#define	INOPF(fs)	((fs)->fs_inopb >> (fs)->fs_fragshift)/* * NINDIR is the number of indirects in a file system block. */#define	NINDIR(fs)	((fs)->fs_nindir)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -