Subject: Adding scan_ufs (scan_ffs replacement, now with LFS support)
To: None <tech-userlevel@netbsd.org>
From: Juan RP <juan@xtrarom.org>
List: tech-userlevel
Date: 07/29/2005 15:02:29
This is a multi-part message in MIME format.
--Multipart=_Fri__29_Jul_2005_15_02_29_+0200_EjXBa0.tso1DO8LU
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Hi there!
Finally, I've added LFS support into the scan_ffs(8) program, but
now that it can detect both filesystems (FFS/LFS), I'd want to
import scan_ufs and remove the current scan_ffs.
An example of using scan_ufs:
[juan@Nocturno][~/scan_ufs]> ./scan_ufs -l -s 51199155 wd0
Disk: Maxtor 6Y080M0
Total sectors on disk: 160086528
# size offset fstype [fsize bsize cpg/sgs]
X: 132048 51199155 4.2BSD 1024 8192 0 # / [FFSv2]
X: 12288528 51856371 4.4LFS 1024 8192 6000 # /usr [LFSv2]
X: 1049328 64144899 4.4LFS 1024 8192 512 # /var [LFSv2]
X: 67936428 65194227 4.4LFS 1024 8192 33172 # /home [LFSv2]
[juan@Nocturno][~/scan_ufs]>
--Multipart=_Fri__29_Jul_2005_15_02_29_+0200_EjXBa0.tso1DO8LU
Content-Type: application/octet-stream;
name="scan_ufs.c"
Content-Disposition: attachment;
filename="scan_ufs.c"
Content-Transfer-Encoding: base64
LyoKICogQ29weXJpZ2h0IChjKSAyMDA1IFRoZSBOZXRCU0QgRm91bmRhdGlvbiwgSW5jLgogKiBB
bGwgcmlnaHRzIHJlc2VydmVkLgogKgogKiBUaGlzIGNvZGUgaXMgZGVyaXZlZCBmcm9tIHNvZnR3
YXJlIGNvbnRyaWJ1dGVkIHRvIFRoZSBOZXRCU0QgRm91bmRhdGlvbgogKiBieSBKdWFuIFJvbWVy
byBQYXJkaW5lcy4KICoKICogUmVkaXN0cmlidXRpb24gYW5kIHVzZSBpbiBzb3VyY2UgYW5kIGJp
bmFyeSBmb3Jtcywgd2l0aCBvciB3aXRob3V0CiAqIG1vZGlmaWNhdGlvbiwgYXJlI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