Date: Tue, 15 Oct 2013 09:07:32 -0700 From: Sean Bruno <sean_bruno@yahoo.com> To: sbruno@freebsd.org Cc: freebsd-embedded@freebsd.org Subject: makefs(8) proposed changes [repost from fs@] Message-ID: <1381853252.2682.0.camel@localhost> In-Reply-To: <1380730546.1619.47.camel@localhost> References: <1380730546.1619.47.camel@localhost>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
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
>
> I suspect a lack of endian knowledge in geom itself, not
> geom_part_vtoc8.
>
> 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:
>
> => 0 10442250 md0 VTOC8 (5.0G)
> 0 10442250 1 freebsd-ufs (5G)
>
> dd to md0a from dev zero for just a bit
> dd if=/dev/zero of=/dev/md0a bs=64k count=100
>
> destroy md0 via mdconfig -d -u 0
> recreate it with mdconfig -f /var/tmp/myfile.img
>
> gpart displays no partions for the image any more:
> gpart: No such geom: md0.
>
> 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
===================================================================
--- 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];
assert (image != NULL);
assert (fsopts != NULL);
@@ -480,6 +481,7 @@
warn("Can't open `%s' for writing", image);
return (-1);
}
+ read(fsopts->fd, temp_buf, 16*512);
/* zero image */
#if HAVE_STRUCT_STATVFS_F_IOSIZE && HAVE_FSTATVFS
bcc - nwhitehorn
[-- Attachment #2 --]
-----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-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1381853252.2682.0.camel>
