The following patch enables trousers to work correctly on a big-endian system
(such as SPARC). Currently, the system.data file is incorrectly interpreted
on big-endian platforms.
--- src/tcs/ps/ps_utils.c.old Wed Aug 5 11:44:32 2009
+++ src/tcs/ps/ps_utils.c Wed Aug 5 11:51:15 2009
@@ -14,6 +14,9 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef SOLARIS
+#include <sys/byteorder.h>
+#endif
#include <fcntl.h>
#include <string.h>
#include <limits.h>
@@ -160,6 +163,9 @@
return -1;
}
+#if defined (_BIG_ENDIAN)
+ num_keys = BSWAP_32(num_keys);
+#endif
if ((rc = write_data(fd, &num_keys, sizeof(UINT32)))) {
LogError("%s", __FUNCTION__);
return rc;
@@ -168,6 +174,10 @@
/* return the offset */
return (TSSPS_NUM_KEYS_OFFSET + sizeof(UINT32));
}
+#if defined (_BIG_ENDIAN)
+ else
+ num_keys = BSWAP_32(num_keys);
+#endif
/* if there is a hole in the file we can write to, find it */
offset = find_write_offset(pub_data_size, blob_size, vendor_data_size);
@@ -187,7 +197,9 @@
LogError("lseek: %s", strerror(errno));
return -1;
}
-
+#if defined(_BIG_ENDIAN)
+ num_keys = BSWAP_32(num_keys);
+#endif
if ((rc = write_data(fd, &num_keys, sizeof(UINT32)))) {
LogError("%s", __FUNCTION__);
return rc;
@@ -274,6 +286,9 @@
} else if ((unsigned)rc < sizeof(UINT32)) {
num_keys = 0;
}
+#if defined(_BIG_ENDIAN)
+ num_keys = BSWAP_32(num_keys);
+#endif
return num_keys;
}
@@ -403,6 +418,9 @@
LogError("%s", __FUNCTION__);
goto err_exit;
}
+#if defined(_BIG_ENDIAN)
+ tmp->pub_data_size = BSWAP_16(tmp->pub_data_size);
+#endif
DBG_ASSERT(tmp->pub_data_size <= 2048 && tmp->pub_data_size >
0);
@@ -411,7 +429,9 @@
LogError("%s", __FUNCTION__);
goto err_exit;
}
-
+#if defined(_BIG_ENDIAN)
+ tmp->blob_size = BSWAP_16(tmp->blob_size);
+#endif
DBG_ASSERT(tmp->blob_size <= 4096 && tmp->blob_size > 0);
/* vendor data size */
@@ -419,6 +439,9 @@
LogError("%s", __FUNCTION__);
goto err_exit;
}
+#if defined(_BIG_ENDIAN)
+ tmp->vendor_data_size = BSWAP_32(tmp->vendor_data_size);
+#endif
/* cache flags */
if ((rc = read_data(fd, &tmp->flags, sizeof(UINT16)))) {
@@ -425,6 +448,9 @@
LogError("%s", __FUNCTION__);
goto err_exit;
}
+#if defined(_BIG_ENDIAN)
+ tmp->flags = BSWAP_16(tmp->flags);
+#endif
#ifdef TSS_DEBUG
if (tmp->flags & CACHE_FLAG_VALID)
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
TrouSerS-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/trousers-tech