Commit 357fbac9 authored by Tim Schmielau's avatar Tim Schmielau Committed by Linus Torvalds

[PATCH] Fix BSD accounting cross-platform compatibility

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: default avatarTim Schmielau <tim@physik3.uni-rostock.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f9d21ae7
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <asm/param.h> #include <asm/param.h>
#include <asm/byteorder.h>
/* /*
* comp_t is a 16-bit "floating" point number with a 3-bit base 8 * comp_t is a 16-bit "floating" point number with a 3-bit base 8
...@@ -104,7 +105,12 @@ struct acct_v3 ...@@ -104,7 +105,12 @@ struct acct_v3
#define ACOMPAT 0x04 /* ... used compatibility mode (VAX only not used) */ #define ACOMPAT 0x04 /* ... used compatibility mode (VAX only not used) */
#define ACORE 0x08 /* ... dumped core */ #define ACORE 0x08 /* ... dumped core */
#define AXSIG 0x10 /* ... was killed by a signal */ #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__ #ifdef __KERNEL__
......
...@@ -398,7 +398,7 @@ static void do_acct_process(long exitcode, struct file *file) ...@@ -398,7 +398,7 @@ static void do_acct_process(long exitcode, struct file *file)
*/ */
memset((caddr_t)&ac, 0, sizeof(acct_t)); 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)); strlcpy(ac.ac_comm, current->comm, sizeof(ac.ac_comm));
elapsed = jiffies_64_to_AHZ(get_jiffies_64() - current->start_time); elapsed = jiffies_64_to_AHZ(get_jiffies_64() - current->start_time);
...@@ -441,8 +441,7 @@ static void do_acct_process(long exitcode, struct file *file) ...@@ -441,8 +441,7 @@ static void do_acct_process(long exitcode, struct file *file)
old_encode_dev(tty_devnum(current->signal->tty)) : 0; old_encode_dev(tty_devnum(current->signal->tty)) : 0;
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
/* ABYTESEX is always set to allow byte order detection */ ac.ac_flag = 0;
ac.ac_flag = ABYTESEX;
if (current->flags & PF_FORKNOEXEC) if (current->flags & PF_FORKNOEXEC)
ac.ac_flag |= AFORK; ac.ac_flag |= AFORK;
if (current->flags & PF_SUPERPRIV) if (current->flags & PF_SUPERPRIV)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment