Subject: Re: Help porting scan_ffs from OpenBSD
To: None <tech-userlevel@netbsd.org>
From: Juan RP <juan@xtrarom.org>
List: tech-userlevel
Date: 05/25/2005 17:56:26
On Wed, 25 May 2005 17:51:54 +0200
Juan RP <juan@xtrarom.org> wrote:

> 
> Hi, time ago I lost the disklabel on a disk... and no backup, that was
> really bad, having scan_ffs would be really nice.
> 
> It can detect FFSv1 partitions (OpenBSD has not FFSv2 support), so
> after looking if FreeBSD has something like this, I found they have
> scan_ffs in ports.
> 
> But there's a problem with this port, it won't find FFSv2 partitions
> with block size <> 16384. 
> 
> I've found a way to detect partitions with block size == 8192 (no idea
> about other block sizes, I tested only 8192 and 16384).
> 
> The workaround was adding a new flag (-t) which accepts an argument,
> to detect partitions with different block sizes.
> 
> My disklabel look like:
> 
> 16 partitions:
> #        size    offset     fstype [fsize bsize cpg/sgs]
>  a:    132048  51199155     4.2BSD   1024  8192 16512  # (Cyl.  50792*-
> 50923*) b:    525168  51331203       swap                     # (Cyl.
> 50923*-  51444*) c:  81931500  51199155     unused      0     0        #
> (Cyl.  50792*- 132074*) d: 160086528         0     unused      0     0
> # (Cyl.      0 - 158815) e:  51199092        63
> # NTFS                     # (Cyl.      0*-  50792*)
>  f:  12288528  51856371     4.2BSD   2048 16384 27560  # (Cyl.  51444*-
> 63635*) g:   1049328  64144899     4.2BSD   1024  8192 43728  # (Cyl.
> 63635*-  64676*) h:  67936428  65194227     4.2BSD   2048 16384 28824  #
> (Cyl.  64676*- 132074*) i:  26955873 133130655      MSDOS
> # (Cyl. 132074*- 158815)
> 
> Running scanffs with -t 1 detects my partitions with block size = 8192.
> 
> Example:
> 
> $ ./scanffs -l -t 1 -s 51000000 -e 65194227 wd0d
> X: 132048 51199267 4.2BSD 1024 8192 16512 # /
> X: 1049328 64145011 4.2BSD 1024 8192 43728 # /var
> $
> 
> Running scanffs without -t (default value: 2), it detects my partitions
>  with block size = 16384:
> 
> $ ./scanffs -l -s 51000000 -e 133130655 wd0d
> X: 12288528 51856499 4.2BSD 2048 16384 93096 # /usr
> X: 67936428 65194355 4.2BSD 2048 16384 94360 # /home
> $
> 
> I assume that specifying t = 3 or 4 will catch partitions with block size 
> 32K and 64K, respectively.
> 
> I've attached the modified scanffs source, suggestions and fixes for
> this problem are welcome.
> 
> That would be really cool if we have this in the src tree, in the future
> we might use it with sysinst...

Forgot to say... my partitions are FFSv2. Without using -l it will show
if the partition is FFSv1 or FFSv2. (haven't modified yet the label output to
show what FFS kind it is).

Please test and help finishing the port to NetBSD!

Thanks.