From owner-freebsd-arch@FreeBSD.ORG Tue Jul 11 15:02:23 2006 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A4E6316A695; Tue, 11 Jul 2006 15:02:23 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2A95343D68; Tue, 11 Jul 2006 15:02:16 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k6BF1qGc075013; Tue, 11 Jul 2006 11:01:59 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-arch@freebsd.org Date: Tue, 11 Jul 2006 09:54:00 -0400 User-Agent: KMail/1.9.1 References: <20060708152801.GA3671@crodrigues.org> <20060711124356.Y78628@fledge.watson.org> <20060711132752.GF65857@submonkey.net> In-Reply-To: <20060711132752.GF65857@submonkey.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200607110954.01691.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Tue, 11 Jul 2006 11:02:03 -0400 (EDT) X-Virus-Scanned: ClamAV 0.87.1/1591/Mon Jul 10 15:41:02 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx Cc: Craig Rodrigues , Scott Long , Ceri Davies , Robert Watson , freebsd-current@freebsd.org Subject: Re: [RFC] mount can figure out fstype automatically X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jul 2006 15:02:23 -0000 On Tuesday 11 July 2006 09:27, Ceri Davies wrote: > On Tue, Jul 11, 2006 at 12:45:18PM +0100, Robert Watson wrote: > > > > On Mon, 10 Jul 2006, Christoph Hellwig wrote: > > > > >On Mon, Jul 10, 2006 at 01:06:02PM -0600, Scott Long wrote: > > >>So in your opinion and experience, what are the pros and cons of > > >>maintaining a table of magic numbers? > > > > > >The feature is imensely useful. The implementation won't win any points > > >for a clean design but works very well in practice. I think it's > > >definitly better than probing in the kernel because letting a filesystem > > >driver try to make sense of something that's not it's own format can lead > > >to all kinds of funnies. Linux does this (iterating all filesystem types > > >in kernel) for the special case of the root filesystem where mount(8) is > > >not available, and it showeds various interesting bugs at least in the fat > > >driver. > > > > In both FreeBSD and Darwin, I've noticed that the kernel msdosfs code is > > excessively permissive as to what it considers a FAT file system. This is > > presumably necessary due to the enourmous diversity of FAT file systems > > floating around, but it makes it a little too easy to cause msdos to trip > > over layouts that violate its layout assumptions. :-) FAT is much more > > reliably detected by looking at the partition type it lives in than by > > looking at the bytes that appear inside the partition, I believe. > > Assuming that there is a valid partition type. I don't really know what > this makes, but there's a valid FAT filesystem on it: > > % truncate -s 1440k floppy > % sudo mdconfig -a -f floppy > md1 > % sudo newfs_msdos -f 1440 /dev/md1 > /dev/md1: 2847 sectors in 2847 FAT12 clusters (512 bytes/cluster) > bps=512 spc=1 res=1 nft=2 rde=224 sec=2880 mid=0xf0 spf=9 spt=18 hds=2 hid=0 > % sudo mount -t msdos /dev/md1 /mnt > % df -h /mnt > Filesystem Size Used Avail Capacity Mounted on > /dev/md1 1.4M 1.0K 1.4M 0% /mnt > {ceri@shrike}-{~} % fdisk /dev/md1 > ******* Working on device /dev/md1 ******* > parameters extracted from in-core disklabel are: > cylinders=0 heads=255 sectors/track=63 (16065 blks/cyl) > > parameters to be used for BIOS calculations are: > cylinders=0 heads=255 sectors/track=63 (16065 blks/cyl) > > Media sector size is 512 > Warning: BIOS sector numbering starts with sector 1 > Information from DOS bootblock is: > The data for partition 1 is: > > The data for partition 2 is: > > The data for partition 3 is: > > The data for partition 4 is: > > > Ceri Dos floppies don't have an MBR (so fdisk on them is meaningless). -- John Baldwin