From owner-freebsd-embedded@FreeBSD.ORG Tue Oct 15 16:13:46 2013 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 58DD8C76 for ; Tue, 15 Oct 2013 16:13:46 +0000 (UTC) (envelope-from sean_bruno@yahoo.com) Received: from nm25-vm2.bullet.mail.gq1.yahoo.com (nm25-vm2.bullet.mail.gq1.yahoo.com [98.136.217.113]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 262B22383 for ; Tue, 15 Oct 2013 16:13:45 +0000 (UTC) Received: from [98.137.12.175] by nm25.bullet.mail.gq1.yahoo.com with NNFMP; 15 Oct 2013 16:07:33 -0000 Received: from [208.71.42.191] by tm14.bullet.mail.gq1.yahoo.com with NNFMP; 15 Oct 2013 16:07:33 -0000 Received: from [127.0.0.1] by smtp202.mail.gq1.yahoo.com with NNFMP; 15 Oct 2013 16:07:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1381853253; bh=RbeFkdjV6qAfQsHBV2xQJ2iqBlHObdovn34QzyakjZY=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:X-Rocket-Received:Subject:From:Reply-To:To:Cc:In-Reply-To:References:Content-Type:Date:Message-ID:Mime-Version:X-Mailer; b=n08G3wzOe7udehtRyblzVY/5o8sJLSOagYRuV8Dqf2Zrrs7OgxtWQSyhsYVFHFYytLv3FDQA5NfY4UFbWLF0Sdnvrvdw4+3uDhXfbw4bXhrL5tJQgkoA8ZkFF7vVH16clrL9lzG2UVmqzd59ZPDJY3+sbwzNXBkRrcUM3/1dyV0= X-Yahoo-Newman-Id: 71630.12269.bm@smtp202.mail.gq1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: Z_KsbigVM1mK5Qjt52HBvX5dPHVVgVEjUAfyomPsMm7OmRG .uO30lsHtRTQP0XmmZ6qylqfB7Wl.BZT_VgVZE8pBpgHqczxWLdgF3TR63U9 pNu5qaVX9essPOq1aH6Ji039q_Lo4sIr0kFFjMKqGSZ58GoojTjIpA_GloD4 xIDGpEQBr2vK3dpQhiLjBp4dD.24PKZZ1Di809DySsDh2SPJOC.1m377vsxe A.EAW2LmAf95r2DOWHq5slOdccaQ3dqiBiGjV.upHFWm8u1HvdEOi85ExCmH pRf7_1n2W0UiRPHp1Mi5dGD2ztE0NrtNQm3cDVxF56cG3K9OEpSdu7961G.m f4QEd05M8TyKogdTC2uSuwHoxTS7f._k11BgAc9uU.gqDHmgwMOedJRg3zQE TrJbtieEFizUQyW5prpMcHT7_50wZ2ENbmp2YUpFaM9bTYlBgBhjpxGizF0x gCjUpa2Kob20Gm3gw0xdzosLA0_fzUBN9bQlJop5DKOSFaYEQQT78TKk0IGR iBKSJXWwGqwJkQ86yruurpdN4MXhjNhflH3iJ7.hcGVAp93icKBfZt7HccGG 1nQ-- X-Yahoo-SMTP: u5BKR6OswBC_iZJVfGRoMkTIpc8pEA4- X-Rocket-Received: from [10.73.160.242] (sean_bruno@209.131.62.116 with ) by smtp202.mail.gq1.yahoo.com with SMTP; 15 Oct 2013 09:07:33 -0700 PDT Subject: makefs(8) proposed changes [repost from fs@] From: Sean Bruno To: sbruno@freebsd.org In-Reply-To: <1380730546.1619.47.camel@localhost> References: <1380730546.1619.47.camel@localhost> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-wRr0ZJ3fThU90aWGtJ7N" Date: Tue, 15 Oct 2013 09:07:32 -0700 Message-ID: <1381853252.2682.0.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Cc: freebsd-embedded@freebsd.org X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: sbruno@freebsd.org List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Oct 2013 16:13:46 -0000 --=-wRr0ZJ3fThU90aWGtJ7N Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable On Wed, 2013-10-02 at 09:15 -0700, Sean Bruno wrote: > Using makefs from an amd64 host to build a f/s in a VTOC8 partition will > destroy the entire partition table. I simplified the test to simple dd > to an existing partition and got the same result, exonerating mkfs >=20 > I suspect a lack of endian knowledge in geom itself, not > geom_part_vtoc8. =20 >=20 > test case: > using amd64 host (10.0 current) create monolothic image > truncate -s+5G /var/tmp/myfile.img > mdconfig -f /var/tmp/myfile.img > build and load geom_part_vtoc8 kernel module > use gpart to create VTOC8 part table > add partition to part table to yeild the following: >=20 > =3D> 0 10442250 md0 VTOC8 (5.0G) > 0 10442250 1 freebsd-ufs (5G) =20 >=20 > dd to md0a from dev zero for just a bit > dd if=3D/dev/zero of=3D/dev/md0a bs=3D64k count=3D100 >=20 > destroy md0 via mdconfig -d -u 0 > recreate it with mdconfig -f /var/tmp/myfile.img >=20 > gpart displays no partions for the image any more: > gpart: No such geom: md0. >=20 > bcc freebsd-geom Nathan brought me some knowledge. newfs(8) knows that the first 16 sectors for the first partition are special and not to touch it. makefs(8) does not. So, as a proof of concept, I modified makefs to read() the first 16 sectors from the "image" (in my case, /dev/md0a) and throw it away. (lseek() failed on the partition, so read() was used) This got me to a bootable SPARC64 image in qemu-system-sparc64, and will probably allow further booting in other BE architectures. Is this patch going to break non "device" makefs calls? e.g. if I want to create an image file and not use a loopback device? Index: ffs.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- ffs.c (revision 255871) +++ ffs.c (working copy) @@ -470,6 +470,7 @@ char *buf; int i, bufsize; off_t bufrem; + char temp_buf[16*512]; =20 assert (image !=3D NULL); assert (fsopts !=3D NULL); @@ -480,6 +481,7 @@ warn("Can't open `%s' for writing", image); return (-1); } + read(fsopts->fd, temp_buf, 16*512); =20 /* zero image */ #if HAVE_STRUCT_STATVFS_F_IOSIZE && HAVE_FSTATVFS bcc - nwhitehorn --=-wRr0ZJ3fThU90aWGtJ7N Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (FreeBSD) iQEcBAABAgAGBQJSXWg7AAoJEBkJRdwI6BaHJfYH/0GPDs8p/BmxePKCZ2kJZdWh ZQolVxPu7IC3TlqE2olngwcMRA7elGnduRJzl4UZycYSsGHR/LZdoYJMlzflsD+6 NDWVF8ckj3L/KHq10rJDGlDV31FgpPJFjWq3C7lEuPkMnMrn1Qp1CbTtbG5JeEZK MlSM/y0RM6aoj8hlJI51uqYyOBoKrZScwOnuOXMOB9BwRF6IQU6SIx9cy6btHfHO uoAXOWjfVsayv6Y7X46OgNruiSKmCnPDaRNMbg/pPi6vpJBQvdyPENpdJpKOwop4 Zj37QcWibh/GQwXgOe/i1qxziL/XvYaz6h1HuN7C+G9koFWQILCXQnuTzdYFbSo= =+Gt1 -----END PGP SIGNATURE----- --=-wRr0ZJ3fThU90aWGtJ7N--