Subject: dosfs,disklabel,calculation
To: None <port-i386@NetBSD.ORG>
From: Hiroyuki Ito <hiroy@netcom.com>
List: port-i386
Date: 04/26/1996 08:01:29
Question:
% disklabel sd0 | egrep '^#|^ [cdgh]:'
# /dev/rsd0d:
# size offset fstype [fsize bsize cpg]
c: 3686400 491520 unused 0 0 # (Cyl. 240 - 2039)
d: 4177920 0 unused 0 0 # (Cyl. 0 - 2039)
g: 245728 32 MSDOS # (Cyl. 0*- 119*)
h: 245728 245792 MSDOS # (Cyl. 120*- 239*)
%
Where do the size/offset of g: come from?
Where do the size/offset of h: come from?
Answer:
% dd if=/dev/sd0d of=mbr count=1
1+0 records in
1+0 records out
512 bytes transferred in 1 secs (512 bytes/sec)
% sed -n 42,65p /usr/include/machine/disklabel.h
#define DOSBBSECTOR 0 /* DOS boot block relative sector # */
#define DOSPARTOFF 446
#define NDOSPART 4
struct dos_partition {
unsigned char dp_flag; /* bootstrap flags */
unsigned char dp_shd; /* starting head */
unsigned char dp_ssect; /* starting sector */
unsigned char dp_scyl; /* starting cylinder */
unsigned char dp_typ; /* partition type (see below) */
unsigned char dp_ehd; /* end head */
unsigned char dp_esect; /* end sector */
unsigned char dp_ecyl; /* end cylinder */
unsigned long dp_start; /* absolute starting sector number */
unsigned long dp_size; /* partition size in sectors */
} dos_partitions[NDOSPART];
/* Known DOS partition types. */
#define DOSPTYP_386BSD 0xa5 /* 386BSD partition type */
#define DOSPTYP_NETBSD DOSPTYP_386BSD /* NetBSD partition type (XXX) */
#define DOSPTYP_FAT12 0x1 /* 12-bit FAT */
#define DOSPTYP_FAT16S 0x4 /* 16-bit FAT, less than 32M */
#define DOSPTYP_FAT16B 0x6 /* 16-bit FAT, more than 32M */
#define DOSPTYP_FAT16C 0xe /* 16-bit FAT, CHS-mapped */
% hexdump -s 446 -e '"%06_ax:" 8/1 " %02x" 2/4 " %8d" "\n"' mbr
0001be: 00 01 01 00 06 3f 20 77 32 245728
0001ce: 00 00 01 78 05 3f 20 ef 245760 245760
0001de: 00 00 00 00 00 00 00 00 0 0
0001ee: 80 00 01 f0 a5 3f e0 fe 491520 1603584
0001fe: 55 aa
% dd if=/dev/sd0d of=ext skip=245760 count=1
1+0 records in
1+0 records out
512 bytes transferred in 1 secs (512 bytes/sec)
% hexdump -v -s 446 -e '"%06_ax:" 8/1 " %02x" 2/4 " %8d" "\n"' ext
0001be: 00 01 01 78 06 3f 20 ef 32 245728
0001ce: 00 00 00 00 00 00 00 00 0 0
0001de: 00 00 00 00 00 00 00 00 0 0
0001ee: 00 00 00 00 00 00 00 00 0 0
0001fe: 55 aa
% echo 245760+32 | bc
245792
%
Hiroyuki Ito