X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=include%2Flinux%2Facct.h;h=b46ce1ac1c6a3e7a96dbde7c8c421e5eceaf68c6;hb=9bf4aaab3e101692164d49b7ca357651eb691cb6;hp=69389c4af8e43ad62d2389d98234fec8a5a1256a;hpb=db216c3d5e4c040e557a50f8f5d35d5c415e8c1c;p=linux-2.6.git diff --git a/include/linux/acct.h b/include/linux/acct.h index 69389c4af..b46ce1ac1 100644 --- a/include/linux/acct.h +++ b/include/linux/acct.h @@ -16,14 +16,19 @@ #define _LINUX_ACCT_H #include +#include +#include /* * comp_t is a 16-bit "floating" point number with a 3-bit base 8 - * exponent and a 13-bit fraction. See linux/kernel/acct.c for the - * specific encoding system used. + * exponent and a 13-bit fraction. + * comp2_t is 24-bit with 5-bit base 2 exponent and 20 bit fraction + * (leading 1 not stored). + * See linux/kernel/acct.c for the specific encoding systems used. */ typedef __u16 comp_t; +typedef __u32 comp2_t; /* * accounting file record @@ -36,27 +41,59 @@ typedef __u16 comp_t; struct acct { - char ac_flag; /* Accounting Flags */ -/* - * No binary format break with 2.0 - but when we hit 32bit uid we'll - * have to bite one - */ - __u16 ac_uid; /* Accounting Real User ID */ - __u16 ac_gid; /* Accounting Real Group ID */ - __u16 ac_tty; /* Accounting Control Terminal */ - __u32 ac_btime; /* Accounting Process Creation Time */ - comp_t ac_utime; /* Accounting User Time */ - comp_t ac_stime; /* Accounting System Time */ - comp_t ac_etime; /* Accounting Elapsed Time */ - comp_t ac_mem; /* Accounting Average Memory Usage */ - comp_t ac_io; /* Accounting Chars Transferred */ - comp_t ac_rw; /* Accounting Blocks Read or Written */ - comp_t ac_minflt; /* Accounting Minor Pagefaults */ - comp_t ac_majflt; /* Accounting Major Pagefaults */ - comp_t ac_swaps; /* Accounting Number of Swaps */ - __u32 ac_exitcode; /* Accounting Exitcode */ - char ac_comm[ACCT_COMM + 1]; /* Accounting Command Name */ - char ac_pad[10]; /* Accounting Padding Bytes */ + char ac_flag; /* Flags */ + char ac_version; /* Always set to ACCT_VERSION */ + /* for binary compatibility back until 2.0 */ + __u16 ac_uid16; /* LSB of Real User ID */ + __u16 ac_gid16; /* LSB of Real Group ID */ + __u16 ac_tty; /* Control Terminal */ + __u32 ac_btime; /* Process Creation Time */ + comp_t ac_utime; /* User Time */ + comp_t ac_stime; /* System Time */ + comp_t ac_etime; /* Elapsed Time */ + comp_t ac_mem; /* Average Memory Usage */ + comp_t ac_io; /* Chars Transferred */ + comp_t ac_rw; /* Blocks Read or Written */ + comp_t ac_minflt; /* Minor Pagefaults */ + comp_t ac_majflt; /* Major Pagefaults */ + comp_t ac_swaps; /* Number of Swaps */ +/* m68k had no padding here. */ +#if !defined(CONFIG_M68K) || !defined(__KERNEL__) + __u16 ac_ahz; /* AHZ */ +#endif + __u32 ac_exitcode; /* Exitcode */ + char ac_comm[ACCT_COMM + 1]; /* Command Name */ + __u8 ac_etime_hi; /* Elapsed Time MSB */ + __u16 ac_etime_lo; /* Elapsed Time LSB */ + __u32 ac_uid; /* Real User ID */ + __u32 ac_gid; /* Real Group ID */ +}; + +struct acct_v3 +{ + char ac_flag; /* Flags */ + char ac_version; /* Always set to ACCT_VERSION */ + __u16 ac_tty; /* Control Terminal */ + __u32 ac_exitcode; /* Exitcode */ + __u32 ac_uid; /* Real User ID */ + __u32 ac_gid; /* Real Group ID */ + __u32 ac_pid; /* Process ID */ + __u32 ac_ppid; /* Parent Process ID */ + __u32 ac_btime; /* Process Creation Time */ +#ifdef __KERNEL__ + __u32 ac_etime; /* Elapsed Time */ +#else + float ac_etime; /* Elapsed Time */ +#endif + comp_t ac_utime; /* User Time */ + comp_t ac_stime; /* System Time */ + comp_t ac_mem; /* Average Memory Usage */ + comp_t ac_io; /* Chars Transferred */ + comp_t ac_rw; /* Blocks Read or Written */ + comp_t ac_minflt; /* Minor Pagefaults */ + comp_t ac_majflt; /* Major Pagefaults */ + comp_t ac_swaps; /* Number of Swaps */ + char ac_comm[ACCT_COMM]; /* Command Name */ }; /* @@ -69,7 +106,11 @@ struct acct #define ACORE 0x08 /* ... dumped core */ #define AXSIG 0x10 /* ... was killed by a signal */ -#define AHZ 100 +#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__ @@ -84,6 +125,66 @@ extern void acct_process(long exitcode); #define acct_process(x) do { } while (0) #endif +/* + * ACCT_VERSION numbers as yet defined: + * 0: old format (until 2.6.7) with 16 bit uid/gid + * 1: extended variant (binary compatible on M68K) + * 2: extended variant (binary compatible on everything except M68K) + * 3: new binary incompatible format (64 bytes) + * 4: new binary incompatible format (128 bytes) + * 5: new binary incompatible format (128 bytes, second half) + * + */ + +#ifdef CONFIG_BSD_PROCESS_ACCT_V3 +#define ACCT_VERSION 3 +#define AHZ 100 +typedef struct acct_v3 acct_t; +#else +#ifdef CONFIG_M68K +#define ACCT_VERSION 1 +#else +#define ACCT_VERSION 2 +#endif +#define AHZ (USER_HZ) +typedef struct acct acct_t; +#endif + +#else +#define ACCT_VERSION 2 +#define AHZ (HZ) #endif /* __KERNEL */ +#ifdef __KERNEL__ +/* + * Yet another set of HZ to *HZ helper functions. + * See for the original. + */ + +static inline u32 jiffies_to_AHZ(unsigned long x) +{ +#if (TICK_NSEC % (NSEC_PER_SEC / AHZ)) == 0 + return x / (HZ / USER_HZ); +#else + u64 tmp = (u64)x * TICK_NSEC; + do_div(tmp, (NSEC_PER_SEC / AHZ)); + return (long)tmp; +#endif +} + +static inline u64 jiffies_64_to_AHZ(u64 x) +{ +#if (TICK_NSEC % (NSEC_PER_SEC / AHZ)) == 0 +#if HZ != AHZ + do_div(x, HZ / AHZ); +#endif +#else + x *= TICK_NSEC; + do_div(x, (NSEC_PER_SEC / AHZ)); +#endif + return x; +} + +#endif /* __KERNEL */ + #endif /* _LINUX_ACCT_H */