aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/linux/sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vppinfra/linux/sysfs.c')
-rw-r--r--src/vppinfra/linux/sysfs.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/vppinfra/linux/sysfs.c b/src/vppinfra/linux/sysfs.c
index 1157e4fe655..758eaa1a86c 100644
--- a/src/vppinfra/linux/sysfs.c
+++ b/src/vppinfra/linux/sysfs.c
@@ -16,6 +16,7 @@
#include <vppinfra/clib.h>
#include <vppinfra/clib_error.h>
#include <vppinfra/format.h>
+#include <vppinfra/bitmap.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -262,6 +263,32 @@ clib_sysfs_prealloc_hugepages (int numa_node, int log2_page_size, int nr)
return clib_sysfs_set_nr_hugepages (numa_node, log2_page_size, n + needed);
}
+__clib_export uword *
+clib_sysfs_list_to_bitmap (char *filename)
+{
+ FILE *fp;
+ uword *r = 0;
+
+ fp = fopen (filename, "r");
+
+ if (fp != NULL)
+ {
+ u8 *buffer = 0;
+ vec_validate (buffer, 256 - 1);
+ if (fgets ((char *) buffer, 256, fp))
+ {
+ unformat_input_t in;
+ unformat_init_string (&in, (char *) buffer,
+ strlen ((char *) buffer));
+ if (unformat (&in, "%U", unformat_bitmap_list, &r) != 1)
+ clib_warning ("unformat_bitmap_list failed");
+ unformat_free (&in);
+ }
+ vec_free (buffer);
+ fclose (fp);
+ }
+ return r;
+}
/*
* fd.io coding-style-patch-verification: ON