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

[tyndur-devel] [PATCH 1/3] libc: lio_seek von FILE auf io_resource_t umgestellt



* libc: lio_seek braucht eigentlich kein ganzes FILE, sondern ein
  io_resource_t reicht auch.

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/modules/c/shell/cmds/bincat.c    |    2 +-
 src/modules/cdi/lib/fs/fs.c          |    4 ++--
 src/modules/include/lostio.h         |    2 +-
 src/modules/lib/lostio/client/seek.c |   13 ++++---------
 src/modules/lib/stdlibc/file.c       |    2 +-
 5 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/src/modules/c/shell/cmds/bincat.c b/src/modules/c/shell/cmds/bincat.c
index 5e294b2..d21d4d9 100644
--- a/src/modules/c/shell/cmds/bincat.c
+++ b/src/modules/c/shell/cmds/bincat.c
@@ -136,7 +136,7 @@ void bincat_display_usage(void);
 
     FILE* file = fopen(path, "r");
 
-    lio_seek(file, start, SEEK_SET);
+    fseek(file, start, SEEK_SET);
     m = start - 8;
 
     if (file == NULL) {
diff --git a/src/modules/cdi/lib/fs/fs.c b/src/modules/cdi/lib/fs/fs.c
index 941c961..6b24231 100644
--- a/src/modules/cdi/lib/fs/fs.c
+++ b/src/modules/cdi/lib/fs/fs.c
@@ -149,7 +149,7 @@ void cdi_fs_driver_register(struct cdi_fs_driver* driver)
 size_t cdi_fs_data_read(struct cdi_fs_filesystem* fs, uint64_t start,
     size_t size, void* buffer)
 {
-    if (!lio_seek(fs->device, start, SEEK_SET)) {
+    if (!fseek(fs->device, start, SEEK_SET)) {
         return -1;
     }
 
@@ -170,7 +170,7 @@ size_t cdi_fs_data_read(struct cdi_fs_filesystem* fs, uint64_t start,
 size_t cdi_fs_data_write(struct cdi_fs_filesystem* fs, uint64_t start,
     size_t size, const void* buffer)
 {
-    if (!lio_seek(fs->device, start, SEEK_SET)) {
+    if (!fseek(fs->device, start, SEEK_SET)) {
         return -1;
     }
 
diff --git a/src/modules/include/lostio.h b/src/modules/include/lostio.h
index d94488c..e5b90f2 100644
--- a/src/modules/include/lostio.h
+++ b/src/modules/include/lostio.h
@@ -204,7 +204,7 @@ size_t lio_compat_write(const void* src, size_t blocksize, size_t blockcount,
     io_resource_t* io_res);
 
 /// Stream-Position setzen
-bool lio_seek(struct lostio_internal_file* io_res, uint64_t offset, int origin);
+bool lio_seek(io_resource_t* io_res, uint64_t offset, int origin);
 
 /** @}  */
 
diff --git a/src/modules/lib/lostio/client/seek.c b/src/modules/lib/lostio/client/seek.c
index 5f6108d..3cfcd6b 100644
--- a/src/modules/lib/lostio/client/seek.c
+++ b/src/modules/lib/lostio/client/seek.c
@@ -36,27 +36,22 @@
  *
  * @param io_res Dateihandle
  * @param offset Offset bezogen auf den mit origin festgelegten Ursprung
- * @param origin Ursprung. Moeglichkeiten: 
+ * @param origin Ursprung. Moeglichkeiten:
  *                  - SEEK_SET Bezogen auf Dateianfang
  *                  - SEEK_CUR Bezogen auf die aktuelle Position
  *                  - SEEK_END Bezogen auf das Ende der Datei
  *
  * @return true wenn die Position erfolgreich gesetzt wurde, sonst false
  */
-bool lio_seek(FILE* io_res, uint64_t offset, int origin)
+bool lio_seek(io_resource_t* io_res, uint64_t offset, int origin)
 {
     io_seek_request_t seek_request;
-    
-    // Ungueltige Handles abfangen
-    if ((io_res == NULL) || (io_res->res->pid == 0)) {
-        return false;
-    }
 
-    seek_request.id = io_res->res->id;
+    seek_request.id = io_res->id;
     seek_request.offset = offset;
     seek_request.origin = origin;
 
-    return (rpc_get_dword(io_res->res->pid, "IO_SEEK ", sizeof(io_seek_request_t),
+    return (rpc_get_dword(io_res->pid, "IO_SEEK ", sizeof(io_seek_request_t),
         (char*) &seek_request) == 0);
 }
 
diff --git a/src/modules/lib/stdlibc/file.c b/src/modules/lib/stdlibc/file.c
index daa5f86..1a99417 100644
--- a/src/modules/lib/stdlibc/file.c
+++ b/src/modules/lib/stdlibc/file.c
@@ -487,7 +487,7 @@ int fseek (FILE* io_res, long int offset, int origin)
         free(io_res->ungetc_buffer);
     }
 
-    return (lio_seek(io_res, offset, origin) ? 0 : -1);
+    return (lio_seek(io_res->res, offset, origin) ? 0 : -1);
 }
 
 
-- 
1.6.0.2