X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=blobdiff_plain;f=cprogs%2Facctdump.c;h=b9040ac710f91eebe6a83af73262a2027a4e4e29;hp=35acfb3e4cad8727794876af93fb14a27bf63a2f;hb=a30213491e687db44dbf5ee15f35932bf8b82394;hpb=51b1ba5e732a7d7245ed567004e88d36acc01c32 diff --git a/cprogs/acctdump.c b/cprogs/acctdump.c index 35acfb3..b9040ac 100644 --- a/cprogs/acctdump.c +++ b/cprogs/acctdump.c @@ -44,6 +44,7 @@ typedef unsigned long long u64; typedef struct acct_v3 struct_acct; #define HAVE_AC_EXITCODE #define HAVE_AC_FLT +#define FIELD_AC_FLAG(as) ((as)->ac_flag) #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) @@ -52,6 +53,8 @@ typedef struct acct_v3 struct_acct; #include typedef struct acctv2 struct_acct; +#define HAVE_AC_IO_MEM +#define FIELD_AC_FLAG(as) ((as)->ac_flagx & ~ANVER) #else @@ -181,6 +184,9 @@ static void printbanner(void) { fputs(" user time sys time elap time " #ifdef HAVE_AC_FLT " minflt maxflt" +#endif +#ifdef HAVE_AC_IO_MEM + " avg.mem io" #endif , stdout); } @@ -199,17 +205,26 @@ static void printrecord(const struct_acct *as, const char *filename) { struct passwd *pw; struct group *gr; time_t btime; + char commbuf[sizeof(as->ac_comm)]; if (raw) { printf("%10lu ",(unsigned long)as->ac_btime); } else { btime= as->ac_btime; tm= localtime(&btime); - strftime(buf,sizeof(buf),"%Y-%m-%d %H:%M:%S",tm); buf[sizeof(buf)-1]= 0; + if (tm) { + strftime(buf,sizeof(buf),"%Y-%m-%d %H:%M:%S",tm); buf[sizeof(buf)-1]= 0; + } else { + snprintf(buf,sizeof(buf),"@%lu",(unsigned long)btime); + } printf("%19s ",buf); } - - printf("%-16.16s ", as->ac_comm); + + for (i=0; iac_comm); i++) { + int c=as->ac_comm[i]; + commbuf[i]= ((c!=0 && c<=32) || c>=127) ? '?' : c; + } + printf("%-*.*s ", (int)sizeof(commbuf),(int)sizeof(commbuf), commbuf); pw= raw ? 0 : getpwuid(as->ac_uid); if (pw) printf("%-8s ",pw->pw_name); @@ -245,7 +260,7 @@ static void printrecord(const struct_acct *as, const char *filename) { } } - r= as->ac_flag; + r= FIELD_AC_FLAG(as); for (i=1, fp= "FS4DX"; *fp; fp++, i<<=1) { if (r&i) { putchar(*fp); @@ -301,6 +316,11 @@ static void printrecord(const struct_acct *as, const char *filename) { printf(" %8lu %8lu", (unsigned long)as->ac_minflt, (unsigned long)as->ac_majflt); +#endif +#ifdef HAVE_AC_IO_MEM + printf(" %4e %4e", + as->ac_mem, + as->ac_io); #endif } putchar('\n');