From owner-freebsd-arch@FreeBSD.ORG Mon Nov 2 11:06:49 2009 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F2176106566C for ; Mon, 2 Nov 2009 11:06:49 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id C6FF38FC08 for ; Mon, 2 Nov 2009 11:06:49 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nA2B6nv3033521 for ; Mon, 2 Nov 2009 11:06:49 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id nA2B6nRq033519 for freebsd-arch@FreeBSD.org; Mon, 2 Nov 2009 11:06:49 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 2 Nov 2009 11:06:49 GMT Message-Id: <200911021106.nA2B6nRq033519@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-arch@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-arch@FreeBSD.org 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: Mon, 02 Nov 2009 11:06:50 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o kern/120749 arch [request] Suggest upping the default kern.ps_arg_cache 1 problem total. From owner-freebsd-arch@FreeBSD.ORG Wed Nov 4 17:20:48 2009 Return-Path: Delivered-To: arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6DDF41065670; Wed, 4 Nov 2009 17:20:48 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 1F16B8FC0A; Wed, 4 Nov 2009 17:20:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id nA4HBoGf049389; Wed, 4 Nov 2009 10:11:50 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Wed, 04 Nov 2009 10:12:07 -0700 (MST) Message-Id: <20091104.101207.-1398301090.imp@bsdimp.com> To: arch@FreeBSD.org From: "M. Warner Losh" X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Wed_Nov__4_10_12_07_2009_078)--" Content-Transfer-Encoding: 7bit Cc: marcel@FreeBSD.org Subject: fdisk behavior hack 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: Wed, 04 Nov 2009 17:20:48 -0000 ----Next_Part(Wed_Nov__4_10_12_07_2009_078)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Greetings, Enclosed please find a hack to the behavior of fdisk. On !x86, !ia64 platforms, you can't do a "fdisk -I da0" because there's not /boot/mbr. It is perfectly valid to make disks that don't have any boot code on them (say if you are an ARM or MIPS embedded machine). This patch changes things. Currently, for all patforms except ia64 we open the specified file (defaulting to /boot/mbr). If it doesn't exist or we can't read it, we die. Then we do a bunch of sanity checking on the MBR that was read in. On ia64 we just make a fake one and return (we don't use the -b argument at all!). I'd like to propose something simpler. I'd like to propose that for !i386 and !amd64 we allow the open and/or stat to fail. If the user specified the -b flag, the same thing as the !ia64 case will happen as today: they get an error and the program refuses to work. If no -b flag was specified, then we'll use the current ia64-only code to fake up a 'good enough' MBR and proceed. This will allow non-x86 platforms that install fdisk to still initialize a disk in the face of the missing template mbr file. Comments? Code Review? Warner ----Next_Part(Wed_Nov__4_10_12_07_2009_078)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fdisk-20091104.diff" Index: fdisk.c =================================================================== --- fdisk.c (revision 198865) +++ fdisk.c (working copy) @@ -501,15 +501,37 @@ static void init_boot(void) { -#ifndef __ia64__ const char *fname; int fdesc, n; struct stat sb; + /* + * Open the mbr file and sanity check it. If we're not on a x86 box, + * then /boot/mbr doesn't exist. In that case, allow the user to + * continue with an MBR that just has the right signature, but no + * actual code. If it does exist, then we sanity check it on all + * platforms. If there's a problem with the -b argument, always + * whine. + */ fname = b_flag ? b_flag : "/boot/mbr"; if ((fdesc = open(fname, O_RDONLY)) == -1 || - fstat(fdesc, &sb) == -1) + fstat(fdesc, &sb) == -1) { +#if !defined(__i386__) && !defined(__amd64__) + if (b_flag) + err(1, "%s", fname); + warn("%s", fname); + if (mboot.bootinst != NULL) + free(mboot.bootinst); + mboot.bootinst_size = secsize; + if ((mboot.bootinst = malloc(mboot.bootinst_size)) == NULL) + errx(1, "unable to allocate boot block buffer"); + memset(mboot.bootinst, 0, mboot.bootinst_size); + le16enc(&mboot.bootinst[DOSMAGICOFFSET], DOSMAGIC); + return; +#else err(1, "%s", fname); +#endif + } if ((mboot.bootinst_size = sb.st_size) % secsize != 0) errx(1, "%s: length must be a multiple of sector size", fname); if (mboot.bootinst != NULL) @@ -521,15 +543,6 @@ err(1, "%s", fname); if (n != mboot.bootinst_size) errx(1, "%s: short read", fname); -#else - if (mboot.bootinst != NULL) - free(mboot.bootinst); - mboot.bootinst_size = secsize; - if ((mboot.bootinst = malloc(mboot.bootinst_size)) == NULL) - errx(1, "unable to allocate boot block buffer"); - memset(mboot.bootinst, 0, mboot.bootinst_size); - le16enc(&mboot.bootinst[DOSMAGICOFFSET], DOSMAGIC); -#endif } ----Next_Part(Wed_Nov__4_10_12_07_2009_078)---- From owner-freebsd-arch@FreeBSD.ORG Wed Nov 4 17:48:57 2009 Return-Path: Delivered-To: arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CF6B8106566B for ; Wed, 4 Nov 2009 17:48:57 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outK.internet-mail-service.net (outk.internet-mail-service.net [216.240.47.234]) by mx1.freebsd.org (Postfix) with ESMTP id B5E378FC19 for ; Wed, 4 Nov 2009 17:48:57 +0000 (UTC) Received: from idiom.com (mx0.idiom.com [216.240.32.160]) by out.internet-mail-service.net (Postfix) with ESMTP id 482CD14DDD0; Wed, 4 Nov 2009 09:49:00 -0800 (PST) X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e Received: from julian-mac.elischer.org (h-67-100-89-137.snfccasy.static.covad.net [67.100.89.137]) by idiom.com (Postfix) with ESMTP id CE0FE2D6037; Wed, 4 Nov 2009 09:48:56 -0800 (PST) Message-ID: <4AF1BE88.2080506@elischer.org> Date: Wed, 04 Nov 2009 09:48:56 -0800 From: Julian Elischer User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: "M. Warner Losh" References: <20091104.101207.-1398301090.imp@bsdimp.com> In-Reply-To: <20091104.101207.-1398301090.imp@bsdimp.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: arch@FreeBSD.org, marcel@FreeBSD.org Subject: Re: fdisk behavior hack 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: Wed, 04 Nov 2009 17:48:57 -0000 M. Warner Losh wrote: > Greetings, > > Enclosed please find a hack to the behavior of fdisk. On !x86, !ia64 > platforms, you can't do a "fdisk -I da0" because there's not > /boot/mbr. It is perfectly valid to make disks that don't have any > boot code on them (say if you are an ARM or MIPS embedded machine). > > This patch changes things. Currently, for all patforms except ia64 we > open the specified file (defaulting to /boot/mbr). If it doesn't > exist or we can't read it, we die. Then we do a bunch of sanity > checking on the MBR that was read in. On ia64 we just make a fake one > and return (we don't use the -b argument at all!). I'd say that you could make a valid readable disk without teh boot code even on x86.. just give a big warning. "No boot code available. Disk will not be bootable" > > I'd like to propose something simpler. > > I'd like to propose that for !i386 and !amd64 we allow the open and/or > stat to fail. If the user specified the -b flag, the same thing as > the !ia64 case will happen as today: they get an error and the program > refuses to work. If no -b flag was specified, then we'll use the > current ia64-only code to fake up a 'good enough' MBR and proceed. > > This will allow non-x86 platforms that install fdisk to still > initialize a disk in the face of the missing template mbr file. > > Comments? > > Code Review? > > Warner > > > ------------------------------------------------------------------------ > > _______________________________________________ > freebsd-arch@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"