makefs(8) proposed changes [repost from fs@]
Sean Bruno
sean_bruno at yahoo.com
Tue Oct 15 16:13:46 UTC 2013
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freebsd.org/pipermail/freebsd-embedded/attachments/20131015/efcbab21/attachment.sig>
More information about the freebsd-embedded
mailing list