- submit_one (plinst, entry, hpsize, value);
-
- fclose(fh);
- return 0;
-}
-
-static int read_syshugepage_dir(const char* path, const char* dirhpsize,
- const char* node)
-{
- DIR *dir = NULL;
- struct dirent *entry = NULL;
- struct dirent *result = NULL;
- size_t name_max = 0;
- size_t len = 0;
-
- dir = opendir(path);
- if (NULL == dir) {
- ERROR("Cannot open directory %s", path);
- return -1;
- }
-
- name_max = pathconf(path, _PC_NAME_MAX);
- if (name_max == -1) { /* Limit not defined, or error */
- name_max = 255; /* Take a guess */
- }
-
- len = offsetof(struct dirent, d_name) + name_max + 1;
- entry = malloc(len);
- if (entry == NULL) {
- ERROR("Malloc returned NULL");
- return -1;
+ if (strcmp(entry, "nr_hugepages") == 0) {
+ used_hp += value;
+ flag++;
+ } else if (strcmp(entry, "surplus_hugepages") == 0) {
+ used_hp += value;
+ flag++;
+ } else if (strcmp(entry, "free_hugepages") == 0) {
+ used_hp -= value;
+ free_hp = value;
+ flag++;