library: remove getpartitions_num from library

getpartitions_num was only used in vmstat and basically counted
partitions in disks, this is now moved to vmstat.
This commit is contained in:
Craig Small 2015-07-01 22:14:30 +10:00
parent 161e06465b
commit 855a6a7055
4 changed files with 14 additions and 88 deletions

View File

@ -12,9 +12,7 @@ global:
get_ns_name; get_ns_name;
get_pid_digits; get_pid_digits;
get_slabinfo; get_slabinfo;
getbtime;
getdiskstat; getdiskstat;
getpartitions_num;
getslabinfo; getslabinfo;
look_up_our_self; look_up_our_self;
lookup_wchan; lookup_wchan;

View File

@ -171,21 +171,6 @@ static void crash(const char *filename) {
} }
///////////////////////////////////////////////////////////////////////
// based on Fabian Frederick's /proc/diskstats parser
unsigned int getpartitions_num(struct disk_stat *disks, int ndisks){
int i=0;
int partitions=0;
for (i=0;i<ndisks;i++){
partitions+=disks[i].partitions;
}
return partitions;
}
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
static int is_disk(char *dev) static int is_disk(char *dev)
{ {

View File

@ -41,7 +41,6 @@ typedef struct partition_stat{
unsigned long long requested_writes; unsigned long long requested_writes;
}partition_stat; }partition_stat;
extern unsigned int getpartitions_num(struct disk_stat *disks, int ndisks);
extern unsigned int getdiskstat (struct disk_stat**,struct partition_stat**); extern unsigned int getdiskstat (struct disk_stat**,struct partition_stat**);
typedef struct slab_cache{ typedef struct slab_cache{

View File

@ -115,76 +115,6 @@ static void __attribute__ ((__noreturn__))
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
} }
#if 0
/* produce: " 6 ", "123 ", "123k ", etc. */
static int format_1024(unsigned long long val64, char *restrict dst)
{
unsigned oldval;
const char suffix[] = " kmgtpe";
unsigned level = 0;
unsigned val32;
if (val64 < 1000) {
/* special case to avoid "6.0 " when plain " 6 " would do */
val32 = val64;
return sprintf(dst, "%3u ", val32);
}
while (val64 > 0xffffffffull) {
level++;
val64 /= 1024;
}
val32 = val64;
while (val32 > 999) {
level++;
oldval = val32;
val32 /= 1024;
}
if (val32 < 10) {
unsigned fract = (oldval % 1024) * 10 / 1024;
return sprintf(dst, "%u.%u%c ", val32, fract, suffix[level]);
}
return sprintf(dst, "%3u%c ", val32, suffix[level]);
}
/* produce: " 6 ", "123 ", "123k ", etc. */
static int format_1000(unsigned long long val64, char *restrict dst)
{
unsigned oldval;
const char suffix[] = " kmgtpe";
unsigned level = 0;
unsigned val32;
if (val64 < 1000) {
/* special case to avoid "6.0 " when plain " 6 " would do */
val32 = val64;
return sprintf(dst, "%3u ", val32);
}
while (val64 > 0xffffffffull) {
level++;
val64 /= 1000;
}
val32 = val64;
while (val32 > 999) {
level++;
oldval = val32;
val32 /= 1000;
}
if (val32 < 10) {
unsigned fract = (oldval % 1000) / 100;
return sprintf(dst, "%u.%u%c ", val32, fract, suffix[level]);
}
return sprintf(dst, "%3u%c ", val32, suffix[level]);
}
#endif
static void new_header(void) static void new_header(void)
{ {
struct tm *tm_ptr; struct tm *tm_ptr;
@ -269,6 +199,20 @@ static void new_header(void)
printf("\n"); printf("\n");
} }
///////////////////////////////////////////////////////////////////////
// based on Fabian Frederick's /proc/diskstats parser
static unsigned int getpartitions_num(struct disk_stat *disks, int ndisks)
{
unsigned int i;
int partitions=0;
for (i=0; i<ndisks; i++) {
partitions+=disks[i].partitions;
}
return partitions;
}
static unsigned long unitConvert(unsigned long size) static unsigned long unitConvert(unsigned long size)
{ {
float cvSize; float cvSize;