NetBSD Problem Report #46743

From christos@zoulas.com  Tue Jul 24 20:34:02 2012
Return-Path: <christos@zoulas.com>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id CCFCE63B85F
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 24 Jul 2012 20:34:01 +0000 (UTC)
Message-Id: <20120724203357.7B36997124@rebar.astron.com>
Date: Tue, 24 Jul 2012 20:33:57 +0000 (UTC)
From: christos@zoulas.com
Reply-To: christos@zoulas.com
To: gnats-bugs@gnats.NetBSD.org
Subject: newfs_msdos produces filesystems that fsck_msdos does not like
X-Send-Pr-Version: 3.95

>Number:         46743
>Category:       bin
>Synopsis:       newfs_msdos produces filesystems that fsck_msdos does not like
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 24 20:35:00 +0000 2012
>Closed-Date:    Sun Jan 05 12:59:46 +0000 2014
>Last-Modified:  Sun Jan 05 12:59:46 +0000 2014
>Originator:     Christos Zoulas
>Release:        NetBSD 5.99.59
>Organization:
	Entropists Anonymous
>Environment:
System: NetBSD rebar.astron.com 5.99.59 NetBSD 5.99.59 (GENERIC) #7: Fri Dec 30 15:19:49 EST 2011 christos@rebar.astron.com:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
	As mentioned on the command line
>How-To-Repeat:
[4:22pm] 2534>dd if=/dev/zero of=msdos seek=31259071 count=1
1+0 records in
1+0 records out
512 bytes transferred in 0.001 secs (512000 bytes/sec)
[4:22pm] 2535>su -m
[4:22pm] 2507#vnconfig vnd0 msdos
[4:22pm] 2508#newfs_msdos /dev/rvnd0d
/dev/rvnd0d: 31251392 sectors in 488303 FAT32 clusters (32768 bytes/cluster)
MBR type: 11
bps=512 spc=64 res=32 nft=2 mid=0xf0 spt=32 hds=64 hid=0 bsec=31259072 bspf=3815 rdcl=2 infs=1 bkbs=2
[4:23pm] 2509#fsck_msdos /dev/rvnd0d
** /dev/rvnd0d
** Phase 1 - Read and Compare FATs
** Phase 2 - Check Cluster Chains
** Phase 3 - Checking Directories
** Phase 4 - Checking for Lost Files
Free space in FSInfo block (-1) not correct (488302)
fix? [yn] y
Next free cluster in FSInfo block (2) not free
fix? [yn] y
1 files, 3042752 free (488302 clusters)
[4:23pm] 2510#

>Fix:
?

>Release-Note:

>Audit-Trail:
From: "Nicolas Joly" <njoly@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46743 CVS commit: src
Date: Sat, 28 Jul 2012 16:08:40 +0000

 Module Name:	src
 Committed By:	njoly
 Date:		Sat Jul 28 16:08:40 UTC 2012

 Modified Files:
 	src/distrib/sets/lists/tests: mi
 	src/etc/mtree: NetBSD.dist.tests
 	src/tests/sbin: Makefile
 Added Files:
 	src/tests/sbin/newfs_msdos: Makefile t_create.sh

 Log Message:
 Add testcase for PR/46743


 To generate a diff of this commit:
 cvs rdiff -u -r1.480 -r1.481 src/distrib/sets/lists/tests/mi
 cvs rdiff -u -r1.79 -r1.80 src/etc/mtree/NetBSD.dist.tests
 cvs rdiff -u -r1.5 -r1.6 src/tests/sbin/Makefile
 cvs rdiff -u -r0 -r1.1 src/tests/sbin/newfs_msdos/Makefile \
     src/tests/sbin/newfs_msdos/t_create.sh

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/46743: suggested patch for second part
Date: Sat, 7 Dec 2013 23:31:23 +0100

 --MGYHOYXEY6WxJCY8
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 The patch below marks the "next free cluster" in the file system info
 block as uninitialized, which make fsck_msdos happy and should be
 generally ok.

 An alternative is to mark cluster bpb.rdcl as 0 (i.e. free) in the
 loop initializing the fats, but that code is ... "slightly" ugly:

             } else if (lsn >= bpb.res && lsn < dir &&
                        !((lsn - bpb.res) %
                          (bpb.spf ? bpb.spf : bpb.bspf))) {
                 mk1(img[0], bpb.mid);
                 for (x = 1; x < o.fat_type * (o.fat_type == 32 ? 3U : 2U) / 8U; x++)
                     mk1(img[x], o.fat_type == 32 && x % 4 == 3 ? 0x0f : 0xff);

 Maybe just leave that loop alone and clear a few bytes afterwards conditional
 on

 	if (o.fat_type == 32 && bpb.infs != MAXU16)

 However, the suggested patch is a lot simpler and I don't see any downsides.

 Martin

 --MGYHOYXEY6WxJCY8
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=patch

 Index: mkfs_msdos.c
 ===================================================================
 RCS file: /cvsroot/src/sbin/newfs_msdos/mkfs_msdos.c,v
 retrieving revision 1.8
 diff -u -p -r1.8 mkfs_msdos.c
 --- mkfs_msdos.c	19 Oct 2013 01:09:59 -0000	1.8
 +++ mkfs_msdos.c	7 Dec 2013 22:04:08 -0000
 @@ -709,7 +709,7 @@ mkfs_msdos(const char *fname, const char
  		mk4(img, 0x41615252);
  		mk4(img + MINBPS - 28, 0x61417272);
  		mk4(img + MINBPS - 24, 0xffffffff);
 -		mk4(img + MINBPS - 20, bpb.rdcl);
 +		mk4(img + MINBPS - 20, 0xffffffff);
  		mk2(img + MINBPS - 2, DOSMAGIC);
  	    } else if (lsn >= bpb.res && lsn < dir &&
  		       !((lsn - bpb.res) %

 --MGYHOYXEY6WxJCY8--

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46743 CVS commit: src/sbin/newfs_msdos
Date: Sun, 5 Jan 2014 12:52:40 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun Jan  5 12:52:39 UTC 2014

 Modified Files:
 	src/sbin/newfs_msdos: mkfs_msdos.c

 Log Message:
 PR bin/46743: mark the "next free cluster" value in the file system
 info block as unitialized.


 To generate a diff of this commit:
 cvs rdiff -u -r1.8 -r1.9 src/sbin/newfs_msdos/mkfs_msdos.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Sun, 05 Jan 2014 12:59:46 +0000
State-Changed-Why:
Should be fixed


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.