NetBSD Problem Report #40360

From jmcneill@black.invisible.ca  Sat Jan 10 19:21:28 2009
Return-Path: <jmcneill@black.invisible.ca>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 4965C63B8BA
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 10 Jan 2009 19:21:28 +0000 (UTC)
Message-Id: <20090110192115.679607D8E70@black.invisible.ca>
Date: Sat, 10 Jan 2009 14:21:15 -0500 (EST)
From: jmcneill@invisible.ca
Reply-To: jmcneill@invisible.ca
To: gnats-bugs@gnats.NetBSD.org
Subject: fictitious disklabels do not handle devices without an MBR
X-Send-Pr-Version: 3.95

>Number:         40360
>Category:       kern
>Synopsis:       fictitious disklabels do not handle devices without an MBR
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 10 19:25:00 +0000 2009
>Last-Modified:  Sat Jan 10 23:10:02 +0000 2009
>Originator:     Jared D. McNeill
>Release:        NetBSD 5.99.5
>Organization:

>Environment:


System: NetBSD black.invisible.ca 5.99.5 NetBSD 5.99.5 (GENERIC) #44: Thu Jan 8 07:01:09 EST 2009 jmcneill@black.invisible.ca:/export/home/jmcneill/branches/HEAD/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
	When inserting a USB device that only contains a FAT filesystems,
	the auto-generated disklabel incorrectly reports a 4.2BSD filesystem
	at the beginning of the device.
>How-To-Repeat:
	$ dd if=/dev/zero of=/tmp/test.img bs=1m count=5
	5+0 records in
	5+0 records out
	5242880 bytes transferred in 0.010 secs (524288000 bytes/sec)
	$ sudo -s
	# vnconfig vnd0 /tmp/test.img  
	# newfs_msdos /dev/rvnd0d
	/dev/rvnd0d: 10192 sectors in 1274 FAT12 clusters (4096 bytes/cluster)
	MBR type: 1
	bps=512 spc=8 res=1 nft=2 rde=512 sec=10240 mid=0xf0 spf=4 spt=32 hds=64 hid=0
	# vnconfig -u vnd0
	# vnconfig vnd0 /tmp/test.img
	# disklabel vnd0
	[...]
	#        size    offset     fstype [fsize bsize cpg/sgs]
	 a:     10240         0     4.2BSD      0     0     0  # (Cyl.      0 -      4)
	 d:     10240         0     unused      0     0        # (Cyl.      0 -      4)
	# mount -t msdos /dev/vnd0d /mnt
	# df -k /mnt
	Filesystem   1K-blocks       Used      Avail %Cap Mounted on
	/dev/vnd0d         5096          0       5096   0% /mnt
>Fix:


>Audit-Trail:
From: David Laight <david@l8s.co.uk>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Subject: Re: kern/40360: fictitious disklabels do not handle devices without an MBR
Date: Sat, 10 Jan 2009 20:39:48 +0000

 On Sat, Jan 10, 2009 at 07:25:01PM +0000, jmcneill@invisible.ca wrote:
 > >Synopsis:       fictitious disklabels do not handle devices without an MBR
 ...
 > >Description:
 > 	When inserting a USB device that only contains a FAT filesystems,
 > 	the auto-generated disklabel incorrectly reports a 4.2BSD filesystem
 > 	at the beginning of the device.

 The filesystem type in the disklabel is fairly irrelevant.
 Nothing during mount looks at it - so it is really just a comment.
 (except maybe for swap).

 It is more important that the fictitious label contain a partition
 that covers the entire disk.

 	David

 -- 
 David Laight: david@l8s.co.uk

From: "Jared D. McNeill" <jmcneill@invisible.ca>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org, 
 netbsd-bugs@netbsd.org
Subject: Re: kern/40360: fictitious disklabels do not handle devices without
 an MBR
Date: Sat, 10 Jan 2009 15:45:06 -0500

 David Laight wrote:
 > The following reply was made to PR kern/40360; it has been noted by GNATS.
 > 
 > From: David Laight <david@l8s.co.uk>
 > To: gnats-bugs@NetBSD.org
 > Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
 > 	netbsd-bugs@netbsd.org
 > Subject: Re: kern/40360: fictitious disklabels do not handle devices without an MBR
 > Date: Sat, 10 Jan 2009 20:39:48 +0000
 > 
 >  On Sat, Jan 10, 2009 at 07:25:01PM +0000, jmcneill@invisible.ca wrote:
 >  > >Synopsis:       fictitious disklabels do not handle devices without an MBR
 >  ...
 >  > >Description:
 >  > 	When inserting a USB device that only contains a FAT filesystems,
 >  > 	the auto-generated disklabel incorrectly reports a 4.2BSD filesystem
 >  > 	at the beginning of the device.
 >  
 >  The filesystem type in the disklabel is fairly irrelevant.
 >  Nothing during mount looks at it - so it is really just a comment.
 >  (except maybe for swap).
 >  
 >  It is more important that the fictitious label contain a partition
 >  that covers the entire disk.

 People look at it[1] and HAL uses it to figure out which mount_* to 
 call. Our HAL backend now has a nasty hack that uses libvolume_id to 
 ignore disklabel if libvolume_id thinks a partition is 'vfat'.

 Also, doesn't /sbin/mount use it to guess which mount_* to use when -t 
 isn't specified?

 Cheers,
 Jared

 [1] http://mail-index.netbsd.org/netbsd-users/2009/01/07/msg002689.html

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: david@l8s.co.uk
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
        netbsd-bugs@NetBSD.org, tsutsui@ceres.dti.ne.jp
Subject: Re: kern/40360: fictitious disklabels do not handle devices without
	 an MBR
Date: Sun, 11 Jan 2009 08:08:40 +0900

 david@l8s.co.uk wrote:

 > > >Description:
 > > 	When inserting a USB device that only contains a FAT filesystems,
 > > 	the auto-generated disklabel incorrectly reports a 4.2BSD filesystem
 > > 	at the beginning of the device.
 > 
 > The filesystem type in the disklabel is fairly irrelevant.
 > Nothing during mount looks at it - so it is really just a comment.
 > (except maybe for swap).

 It's okay if it's "unused" against a raw partition,
 but subr_disk_mbr.c implicitly sets 4.4BSD for partitoin 'a'
 if there is no valid disklabel.
 ---
 	/*
 	 * Set partition 'a' to be the whole disk.
 	 * Cleared if we find an mbr or a netbsd label.
 	 */
 	lp->d_partitions[0].p_size = lp->d_partitions[RAW_PART].p_size;
 	lp->d_partitions[0].p_fstype = FS_BSDFFS;
 ---
 It's quite a bad assumption.

 ---
 Izumi Tsutsui

>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.