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

[tyndur-devel] [PATCH 3/7] libc: file_get_stream()



+ libc: file_get_stream() gibt den LIOv2-Stream zu einem FILE* zurück

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/modules/include/lostio.h   | 5 ++++-
 src/modules/lib/stdlibc/file.c | 9 +++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/modules/include/lostio.h b/src/modules/include/lostio.h
index 9ad8c33..b1c56d5 100644
--- a/src/modules/include/lostio.h
+++ b/src/modules/include/lostio.h
@@ -82,7 +82,8 @@ typedef struct vfstree_node_t
 
 
 ///Handle fuer eine geoeffnete Datei
-struct lostio_internal_file;
+typedef struct lostio_internal_file FILE;
+
 typedef struct
 {
     uint32_t        id;
@@ -152,6 +153,8 @@ struct lostio_internal_file {
 };
 #define IS_LIO2(h) ((h)->lio2_res > 0)
 
+lio_stream_t file_get_stream(FILE *io_res);
+
 ///LostIO-Schnittstelle initialisieren
 void lostio_init(void);
 
diff --git a/src/modules/lib/stdlibc/file.c b/src/modules/lib/stdlibc/file.c
index 60c9e83..b0935bc 100644
--- a/src/modules/lib/stdlibc/file.c
+++ b/src/modules/lib/stdlibc/file.c
@@ -181,6 +181,15 @@ int fclose (FILE* io_res)
     return result ? EOF : 0;
 }
 
+lio_stream_t file_get_stream(FILE *io_res)
+{
+    if (!is_valid_res(io_res) || !IS_LIO2_FILE(io_res)) {
+        return -EBADF;
+    }
+
+    return io_res->res->lio2_stream;
+}
+
 static void prepare_buffer(FILE* io_res, bool is_write)
 {
     if (io_res->buffer_writes == is_write) {
-- 
2.1.4