char buf[1024];
char *str = buf;
FILE *file = fopen(STATFILE, "r");
- int user, nice, sys, idle, wait, irq, softirq;
+ long long user, nice, sys, idle, wait, irq, softirq;
if (file == NULL) {
pr_err("Failed to open file %s\n", STATFILE);
return -1;
}
- user = dec_to_int(str, &str);
- nice = dec_to_int(str, &str);
- sys = dec_to_int(str, &str);
- idle = dec_to_int(str, &str);
- wait = dec_to_int(str, &str);
- irq = dec_to_int(str, &str);
- softirq = dec_to_int(str, &str);
+ user = dec_to_longlong(str, &str);
+ nice = dec_to_longlong(str, &str);
+ sys = dec_to_longlong(str, &str);
+ idle = dec_to_longlong(str, &str);
+ wait = dec_to_longlong(str, &str);
+ irq = dec_to_longlong(str, &str);
+ softirq = dec_to_longlong(str, &str);
- sprintf(data, "%d:%d:%d:%d:%d:%d:%d",
+ sprintf(data, "%lld:%lld:%lld:%lld:%lld:%lld:%lld",
user, nice, sys, idle, wait, irq, softirq);
fclose(file);
#include <stdlib.h>
int dec_to_int(char *src, char **dst);
+int dec_to_longlong(char *src, char **dst);
float dec_to_float(char *src, char **dst);
int get_word(char *src, char **dst, char *word, int size);