[BACK]Return to bpb.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / fs / msdosfs

File: [cvs.NetBSD.org] / src / sys / fs / msdosfs / bpb.h (download)

Revision 1.8, Fri Jan 22 22:53:36 2016 UTC (5 years, 2 months ago) by dholland
Branch: MAIN
CVS Tags: tls-maxphys-base-20171202, thorpej-futex-base, thorpej-futex, thorpej-cfargs-base, thorpej-cfargs, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, nick-nhusb-base-20170825, nick-nhusb-base-20170204, nick-nhusb-base-20161204, nick-nhusb-base-20161004, nick-nhusb-base-20160907, nick-nhusb-base-20160529, nick-nhusb-base-20160422, nick-nhusb-base-20160319, netbsd-9-base, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, jdolecek-ncq-base, jdolecek-ncq, isaki-audio2-base, isaki-audio2, is-mlppp-base, is-mlppp, bouyer-xenpvh-base2, bouyer-xenpvh-base1, bouyer-xenpvh-base, bouyer-xenpvh, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, ad-namecache-base3, ad-namecache-base2, ad-namecache-base1, ad-namecache-base, ad-namecache, HEAD
Changes since 1.7: +82 -82 lines

u_int{8,16,32}_t -> uint{8,16,32}_t, also u_int -> unsigned and
u_char -> unsigned char.

/*	$NetBSD: bpb.h,v 1.8 2016/01/22 22:53:36 dholland Exp $	*/

/*
 * Written by Paul Popelka (paulp@uts.amdahl.com)
 *
 * You can do anything you want with this software, just don't say you wrote
 * it, and don't remove this notice.
 *
 * This software is provided "as is".
 *
 * The author supplies this software to be publicly redistributed on the
 * understanding that the author is not responsible for the correct
 * functioning of this software in any circumstances and is not liable for
 * any damages caused by this software.
 *
 * October 1992
 */

#ifndef _MSDOSFS_BPB_H_
#define _MSDOSFS_BPB_H_

/*
 * BIOS Parameter Block (BPB) for DOS 3.3
 */
struct bpb33 {
	uint16_t	bpbBytesPerSec;	/* bytes per sector */
	uint8_t		bpbSecPerClust;	/* sectors per cluster */
	uint16_t	bpbResSectors;	/* number of reserved sectors */
	uint8_t		bpbFATs;	/* number of FATs */
	uint16_t	bpbRootDirEnts;	/* number of root directory entries */
	uint16_t	bpbSectors;	/* total number of sectors */
	uint8_t		bpbMedia;	/* media descriptor */
	uint16_t	bpbFATsecs;	/* number of sectors per FAT */
	uint16_t	bpbSecPerTrack;	/* sectors per track */
	uint16_t	bpbHeads;	/* number of heads */
	uint16_t	bpbHiddenSecs;	/* number of hidden sectors */
};

/*
 * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
 * and bpbHugeSectors is not in the 3.3 bpb.
 */
struct bpb50 {
	uint16_t	bpbBytesPerSec;	/* bytes per sector */
	uint8_t		bpbSecPerClust;	/* sectors per cluster */
	uint16_t	bpbResSectors;	/* number of reserved sectors */
	uint8_t		bpbFATs;	/* number of FATs */
	uint16_t	bpbRootDirEnts;	/* number of root directory entries */
	uint16_t	bpbSectors;	/* total number of sectors */
	uint8_t		bpbMedia;	/* media descriptor */
	uint16_t	bpbFATsecs;	/* number of sectors per FAT */
	uint16_t	bpbSecPerTrack;	/* sectors per track */
	uint16_t	bpbHeads;	/* number of heads */
	uint32_t	bpbHiddenSecs;	/* # of hidden sectors */
	uint32_t	bpbHugeSectors;	/* # of sectors if bpbSectors == 0 */
};

/*
 * BPB for DOS 7.10 (FAT32).  This one has a few extensions to bpb50.
 */
struct bpb710 {
	uint16_t	bpbBytesPerSec;	/* bytes per sector */
	uint8_t		bpbSecPerClust;	/* sectors per cluster */
	uint16_t	bpbResSectors;	/* number of reserved sectors */
	uint8_t		bpbFATs;	/* number of FATs */
	uint16_t	bpbRootDirEnts;	/* number of root directory entries */
	uint16_t	bpbSectors;	/* total number of sectors */
	uint8_t		bpbMedia;	/* media descriptor */
	uint16_t	bpbFATsecs;	/* number of sectors per FAT */
	uint16_t	bpbSecPerTrack;	/* sectors per track */
	uint16_t	bpbHeads;	/* number of heads */
	uint32_t	bpbHiddenSecs;	/* # of hidden sectors */
	uint32_t	bpbHugeSectors;	/* # of sectors if bpbSectors == 0 */
	uint32_t	bpbBigFATsecs;	/* like bpbFATsecs for FAT32 */
	uint16_t	bpbExtFlags;	/* extended flags: */
#define	FATNUM		0xf		/* mask for numbering active FAT */
#define	FATMIRROR	0x80		/* FAT is mirrored (like it always was) */
	uint16_t	bpbFSVers;	/* filesystem version */
#define	FSVERS		0		/* currently only 0 is understood */
	uint32_t	bpbRootClust;	/* start cluster for root directory */
	uint16_t	bpbFSInfo;	/* filesystem info structure sector */
	uint16_t	bpbBackup;	/* backup boot sector */
	uint8_t		bpbReserved[12]; /* Reserved for future expansion */
};

