From owner-freebsd-bugs@FreeBSD.ORG Fri Dec 24 13:10:12 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D62801065670 for ; Fri, 24 Dec 2010 13:10:12 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 98C718FC18 for ; Fri, 24 Dec 2010 13:10:12 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id oBODACIl066370 for ; Fri, 24 Dec 2010 13:10:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id oBODACZB066369; Fri, 24 Dec 2010 13:10:12 GMT (envelope-from gnats) Resent-Date: Fri, 24 Dec 2010 13:10:12 GMT Resent-Message-Id: <201012241310.oBODACZB066369@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Keith White Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6D8B11065698 for ; Fri, 24 Dec 2010 13:04:43 +0000 (UTC) (envelope-from kwhite@site.uottawa.ca) Received: from courriel.site.uottawa.ca (courriel.site.uottawa.ca [137.122.24.224]) by mx1.freebsd.org (Postfix) with ESMTP id 13ABB8FC16 for ; Fri, 24 Dec 2010 13:04:42 +0000 (UTC) Received: from [192.168.0.22] (dyn-pppoe-69-171-96-47.vianet.ca [69.171.96.47]) (authenticated bits=0) by courriel.site.uottawa.ca (8.14.4/8.14.4) with ESMTP id oBOCmCks053166 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 24 Dec 2010 07:48:13 -0500 (EST) (envelope-from kwhite@site.uottawa.ca) Message-Id: Date: Fri, 24 Dec 2010 07:48:08 -0500 (EST) From: Keith White To: FreeBSD-gnats-submit@FreeBSD.org Cc: Keith White Subject: bin/153426: [patch] fsck_msdosfs only works with sector size 512 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Keith White List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Dec 2010 13:10:13 -0000 >Number: 153426 >Category: bin >Synopsis: [patch] fsck_msdosfs only works with sector size 512 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Fri Dec 24 13:10:11 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Keith White >Release: FreeBSD 9.0-CURRENT i386 >Organization: >Environment: System: FreeBSD demo 9.0-CURRENT FreeBSD 9.0-CURRENT #49: Mon Nov 22 07:00:30 EST 2010 kwhite@demo:/usr/src/obj/usr/src/sys/U100 i386 >Description: It is possible to create and use an msdos filesystem with 2048-byte sectors; but it is not possible to "fsck" it. "fsck_msdosfs" on such a fileystem returns: "could not read boot block (Invalid argument)" >How-To-Repeat: dd if=/dev/zero bs=1m of=msdos.img count=20 MD=`mdconfig -af msdos.img` gnop create -S 2048 -v $MD newfs_msdos -n1 $MD.nop fsck_msdosfs /dev/$MD.nop ** /dev/md4.nop could not read boot block (Invalid argument) ... mount -t msdosfs /dev/$MD.nop /mnt >Fix: The following POC patch uses DIOCGSECTORSIZE instead of a fixed value of DOSBOOTBLOCKSIZE. ============= --- src/sbin/fsck_msdosfs/boot.c.orig 2010-07-03 06:49:57.000000000 -0400 +++ src/sbin/fsck_msdosfs/boot.c 2010-12-24 05:49:09.000000000 -0500 @@ -35,6 +35,7 @@ #include #include #include +#include #include "ext.h" #include "fsutil.h" @@ -47,11 +48,23 @@ u_char backup[DOSBOOTBLOCKSIZE]; int ret = FSOK; int i; + u_char *tblock; + unsigned int sectorsize; - if (read(dosfs, block, sizeof block) != sizeof block) { + if ((ioctl(dosfs, DIOCGSECTORSIZE, §orsize) == -1) || sectorsize < sizeof block) { + printf("** could not get valid device sectorsize, assuming %d\n", sizeof block); + sectorsize = sizeof block; + } + tblock = (u_char *)malloc(sectorsize); + if (read(dosfs, tblock, sectorsize) != sectorsize) { perror("could not read boot block"); return FSFATAL; } + memcpy(block, tblock, sizeof block); + free(tblock); + if (sectorsize != sizeof block) { + printf("** non-standard sectorsize of %d\n", sectorsize); + } if (block[510] != 0x55 || block[511] != 0xaa) { pfatal("Invalid signature in boot block: %02x%02x", ============= >Release-Note: >Audit-Trail: >Unformatted: To: FreeBSD-gnats-submit@freebsd.org Subject: [patch] fsck_msdosfs only works with sector size 512 From: Keith White Reply-To: Keith White Cc: kwhite@uottawa.ca X-send-pr-version: 3.113 X-GNATS-Notify: