@@ -104,4 +104,14 @@ eal_get_hugefile_path(char *buffer, size_t buflen, const char *hugedir, int f_id
* Used to read information from files on /sys */
int eal_parse_sysfs_value(const char *filename, unsigned long *val);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Function to read a line from a file on the filesystem.
+ * Used to read information from files on /sys
+ */
+__rte_experimental
+int rte_eal_parse_sysfs_str(const char *filename, char *buf, unsigned long sz);
+
#endif /* EAL_FILESYSTEM_H */
@@ -209,6 +209,28 @@ eal_parse_sysfs_value(const char *filename, unsigned long *val)
return 0;
}
+int
+rte_eal_parse_sysfs_str(const char *filename, char *buf, unsigned long sz)
+{
+ FILE *f;
+
+ f = fopen(filename, "r");
+ if (f == NULL) {
+ RTE_LOG(ERR, EAL, "%s(): cannot open sysfs file %s\n",
+ __func__, filename);
+ return -1;
+ }
+
+ if (fgets(buf, sz, f) == NULL) {
+ RTE_LOG(ERR, EAL, "%s(): cannot read sysfs file %s\n",
+ __func__, filename);
+ fclose(f);
+ return -1;
+ }
+
+ fclose(f);
+ return 0;
+}
/* create memory configuration in shared/mmap memory. Take out
* a write lock on the memsegs, so we can auto-detect primary/secondary.
@@ -295,6 +295,28 @@ eal_parse_sysfs_value(const char *filename, unsigned long *val)
return 0;
}
+int
+rte_eal_parse_sysfs_str(const char *filename, char *buf, unsigned long sz)
+{
+ FILE *f;
+
+ f = fopen(filename, "r");
+ if (f == NULL) {
+ RTE_LOG(ERR, EAL, "%s(): cannot open sysfs file %s\n",
+ __func__, filename);
+ return -1;
+ }
+
+ if (fgets(buf, sz, f) == NULL) {
+ RTE_LOG(ERR, EAL, "%s(): cannot read sysfs file %s\n",
+ __func__, filename);
+ fclose(f);
+ return -1;
+ }
+
+ fclose(f);
+ return 0;
+}
/* create memory configuration in shared/mmap memory. Take out
* a write lock on the memsegs, so we can auto-detect primary/secondary.
@@ -331,6 +331,7 @@ EXPERIMENTAL {
rte_dev_hotplug_handle_enable;
rte_dev_iterator_init;
rte_dev_iterator_next;
+ rte_eal_parse_sysfs_str;
rte_extmem_attach;
rte_extmem_detach;
rte_extmem_register;