svn commit: r245096 - user/hrs/releng/usr.sbin/makevd

Hiroki Sato hrs at FreeBSD.org
Sun Jan 6 03:51:46 UTC 2013


Author: hrs
Date: Sun Jan  6 03:51:44 2013
New Revision: 245096
URL: http://svnweb.freebsd.org/changeset/base/245096

Log:
  Always use LE byte order in VMDK.

Modified:
  user/hrs/releng/usr.sbin/makevd/vmdk.c
  user/hrs/releng/usr.sbin/makevd/vmdk.h

Modified: user/hrs/releng/usr.sbin/makevd/vmdk.c
==============================================================================
--- user/hrs/releng/usr.sbin/makevd/vmdk.c	Sun Jan  6 03:31:45 2013	(r245095)
+++ user/hrs/releng/usr.sbin/makevd/vmdk.c	Sun Jan  6 03:51:44 2013	(r245096)
@@ -78,22 +78,23 @@ vmdk_makeim(struct iminfo *imi)
 	if (vmdkfilebase == '\0')
 		vmdkfilebase = vmdkfile;
 
-	imh->magicNumber = SPARSE_MAGICNUMBER;
-	imh->version = SPARSE_VERSION_DEFAULT;
-	imh->flags = 1;
-	imh->capacity = 0;
-	imh->grainSize = 16;
-        imh->descriptorOffset = (sizeof(*imh) + 511) / 512;
-        imh->descriptorSize = (sizeof(desc) + 511) / 512;
-        imh->numGTEsPerGT = 512;
-        imh->rgdOffset = 0;
-        imh->gdOffset = 0;
-        imh->overHead = imh->descriptorOffset + imh->descriptorSize;
-        imh->uncleanShutdown = 0;
-        imh->singleEndLineChar = '\n';
-        imh->nonEndLineChar = ' ';
-        imh->doubleEndLineChar1 = '\r';
-        imh->doubleEndLineChar2 = '\n';
+	/* All of the fields are in LE byte order. */
+	imh->magicNumber = htole32(SEH_MAGICNUMBER);
+	imh->version = htole32(SEH_VERSION_DEFAULT);
+	imh->flags = htole32(1);
+	imh->capacity = htole64(0);
+	imh->grainSize = htole64(16);
+	imh->descriptorOffset = htole64((sizeof(*imh) + 511) / 512);
+	imh->descriptorSize = htole64((sizeof(desc) + 511) / 512);
+	imh->numGTEsPerGT = htole32(512);
+	imh->rgdOffset = htole64(0);
+	imh->gdOffset = htole64(0);
+	imh->overHead = htole64(imh->descriptorOffset + imh->descriptorSize);
+	imh->uncleanShutdown = 0;
+	imh->singleEndLineChar = '\n';
+	imh->nonEndLineChar = ' ';
+	imh->doubleEndLineChar1 = '\r';
+	imh->doubleEndLineChar2 = '\n';
 
 	sectors = 63;
 	heads = 16;

Modified: user/hrs/releng/usr.sbin/makevd/vmdk.h
==============================================================================
--- user/hrs/releng/usr.sbin/makevd/vmdk.h	Sun Jan  6 03:31:45 2013	(r245095)
+++ user/hrs/releng/usr.sbin/makevd/vmdk.h	Sun Jan  6 03:51:44 2013	(r245096)
@@ -38,9 +38,12 @@ typedef uint16_t uint16;
 typedef uint8_t uint8;
 typedef uint8_t Bool;
 
+/* All of the fields are in LE byte order. */
 struct SparseExtentHeader {
 	uint32	     magicNumber;
+#define	SEH_MAGICNUMBER		(0x564d444b)	/* "VMDK" */
 	uint32	     version;
+#define	SEH_VERSION_DEFAULT	(2)
 	uint32	     flags;
 	SectorType   capacity;
 	SectorType   grainSize;
@@ -59,12 +62,4 @@ struct SparseExtentHeader {
 	uint8	     pad[433];
 } __attribute__((__packed__));
 
-#if _BYTE_ORDER == _BIG_ENDIAN
-#define	SPARSE_MAGICNUMBER		(0x4b444d56)	/* 'K' 'D' 'M' 'V' */
-#else
-#define	SPARSE_MAGICNUMBER		(0x564d444b)	/* 'V' 'M' 'D' 'K' */
-#endif
-
-#define	SPARSE_VERSION_DEFAULT		2
-
 #endif	/* _VMDK_H */


More information about the svn-src-user mailing list