[PATCH 06/16] util: Add virSysfsDirOpen

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/libvirt_private.syms |  1 +
 src/util/virsysfs.c      | 17 ++++++++++++++++-
 src/util/virsysfs.h      |  6 ++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9e61accda3fc..3965ef3f89c9 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2621,6 +2621,7 @@ virVasprintfInternal;


 # util/virsysfs.h
+virSysfsDirOpen;
 virSysfsGetCpuValueBitmap;
 virSysfsGetCpuValueInt;
 virSysfsGetCpuValueString;
diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c
index c482e188a301..6686d8ddbfcb 100644
--- a/src/util/virsysfs.c
+++ b/src/util/virsysfs.c
@@ -25,7 +25,6 @@
 #include "virsysfspriv.h"

 #include "viralloc.h"
-#include "virfile.h"
 #include "virlog.h"
 #include "virstring.h"

@@ -120,6 +119,22 @@ virSysfsGetValueBitmap(const char *file,
  * Per-CPU getters
  */
 int
+virSysfsDirOpen(const char *file,
+                DIR **dirp)
+{
+    char *path = NULL;
+
+    if (virAsprintf(&path, "%s/%s", sysfs_system_path, file) < 0)
+        return -1;
+
+    if (!virFileIsDir(path))
+        return -2;
+
+    return virDirOpen(dirp, path);
+}
+
+
+int
 virSysfsGetCpuValueInt(unsigned int cpu,
                        const char *file,
                        int *value)
diff --git a/src/util/virsysfs.h b/src/util/virsysfs.h
index 1b24fc193a16..ff5012d62747 100644
--- a/src/util/virsysfs.h
+++ b/src/util/virsysfs.h
@@ -23,6 +23,8 @@

 # include "internal.h"
 # include "virbitmap.h"
+# include "virfile.h"
+

 /*
  * Generic getters
@@ -41,6 +43,10 @@ int
 virSysfsGetValueBitmap(const char *file,
                        virBitmapPtr *value);

+int
+virSysfsDirOpen(const char *file,
+                DIR **dirp);
+

 /*
  * Per-CPU getters
-- 
2.12.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux