diff --git a/NEWS b/NEWS index e3b0c92e..4105c512 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ procps-3.2.1 --> procps-3.2.2 avoid warning about -lncurses when not linking -- thanks FLWM ps: personality-specific -x support (HP-UX and SVR4-MP) ps: k option, same as --sort +vmstat: fixed -d procps-3.2.0 --> procps-3.2.1 diff --git a/proc/sysinfo.c b/proc/sysinfo.c index 4961484d..234e6348 100644 --- a/proc/sysinfo.c +++ b/proc/sysinfo.c @@ -674,20 +674,6 @@ nextline: /////////////////////////////////////////////////////////////////////// // based on Fabian Frederick's /proc/diskstats parser -static unsigned int getFileLines(const char* szFile){ - char szBuffer[1024]; - FILE *fdiskStat; - int lines=0; - if ((fdiskStat=fopen (szFile,"rb"))){ - while (fgets(szBuffer, 1024, fdiskStat)){ - lines++; - } - fclose(fdiskStat); - } - return lines; -} - -///////////////////////////////////////////////////////////////////////////// unsigned int getpartitions_num(struct disk_stat *disks, int ndisks){ int i=0; @@ -704,31 +690,28 @@ unsigned int getpartitions_num(struct disk_stat *disks, int ndisks){ unsigned int getdiskstat(struct disk_stat **disks, struct partition_stat **partitions){ FILE* fd; - int units, - i, - disk_type, - disk_num, - cDisk=0, - cPartition=0; + int cDisk = 0; + int cPartition = 0; + int fields; + unsigned dummy; *disks = NULL; *partitions = NULL; buff[BUFFSIZE-1] = 0; - units = getFileLines("/proc/diskstats"); fd = fopen("/proc/diskstats", "rb"); if(!fd) crash("/proc/diskstats"); - for (i=0; itypecode = SEL_JID; + return NULL; /* can't have any more options */ +#endif case 'L': /* */ /* In spite of the insane 2-level thread system, Sun appears to * have made this option Linux-compatible. If a process has N @@ -264,7 +274,7 @@ static const char *parse_sysv_option(void){ thread_flags |= TF_U_L; // format_modifiers |= FM_L; break; - case 'M': /* someday, maybe, we will have MAC like SGI's Irix */ + case 'M': // typically the SE Linux context trace("-M Print security label for Mandatory Access Control.\n"); format_modifiers |= FM_M; break; @@ -279,14 +289,18 @@ static const char *parse_sysv_option(void){ defer_sf_option(arg, SF_U_O); return NULL; /* can't have any more options */ case 'P': /* SunOS 5 "psr" or unknown HP/UX feature */ - trace("-P adds columns of PRM info (HP) or PSR column (Sun)\n"); + trace("-P adds columns of PRM info (HP-UX), PSR (SunOS), or capabilities (IRIX)\n"); format_modifiers |= FM_P; break; -#ifdef WE_UNDERSTAND_THIS - case 'R': /* unknown HP/UX feature */ - trace("-R selects PRM groups\n"); - return "Don't understand PRM on Linux."; - break; +#if 0 + case 'R': // unknown HP/UX feature, like IRIX "-J" maybe? + trace("-R select by PRM group\n"); + arg=get_opt_arg(); + if(!arg) return "List of PRM groups must follow -R."; + err=parse_list(arg, parse_prm); + if(err) return err; + selection_list->typecode = SEL_PRM; + return NULL; /* can't have any more options */ #endif case 'T': /* IRIX 6.5 docs suggest POSIX threads get shown individually. @@ -312,9 +326,10 @@ static const char *parse_sysv_option(void){ display_version(); exit(0); #if 0 + // This must be verified against SVR4-MP (UnixWare or Powermax) case 'Z': /* full Mandatory Access Control level info */ trace("-Z shows full MAC info\n"); - return "Don't understand MAC on Linux."; + format_modifiers |= FM_M; break; #endif case 'a': @@ -394,7 +409,7 @@ static const char *parse_sysv_option(void){ if(err) return err; selection_list->typecode = SEL_PID; return NULL; /* can't have any more options */ -#ifdef KNOW_WHAT_TO_DO_WITH_THIS +#if 0 case 'r': trace("-r some Digital Unix thing about warnings...\n"); trace(" or SCO's option to chroot() for new /proc and /dev.\n"); @@ -448,9 +463,10 @@ static const char *parse_sysv_option(void){ format_modifiers |= FM_y; break; #if 0 + // This must be verified against SVR4-MP (UnixWare or Powermax) case 'z': /* alias of Mandatory Access Control level info */ trace("-z shows aliased MAC info\n"); - return "Don't understand MAC aliases on Linux."; + format_modifiers |= FM_M; break; #endif case '-': diff --git a/vmstat.c b/vmstat.c index 09d1fa4b..8ae8cd85 100644 --- a/vmstat.c +++ b/vmstat.c @@ -163,27 +163,6 @@ static void new_header(void){ //////////////////////////////////////////////////////////////////////////// -static void diskheader(void){ - printf("disk ----------reads------------ -----------writes----------- -------IO-------\n"); - - printf("%3s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s\n", " ", "total", "merged","sectors","ms","total","merged","sectors","ms","cur","s"); - -} - -//////////////////////////////////////////////////////////////////////////// - -static void diskpartition_header(const char *partition_name){ - printf("%-10s %10s %10s %10s %10s\n",partition_name, "reads ", "read sectors", "writes ", "requested writes"); -} - -//////////////////////////////////////////////////////////////////////////// - -static void slabheader(void){ - printf("%-24s %6s %6s %6s %6s\n","Cache","Num", "Total", "Size", "Pages"); -} - -//////////////////////////////////////////////////////////////////////////// - static unsigned long unitConvert(unsigned int size){ float cvSize; cvSize=(float)size/dataUnit*((statMode==SLABSTAT)?1:1024); @@ -290,6 +269,12 @@ static void new_format(void) { //////////////////////////////////////////////////////////////////////////// +static void diskpartition_header(const char *partition_name){ + printf("%-10s %10s %10s %10s %10s\n",partition_name, "reads ", "read sectors", "writes ", "requested writes"); +} + +//////////////////////////////////////////////////////////////////////////// + static int diskpartition_format(const char* partition_name){ FILE *fDiskstat; struct disk_stat *disks; @@ -345,19 +330,41 @@ static int diskpartition_format(const char* partition_name){ //////////////////////////////////////////////////////////////////////////// +static void diskheader(void){ + printf("disk- ------------reads------------ ------------writes----------- -----IO------\n"); + + printf("%5s %6s %6s %7s %7s %6s %6s %7s %7s %6s %6s\n", + " ", "total", "merged","sectors","ms","total","merged","sectors","ms","cur","sec"); + +} + +//////////////////////////////////////////////////////////////////////////// + static void diskformat(void){ FILE *fDiskstat; struct disk_stat *disks; struct partition_stat *partitions; unsigned long ndisks,i,j,k; - const char format[]="%-3s %6u %6u %6llu %6u %6u %6u %6llu %6u %6u %6u\n"; + const char format[]="%-5s %6u %6u %7llu %7u %6u %6u %7llu %7u %6u %6u\n"; if ((fDiskstat=fopen("/proc/diskstats", "rb"))){ fclose(fDiskstat); ndisks=getdiskstat(&disks,&partitions); for(k=0; k