diff --git a/include/ntfs-3g/cache.h b/include/ntfs-3g/cache.h index 67e4f9da..be63b1a4 100644 --- a/include/ntfs-3g/cache.h +++ b/include/ntfs-3g/cache.h @@ -1,7 +1,7 @@ /* * cache.h : deal with indexed LRU caches * - * Copyright (c) 2008-2009 Jean-Pierre Andre + * Copyright (c) 2008-2010 Jean-Pierre Andre * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -29,11 +29,7 @@ struct CACHED_GENERIC { struct CACHED_GENERIC *previous; void *variable; size_t varsize; - union { - /* force alignment for pointers and u64 */ - u64 u64align; - void *ptralign; - } fixed[0]; + union ALIGNMENT payload[0]; } ; struct CACHED_INODE { @@ -41,6 +37,7 @@ struct CACHED_INODE { struct CACHED_INODE *previous; const char *pathname; size_t varsize; + union ALIGNMENT payload[0]; /* above fields must match "struct CACHED_GENERIC" */ u64 inum; } ; @@ -50,6 +47,7 @@ struct CACHED_NIDATA { struct CACHED_NIDATA *previous; const char *pathname; /* not used */ size_t varsize; /* not used */ + union ALIGNMENT payload[0]; /* above fields must match "struct CACHED_GENERIC" */ u64 inum; ntfs_inode *ni; @@ -60,6 +58,7 @@ struct CACHED_LOOKUP { struct CACHED_LOOKUP *previous; const char *name; size_t namesize; + union ALIGNMENT payload[0]; /* above fields must match "struct CACHED_GENERIC" */ u64 parent; u64 inum; diff --git a/include/ntfs-3g/security.h b/include/ntfs-3g/security.h index 83d7c0e1..f6a8dace 100644 --- a/include/ntfs-3g/security.h +++ b/include/ntfs-3g/security.h @@ -4,7 +4,7 @@ * * Copyright (c) 2004 Anton Altaparmakov * Copyright (c) 2005-2006 Szabolcs Szakacsits - * Copyright (c) 2007-2008 Jean-Pierre Andre + * Copyright (c) 2007-2010 Jean-Pierre Andre * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -85,6 +85,7 @@ struct CACHED_PERMISSIONS_LEGACY { struct CACHED_PERMISSIONS_LEGACY *previous; void *variable; size_t varsize; + union ALIGNMENT payload[0]; /* above fields must match "struct CACHED_GENERIC" */ u64 mft_no; struct CACHED_PERMISSIONS perm; @@ -99,6 +100,7 @@ struct CACHED_SECURID { struct CACHED_SECURID *previous; void *variable; size_t varsize; + union ALIGNMENT payload[0]; /* above fields must match "struct CACHED_GENERIC" */ uid_t uid; gid_t gid; diff --git a/include/ntfs-3g/types.h b/include/ntfs-3g/types.h index 8b7f3f52..a64f12fa 100644 --- a/include/ntfs-3g/types.h +++ b/include/ntfs-3g/types.h @@ -120,5 +120,13 @@ typedef enum { #define STATUS_KEEP_SEARCHING (-3) #define STATUS_NOT_FOUND (-4) +/* + * Force alignment in a struct if required by processor + */ +union ALIGNMENT { + u64 u64align; + void *ptralign; +} ; + #endif /* defined _NTFS_TYPES_H */ diff --git a/libntfs-3g/cache.c b/libntfs-3g/cache.c index dd147672..43ff151d 100644 --- a/libntfs-3g/cache.c +++ b/libntfs-3g/cache.c @@ -1,7 +1,7 @@ /** * cache.c : deal with LRU caches * - * Copyright (c) 2008-2009 Jean-Pierre Andre + * Copyright (c) 2008-2010 Jean-Pierre Andre * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -298,7 +298,7 @@ struct CACHED_GENERIC *ntfs_enter_cache(struct CACHE_HEADER *cache, if (cache->most_recent_entry) cache->most_recent_entry->previous = current; cache->most_recent_entry = current; - memcpy(current->fixed, item->fixed, cache->fixed_size); + memcpy(current->payload, item->payload, cache->fixed_size); if (item->varsize) { if (current->variable) { memcpy(current->variable,