#ifdef	atari
/*
 * BPB for GEMDOS filesystems. Atari leaves the obsolete stuff undefined.
 * Currently there is no need for a separate BPB structure.
 */
#if 0
struct bpb_a {
	uint16_t	bpbBytesPerSec;	/* bytes per sector		*/
	uint8_t		bpbSecPerClust;	/* sectors per cluster		*/
	uint16_t	bpbResSectors;	/* number of reserved sectors	*/
	uint8_t		bpbFATs;	/* number of FATs		*/
	uint16_t	bpbRootDirEnts;	/* number of root directory entries */
	uint16_t	bpbSectors;	/* total number of sectors	*/
	uint8_t		bpbUseless1;	/* meaningless on GEMDOS FS	*/
	uint16_t	bpbFATsecs;	/* number of sectors per FAT	*/
	uint16_t	bpbUseless2;	/* meaningless for harddisk fs	*/
	uint16_t	bpbUseless3;	/* meaningless for harddisk fs	*/
	uint16_t	bpbHiddenSecs;	/* the TOS-BIOS ignores this	*/
};
#endif
#endif	/* atari */

/*
 * The following structures represent how the bpb's look on disk.  shorts
 * and longs are just character arrays of the appropriate length.  This is
 * because the compiler forces shorts and longs to align on word or
 * halfword boundaries.
 */

#include <sys/endian.h>

#define	getushort(p)	le16dec(p)
#define	getulong(p)	le32dec(p)
#define	putushort(p, v) le16enc((p), (v))
#define	putulong(p, v)	le32enc((p), (v))

/*
 * BIOS Parameter Block (BPB) for DOS 3.3
 */
struct byte_bpb33 {
	int8_t bpbBytesPerSec[2];	/* bytes per sector */
	int8_t bpbSecPerClust;		/* sectors per cluster */
	int8_t bpbResSectors[2];	/* number of reserved sectors */
	int8_t bpbFATs;			/* number of FATs */
	int8_t bpbRootDirEnts[2];	/* number of root directory entries */
	int8_t bpbSectors[2];		/* total number of sectors */
	int8_t bpbMedia;		/* media descriptor */
	int8_t bpbFATsecs[2];		/* number of sectors per FAT */
	int8_t bpbSecPerTrack[2];	/* sectors per track */
	int8_t bpbHeads[2];		/* number of heads */
	int8_t bpbHiddenSecs[2];	/* number of hidden sectors */
};

/*
 * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
 * and bpbHugeSectors is not in the 3.3 bpb.
 */
struct byte_bpb50 {
	int8_t bpbBytesPerSec[2];	/* bytes per sector */
	int8_t bpbSecPerClust;		/* sectors per cluster */
	int8_t bpbResSectors[2];	/* number of reserved sectors */
	int8_t bpbFATs;			/* number of FATs */
	int8_t bpbRootDirEnts[2];	/* number of root directory entries */
	int8_t bpbSectors[2];		/* total number of sectors */
	int8_t bpbMedia;		/* media descriptor */
	int8_t bpbFATsecs[2];		/* number of sectors per FAT */
	int8_t bpbSecPerTrack[2];	/* sectors per track */
	int8_t bpbHeads[2];		/* number of heads */
	int8_t bpbHiddenSecs[4];	/* number of hidden sectors */
	int8_t bpbHugeSectors[4];	/* # of sectors if bpbSectors == 0 */
};

/*
 * BPB for DOS 7.10 (FAT32).  This one has a few extensions to bpb50.
 */
struct byte_bpb710 {
	uint8_t bpbBytesPerSec[2];	/* bytes per sector */
	uint8_t bpbSecPerClust;		/* sectors per cluster */
	uint8_t bpbResSectors[2];	/* number of reserved sectors */
	uint8_t bpbFATs;		/* number of FATs */
	uint8_t bpbRootDirEnts[2];	/* number of root directory entries */
	uint8_t bpbSectors[2];		/* total number of sectors */
	uint8_t bpbMedia;		/* media descriptor */
	uint8_t bpbFATsecs[2];		/* number of sectors per FAT */
	uint8_t bpbSecPerTrack[2];	/* sectors per track */
	uint8_t bpbHeads[2];		/* number of heads */
	uint8_t bpbHiddenSecs[4];	/* # of hidden sectors */
	uint8_t bpbHugeSectors[4];	/* # of sectors if bpbSectors == 0 */
	uint8_t bpbBigFATsecs[4];	/* like bpbFATsecs for FAT32 */
	uint8_t bpbExtFlags[2];		/* extended flags: */
	uint8_t bpbFSVers[2];		/* filesystem version */
	uint8_t bpbRootClust[4];	/* start cluster for root directory */
	uint8_t bpbFSInfo[2];		/* filesystem info structure sector */
	uint8_t bpbBackup[2];		/* backup boot sector */
	uint8_t bpbReserved[12];	/* Reserved for future expansion */
};

/*
 * FAT32 FSInfo block.
 */
struct fsinfo {
	uint8_t fsisig1[4];
	uint8_t fsifill1[480];
	uint8_t fsisig2[4];
	uint8_t fsinfree[4];
	uint8_t fsinxtfree[4];
	uint8_t fsifill2[12];
	uint8_t fsisig3[4];
	uint8_t fsifill3[508];
	uint8_t fsisig4[4];
};
#endif /* _MSDOSFS_BPB_H_ */