Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Aug 2001 17:57:28 +0100
From:      Ian Dowse <iedowse@maths.tcd.ie>
To:        Igor Shmukler <shmukler@mail.ru>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: another FFS question 
Message-ID:   <200108121757.aa23922@salmon.maths.tcd.ie>
In-Reply-To: Your message of "Sun, 12 Aug 2001 12:06:45 EDT." <003901c12348$cac65ea0$7b02a8c0@tp600e> 

next in thread | previous in thread | raw e-mail | index | archive | help

In message <003901c12348$cac65ea0$7b02a8c0@tp600e>, Igor Shmukler writes:
>Since it was only intended to run once, so I didn't check whether malloc
>would fail.

That's fine, though you should at least ktrace the program to
check that all system calls succeeded before trusting the output.

>Regarding inappropriate cast, I did get warning, but for cylinder 0 head 1
>sector 1 int and long long should yield same results.

In general this is not true at all; passing an int instead of a
long long will fill the high 32 bits of the long long with junk
from the stack, and can mess up other arguments. However in this
case I hadn't noticed that the SBOFF macro includes an (off_t)
cast, so it might have actually worked.

>I actually dumped partition and came up with following:
>I got 2 versions of FreeBSD installed on 2 different boxes.
>On FBSD 2.2 sectors 17,18 and 19 are 0x00 filled.
>On FBSD 4.3 same sectors seem to contain the FS structure, but still no
>FS_MAGIC present.

You must be looking in the wrong place on the disk; every ffs
filesystem does have a superblock containing FS_MAGIC, and this is
checked by the ffs mount code, by fsck and by any other filesystem
utilities.

Are you sure you are taking the offset of the start of the partition
into account? For a raw disk, you need to read the DOS slice table
and determine the start of the FreeBSD slice, and then read the
disklabel in that slice to find the partitions. Normally the 'a'
partition would begin right at the start of the FreeBSD slice,
but nothing stops you from putting it elsewhere. Try looking at the
raw disk/slice/partition with hd:

	hd /dev/ad0 | less
	hd /dev/ad0s1 | less
	hd /dev/ad0s1a | less

In the first case (ad0), the MBR partition table starts at 0x1be,
so you'd have to read that to determine where the slices start.

For ad0s1, the disklabel should appear at 0x200.

Finally, for ad0s1a (which on a slice beginning with the 'a' partition
starts at the same place as ad0s1), the superblock can be found at
0x2000, with the FS_MAGIC visable at 0x255c.

>Is FS_MAGIC signature mandatory for FFS?

Yes.

Ian

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-fs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200108121757.aa23922>