[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/3] ios: Introduce ios_flush and ios_dev_<...>_flush.
From: |
Egeyar Bagcioglu |
Subject: |
[PATCH 1/3] ios: Introduce ios_flush and ios_dev_<...>_flush. |
Date: |
Sat, 11 Jul 2020 18:07:24 +0200 |
Those functions are currently ineffective. This is a preparation patch
for stream IO implementation.
2020-07-11 Egeyar Bagcioglu <egeyar@gmail.com>
* 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_mem_flush): New.
* libpoke/ios-dev-nbd.c (ios_dev_nbd_flush): 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 fb42ed4f..4e4f3e63 100644
--- a/libpoke/ios-dev-file.c
+++ b/libpoke/ios-dev-file.c
@@ -203,6 +203,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"))) =
{
@@ -213,4 +219,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 fba99d41..56c3d42b 100644
--- a/libpoke/ios-dev-mem.c
+++ b/libpoke/ios-dev-mem.c
@@ -131,6 +131,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"))) =
{
@@ -141,4 +147,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 cfc68d48..9ed1834e 100644
--- a/libpoke/ios-dev-nbd.c
+++ b/libpoke/ios-dev-nbd.c
@@ -169,6 +169,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"))) =
{
@@ -179,4 +185,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 217e96c6..36fc88e4 100644
--- a/libpoke/ios.c
+++ b/libpoke/ios.c
@@ -1517,3 +1517,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 5c1f59ef..ab44ac68 100644
--- a/libpoke/ios.h
+++ b/libpoke/ios.h
@@ -352,6 +352,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/3] ios: Introduce ios_flush and ios_dev_<...>_flush.,
Egeyar Bagcioglu <=
- [PATCH 2/3] ios: Move file name normalization logic into ios-dev.h, Egeyar Bagcioglu, 2020/07/11
- Re: [PATCH 2/3] ios: Move file name normalization logic into ios-dev.h, Jose E. Marchesi, 2020/07/12
- Re: [PATCH 2/3] ios: Move file name normalization logic into ios-dev.h, Egeyar Bagcioglu, 2020/07/12
- Re: [PATCH 2/3] ios: Move file name normalization logic into ios-dev.h, Egeyar Bagcioglu, 2020/07/13
- Re: [PATCH 2/3] ios: Move file name normalization logic into ios-dev.h, Jose E. Marchesi, 2020/07/13
- Re: [PATCH 2/3] ios: Move file name normalization logic into ios-dev.h, Jose E. Marchesi, 2020/07/13
- Re: [PATCH 2/3] ios: Move file name normalization logic into ios-dev.h, Egeyar Bagcioglu, 2020/07/14
[PATCH 3/3] ios: Pass "flags" to handler_normalize as an argument., Egeyar Bagcioglu, 2020/07/11