From: Tim Schmielau BSD accounting cross-platform compatibility is a new feature of 2.6.8 and thus not crucial, but it'd be nice not to have kernels writing wrong file formats out in the wild. The endianness detection logic I wanted to suppose for userspace turned out to be bogus. So just do it the simple way and store endianness info together with the version number. Signed-off-by: Tim Schmielau Signed-off-by: Andrew Morton --- 25-akpm/include/linux/acct.h | 8 +++++++- 25-akpm/kernel/acct.c | 5 ++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff -puN include/linux/acct.h~fix-bsd-accounting-cross-platform-compatibility include/linux/acct.h --- 25/include/linux/acct.h~fix-bsd-accounting-cross-platform-compatibility Thu Jul 29 15:23:21 2004 +++ 25-akpm/include/linux/acct.h Thu Jul 29 15:23:21 2004 @@ -17,6 +17,7 @@ #include #include +#include /* * comp_t is a 16-bit "floating" point number with a 3-bit base 8 @@ -104,7 +105,12 @@ struct acct_v3 #define ACOMPAT 0x04 /* ... used compatibility mode (VAX only not used) */ #define ACORE 0x08 /* ... dumped core */ #define AXSIG 0x10 /* ... was killed by a signal */ -#define ABYTESEX 0x80 /* always set, allows to detect byteorder */ + +#ifdef __BIG_ENDIAN +#define ACCT_BYTEORDER 0x80 /* accounting file is big endian */ +#else +#define ACCT_BYTEORDER 0x00 /* accounting file is little endian */ +#endif #ifdef __KERNEL__ diff -puN kernel/acct.c~fix-bsd-accounting-cross-platform-compatibility kernel/acct.c --- 25/kernel/acct.c~fix-bsd-accounting-cross-platform-compatibility Thu Jul 29 15:23:21 2004 +++ 25-akpm/kernel/acct.c Thu Jul 29 15:23:21 2004 @@ -398,7 +398,7 @@ static void do_acct_process(long exitcod */ memset((caddr_t)&ac, 0, sizeof(acct_t)); - ac.ac_version = ACCT_VERSION; + ac.ac_version = ACCT_VERSION | ACCT_BYTEORDER; strlcpy(ac.ac_comm, current->comm, sizeof(ac.ac_comm)); elapsed = jiffies_64_to_AHZ(get_jiffies_64() - current->start_time); @@ -441,8 +441,7 @@ static void do_acct_process(long exitcod old_encode_dev(tty_devnum(current->signal->tty)) : 0; read_unlock(&tasklist_lock); - /* ABYTESEX is always set to allow byte order detection */ - ac.ac_flag = ABYTESEX; + ac.ac_flag = 0; if (current->flags & PF_FORKNOEXEC) ac.ac_flag |= AFORK; if (current->flags & PF_SUPERPRIV) _