explicitly pad struct appleufslabel and use __attribute__((__packed__))
since apple put the 64 bit uuid field on a 4 byte boundary
This commit is contained in:
parent
df08e4e233
commit
ca5ad5d61f
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ffs_appleufs.c,v 1.4 2004/01/02 05:08:57 dbj Exp $ */
|
||||
/* $NetBSD: ffs_appleufs.c,v 1.5 2004/01/02 06:57:46 dbj Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 Darrin B. Jewell
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_appleufs.c,v 1.4 2004/01/02 05:08:57 dbj Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_appleufs.c,v 1.5 2004/01/02 06:57:46 dbj Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -63,13 +63,13 @@ ffs_appleufs_cksum(appleufs)
|
|||
const struct appleufslabel *appleufs;
|
||||
{
|
||||
const u_int16_t *p = (const u_int16_t *)appleufs;
|
||||
int len = sizeof(struct appleufslabel);
|
||||
int len = APPLEUFS_LABEL_SIZE; /* sizeof(struct appleufslabel) */
|
||||
long res = 0;
|
||||
while (len > 1) {
|
||||
res += *p++;
|
||||
len -= 2;
|
||||
}
|
||||
#if 0 /* sizeof(struct appleufslabel) is guaranteed to be even */
|
||||
#if 0 /* APPLEUFS_LABEL_SIZE is guaranteed to be even */
|
||||
if (len == 1)
|
||||
res += htobe16(*(u_char *)p<<8);
|
||||
#endif
|
||||
|
@ -115,14 +115,12 @@ ffs_appleufs_validate(name,o,n)
|
|||
#endif
|
||||
n->ul_namelen = APPLEUFS_MAX_LABEL_NAME;
|
||||
}
|
||||
/* if len is max, will set ul_unused1 */
|
||||
n->ul_name[n->ul_namelen] = '\0';
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
unsigned char foundname[APPLEUFS_MAX_LABEL_NAME+1];
|
||||
memcpy(foundname,n->ul_name,n->ul_namelen);
|
||||
foundname[n->ul_namelen] = '\0';
|
||||
printf("%s: found APPLE UFS label v%d: \"%s\"\n",
|
||||
name,n->ul_version,foundname);
|
||||
}
|
||||
printf("%s: found APPLE UFS label v%d: \"%s\"\n",
|
||||
name,n->ul_version,n->ul_name);
|
||||
#endif
|
||||
n->ul_uuid = be64toh(o->ul_uuid);
|
||||
|
||||
|
@ -157,7 +155,7 @@ ffs_appleufs_set(appleufs, name, t, uuid)
|
|||
namelen = strlen(name);
|
||||
if (namelen > APPLEUFS_MAX_LABEL_NAME)
|
||||
namelen = APPLEUFS_MAX_LABEL_NAME;
|
||||
memset(appleufs, 0, sizeof(*appleufs));
|
||||
memset(appleufs, 0, APPLEUFS_LABEL_SIZE);
|
||||
appleufs->ul_magic = htobe32(APPLEUFS_LABEL_MAGIC);
|
||||
appleufs->ul_version = htobe32(APPLEUFS_LABEL_VERSION);
|
||||
appleufs->ul_time = htobe32((u_int32_t)t);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fs.h,v 1.38 2004/01/02 05:08:57 dbj Exp $ */
|
||||
/* $NetBSD: fs.h,v 1.39 2004/01/02 06:57:46 dbj Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1993
|
||||
|
@ -613,14 +613,16 @@ struct ocg {
|
|||
struct appleufslabel {
|
||||
u_int32_t ul_magic;
|
||||
u_int16_t ul_checksum;
|
||||
u_int16_t ul_unused0;
|
||||
u_int32_t ul_version;
|
||||
u_int32_t ul_time;
|
||||
u_int16_t ul_namelen;
|
||||
u_char ul_name[APPLEUFS_MAX_LABEL_NAME]; /* Warning: may not be null terminated */
|
||||
u_int64_t ul_uuid;
|
||||
u_int16_t ul_unused1;
|
||||
u_int64_t ul_uuid; /* Note this is only 4 byte aligned */
|
||||
u_char ul_reserved[24];
|
||||
u_char ul_unused[460];
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
#endif /* !_UFS_FFS_FS_H_ */
|
||||
|
|
Loading…
Reference in New Issue