]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Fix BSD accounting cross-platform compatibility
authorTim Schmielau <tim@physik3.uni-rostock.de>
Mon, 2 Aug 2004 03:09:36 +0000 (20:09 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 2 Aug 2004 03:09:36 +0000 (20:09 -0700)
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 <tim@physik3.uni-rostock.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/linux/acct.h
kernel/acct.c

index 6c2bd56773f00e036b0d7abd12cbbeb98b0f945f..b46ce1ac1c6a3e7a96dbde7c8c421e5eceaf68c6 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <linux/types.h>
 #include <asm/param.h>
+#include <asm/byteorder.h>
 
 /* 
  *  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__
 
index e55e7bba861e17b9ec290be6d123c9d6bf4aa75e..daf23c4efab4d8e87e52331546312ce2a2cb72bc 100644 (file)
@@ -398,7 +398,7 @@ static void do_acct_process(long exitcode, struct file *file)
         */
        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 exitcode, struct file *file)
                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)