From owner-freebsd-current@FreeBSD.ORG Thu Jul 23 15:22:28 2009 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0F086106566B for ; Thu, 23 Jul 2009 15:22:28 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from 0.mx.codelabs.ru (0.mx.codelabs.ru [144.206.177.45]) by mx1.freebsd.org (Postfix) with ESMTP id B10BA8FC13 for ; Thu, 23 Jul 2009 15:22:27 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) DomainKey-Signature: a=rsa-sha1; q=dns; c=simple; s=one; d=codelabs.ru; h=Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:Sender; b=DQo7q0D0Hhfi0+4kQVbCyawPvGIw6mYjZiKUocD4lhDoQJErL4WhNlWL4amXNnpR7VrCwpcODnLfzlkgeG+uez5oFRkPYbWr8+dLLlexUHPFSlsYfhscoAuGu7JDoKCGaV4DWNjJUjGiJm+VP2qXt8gOkILsgf+4Nb6QBeebUyU=; Received: from void.codelabs.ru (void.codelabs.ru [144.206.177.25]) by 0.mx.codelabs.ru with esmtpsa (TLSv1:AES256-SHA:256) id 1MU07m-000PxV-K1; Thu, 23 Jul 2009 19:22:26 +0400 Date: Thu, 23 Jul 2009 19:22:24 +0400 From: Eygene Ryabinkin To: Alexander Best Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: rea-fbsd@codelabs.ru Cc: freebsd-current@FreeBSD.org Subject: Re: possible bug in sbin/fsck_msdosfs/boot.c X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: rea-fbsd@codelabs.ru List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jul 2009 15:22:28 -0000 Alexander, good day. Thu, Jul 23, 2009 at 12:29:23PM +0200, Alexander Best wrote: > i just tried to do fsck_msdosfs on my mobile phone's memory card using a usb > connection cable. this is what `file -s` has to say about /dev/da0: > > /dev/da0: x86 boot sector, code offset 0x0, OEM-ID " ", sectors/cluster > 64, reserved sectors 6304, Media descriptor 0xf8, heads 128, hidden sectors > 8192, sectors 7736320 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 944, > reserved3 0x800000, serial number 0x34613466, label: "mem " > > however after issuing the command `fsck_msdosfs /dev/da0` i got the following > error: > > fsck_msdosfs /dev/da0 > ** /dev/da0 > backup doesn't compare to primary bootblock > > i did a bit of research and it seems this bug was supposed to be fixed by > r128463. the problem was that the entire bootblock was compared to the > backupblock. but since only the first 52 bytes of the bootblock are important > many device use the rest of the bootblock for some other purpose. the > following change was made to sbin/fsck_msdosfs/boot.c: > > -- if (memcmp(block, backup, DOSBOOTBLOCKSIZE)) { > ++ if (memcmp(block + 11, backup + 11, 79)) { > > it seems however that the last memcmp argument is still too high. could > somebody with good fat12/16/32 knowledge please look into this? 79 looks sane for the FAT32, see http://www.win.tue.nl/~aeb/linux/fs/fat/fat-1.html For FAT16/FAT12 the size should be 51. Actually, what is now compared is the BIOS parameter block. I'll take a look at the FS forensics book: my memory blocks with FAT remniscents are a bit rusty ;)) -- Eygene _ ___ _.--. # \`.|\..----...-'` `-._.-'_.-'` # Remember that it is hard / ' ` , __.--' # to read the on-line manual )/' _/ \ `-_, / # while single-stepping the kernel. `-'" `"\_ ,_.-;_.-\_ ', fsc/as # _.-'_./ {_.' ; / # -- FreeBSD Developers handbook {_.-``-' {_/ #