[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] ios: Introduce ios_flush and ios_dev_<...>_flush.
From: |
Egeyar Bagcioglu |
Subject: |
[PATCH 1/2] ios: Introduce ios_flush and ios_dev_<...>_flush. |
Date: |
Sun, 10 May 2020 18:27:24 +0200 |
Those functions are currently ineffective. This is a preparation patch
for stream IO implementation.
2020-05-10 Egeyar Bagcioglu <address@hidden>
* libpoke/ios.h (ios_flush): New.
* libpoke/ios.c (ios_flush): New.
* libpoke/ios-dev.h (struct ios_dev_if): Add new member "flush".
* libpoke/ios-dev-file.c (ios_dev_file_flush): New.
* libpoke/ios-dev-mem.c (ios_dev_file_mem): New.
* libpoke/ios-dev-nbd.c (ios_dev_file_nbd): New.
---
libpoke/ios-dev-file.c | 7 +++++++
libpoke/ios-dev-mem.c | 7 +++++++
libpoke/ios-dev-nbd.c | 7 +++++++
libpoke/ios-dev.h | 5 +++++
libpoke/ios.c | 6 ++++++
libpoke/ios.h | 8 ++++++++
6 files changed, 40 insertions(+)
diff --git a/libpoke/ios-dev-file.c b/libpoke/ios-dev-file.c
index 14b6ba0a..84d36109 100644
--- a/libpoke/ios-dev-file.c
+++ b/libpoke/ios-dev-file.c
@@ -188,6 +188,12 @@ ios_dev_file_size (void *iod)
return st.st_size;
}
+static int
+ios_dev_file_flush (void *iod, ios_dev_off offset)
+{
+ return IOS_OK;
+}
+
struct ios_dev_if ios_dev_file
__attribute__ ((visibility ("hidden"))) =
{
@@ -198,4 +204,5 @@ struct ios_dev_if ios_dev_file
.pwrite = ios_dev_file_pwrite,
.get_flags = ios_dev_file_get_flags,
.size = ios_dev_file_size,
+ .flush = ios_dev_file_flush
};
diff --git a/libpoke/ios-dev-mem.c b/libpoke/ios-dev-mem.c
index 88b370ad..b0f8d25c 100644
--- a/libpoke/ios-dev-mem.c
+++ b/libpoke/ios-dev-mem.c
@@ -114,6 +114,12 @@ ios_dev_mem_size (void *iod)
return mio->size;
}
+static int
+ios_dev_mem_flush (void *iod, ios_dev_off offset)
+{
+ return IOS_OK;
+}
+
struct ios_dev_if ios_dev_mem
__attribute__ ((visibility ("hidden"))) =
{
@@ -124,4 +130,5 @@ struct ios_dev_if ios_dev_mem
.pwrite = ios_dev_mem_pwrite,
.get_flags = ios_dev_mem_get_flags,
.size = ios_dev_mem_size,
+ .flush = ios_dev_mem_flush,
};
diff --git a/libpoke/ios-dev-nbd.c b/libpoke/ios-dev-nbd.c
index bb8227b0..e0c8bb2f 100644
--- a/libpoke/ios-dev-nbd.c
+++ b/libpoke/ios-dev-nbd.c
@@ -156,6 +156,12 @@ ios_dev_nbd_size (void *iod)
return nio->size;
}
+static int
+ios_dev_nbd_flush (void *iod, ios_dev_off offset)
+{
+ return IOS_OK;
+}
+
struct ios_dev_if ios_dev_nbd
__attribute__ ((visibility ("hidden"))) =
{
@@ -166,4 +172,5 @@ struct ios_dev_if ios_dev_nbd
.pwrite = ios_dev_nbd_pwrite,
.get_flags = ios_dev_nbd_get_flags,
.size = ios_dev_nbd_size,
+ .flush = ios_dev_nbd_flush,
};
diff --git a/libpoke/ios-dev.h b/libpoke/ios-dev.h
index fa5f6a06..8461bb35 100644
--- a/libpoke/ios-dev.h
+++ b/libpoke/ios-dev.h
@@ -79,4 +79,9 @@ struct ios_dev_if
/* Return the size of the device, in bytes. */
ios_dev_off (*size) (void *dev);
+
+ /* If called on a in-stream, free the buffer before OFFSET. If called on
+ an out-stream, flush the data till OFFSET and free the buffer before
+ OFFSET. Otherwise, do not do anything. */
+ int (*flush) (void *dev, ios_dev_off offset);
};
diff --git a/libpoke/ios.c b/libpoke/ios.c
index f3201f4f..6f8bcd6b 100644
--- a/libpoke/ios.c
+++ b/libpoke/ios.c
@@ -1489,3 +1489,9 @@ ios_size (ios io)
{
return io->dev_if->size (io->dev) * 8;
}
+
+int
+ios_flush (ios io, ios_off offset)
+{
+ return io->dev_if->flush (io->dev, offset);
+}
diff --git a/libpoke/ios.h b/libpoke/ios.h
index 2bdc2fa6..0837f1b0 100644
--- a/libpoke/ios.h
+++ b/libpoke/ios.h
@@ -350,6 +350,14 @@ int ios_write_string (ios io, ios_off offset, int flags,
const char *value)
__attribute__ ((visibility ("hidden")));
+/* If the current IOD is a write stream, write out the data in the buffer
+ till OFFSET. If the current IOD is a stream IOD, free (if allowed by the
+ embedded buffering strategy) bytes up to OFFSET. This function has no
+ impact when called on other IO devices. */
+
+int ios_flush (ios io, ios_off offset)
+ __attribute__ ((visibility ("hidden")));
+
/* **************** Update API **************** */
/* XXX: writeme. */
--
2.25.4
- [PATCH 1/2] ios: Introduce ios_flush and ios_dev_<...>_flush.,
Egeyar Bagcioglu <=
- [PATCH 2/2] ios: Introduce IO stream device for stdin, stdout, stderr., Egeyar Bagcioglu, 2020/05/10
- Re: [PATCH 2/2] ios: Introduce IO stream device for stdin, stdout, stderr., Jose E. Marchesi, 2020/05/10
- Re: [PATCH 2/2] ios: Introduce IO stream device for stdin, stdout, stderr., Jose E. Marchesi, 2020/05/10
- Re: [PATCH 2/2] ios: Introduce IO stream device for stdin, stdout, stderr., Jose E. Marchesi, 2020/05/10
- Re: [PATCH 1/2] ios: Introduce ios_flush and ios_dev_<...>_flush., Jose E. Marchesi, 2020/05/10