This patch adds a new internal api function to check if a fdstream is
open. The check is done as an trivial check of private data structures,
as if the stream is closed, those don't exist.
---
src/fdstream.c | 9 +++++++++
src/fdstream.h | 2 ++
src/libvirt_private.syms | 1 +
3 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/src/fdstream.c b/src/fdstream.c
index 8fb5e78..2e2f3af 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -674,3 +674,12 @@ int virFDStreamCreateFile(virStreamPtr st,
offset, length,
oflags | O_CREAT, mode);
}
+
+/* internal function to check if stream is still open */
+int virFDStreamIsOpen(virStreamPtr st)
+{
+ if (!st || !st->privateData)
+ return 0;
+
+ return 1;
+}
diff --git a/src/fdstream.h b/src/fdstream.h
index f9edb23..dbea450 100644
--- a/src/fdstream.h
+++ b/src/fdstream.h
@@ -45,4 +45,6 @@ int virFDStreamCreateFile(virStreamPtr st,
int oflags,
mode_t mode);
+int virFDStreamIsOpen(virStreamPtr st);
+
#endif /* __VIR_FDSTREAM_H_ */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 11ff705..3fa042c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -543,6 +543,7 @@ virFDStreamOpen;
virFDStreamConnectUNIX;
virFDStreamOpenFile;
virFDStreamCreateFile;
+virFDStreamIsOpen;
# hash.h
--
1.7.3.4