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

[UNIKRAFT/MUSL PATCH 5/7] Fix stdout flushing in musl



From: Gaulthier Gain <gaulthier.gain@xxxxxxxxx>

In this commit, we replace our old patch by a more robust patch
series. We temporary remove the call to `ioctl` in `__stdout_write.c`
which causes an assertion error due to invalid argument order. In
addition, `__stdio_write` is fixed by updating a condition to avoid an
infinite loop since the last caracter of the buffer is skipped when
the `cnt` variable is tested with the `iov_len` variable.

Signed-off-by: Gaulthier Gain <gaulthier.gain@xxxxxxxxx>
---
 .../0009-Fix-stdout-flushing-in-musl.patch    | 46 +++++++++++++++++++
 ...09-update__stdout_write_for_flushing.patch | 25 ----------
 2 files changed, 46 insertions(+), 25 deletions(-)
 create mode 100644 patches/0009-Fix-stdout-flushing-in-musl.patch
 delete mode 100644 patches/0009-update__stdout_write_for_flushing.patch

diff --git a/patches/0009-Fix-stdout-flushing-in-musl.patch 
b/patches/0009-Fix-stdout-flushing-in-musl.patch
new file mode 100644
index 0000000..2ad48f7
--- /dev/null
+++ b/patches/0009-Fix-stdout-flushing-in-musl.patch
@@ -0,0 +1,46 @@
+From e38b6114fb02f14ed51870e68116d336aa462add Mon Sep 17 00:00:00 2001
+From: gaulthier gain <gaulthier.gain@xxxxxxxxx>
+Date: Sun, 18 Oct 2020 10:26:45 +0000
+Subject: [PATCH] Fix stdout flushing in musl
+
+In this patch, we temporary remove the call to `ioctl` in
+`__stdout_write.c` which causes an assertion error due to invalid
+argument order. In addition, `__stdio_write` is fixed by updating
+a condition to avoid an infinite loop since the last caracter of the
+buffer is skipped when the `cnt` variable is tested with the
+`iov_len` variable.
+
+Signed-off-by: gaulthier gain <gaulthier.gain@xxxxxxxxx>
+---
+ src/stdio/__stdio_write.c  | 2 +-
+ src/stdio/__stdout_write.c | 2 --
+ 2 files changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c
+index d2d8947..6ebf59e 100644
+--- a/src/stdio/__stdio_write.c
++++ b/src/stdio/__stdio_write.c
+@@ -24,7 +24,7 @@ size_t __stdio_write(FILE *f, const unsigned char *buf, 
size_t len)
+                       return iovcnt == 2 ? 0 : len-iov[0].iov_len;
+               }
+               rem -= cnt;
+-              if (cnt > iov[0].iov_len) {
++              if (cnt >= iov[0].iov_len) {
+                       cnt -= iov[0].iov_len;
+                       iov++; iovcnt--;
+               }
+diff --git a/src/stdio/__stdout_write.c b/src/stdio/__stdout_write.c
+index dd1ec60..1fdc12e 100644
+--- a/src/stdio/__stdout_write.c
++++ b/src/stdio/__stdout_write.c
+@@ -5,7 +5,5 @@ size_t __stdout_write(FILE *f, const unsigned char *buf, 
size_t len)
+ {
+       struct winsize wsz;
+       f->write = __stdio_write;
+-      if (!(f->flags & F_SVB) && __syscall(SYS_ioctl, f->fd, TIOCGWINSZ, 
&wsz))
+-              f->lbf = -1;
+       return __stdio_write(f, buf, len);
+ }
+-- 
+2.17.1
+
diff --git a/patches/0009-update__stdout_write_for_flushing.patch 
b/patches/0009-update__stdout_write_for_flushing.patch
deleted file mode 100644
index bda423f..0000000
--- a/patches/0009-update__stdout_write_for_flushing.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From 235b3d8240fbc99782f2fb8449786f519fcb3bde Mon Sep 17 00:00:00 2001
-From: gaulthier gain <gaulthier.gain@xxxxxxxxx>
-Date: Fri, 28 Feb 2020 17:05:28 +0000
-Subject: [UNIKRAFT/MUSL] Update __stdout_write to allow flushing on stdout
-
-Signed-off-by: gaulthier gain <gaulthier.gain@xxxxxxxxx>
----
- src/stdio/__stdout_write.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/stdio/__stdout_write.c b/src/stdio/__stdout_write.c
-index dd1ec60..f9c9489 100644
---- a/src/stdio/__stdout_write.c
-+++ b/src/stdio/__stdout_write.c
-@@ -6,6 +6,6 @@ size_t __stdout_write(FILE *f, const unsigned char *buf, 
size_t len)
-       struct winsize wsz;
-       f->write = __stdio_write;
-       if (!(f->flags & F_SVB) && __syscall(SYS_ioctl, f->fd, TIOCGWINSZ, 
&wsz))
--              f->lbf = -1;
-+              f->lbf = '\n';
-       return __stdio_write(f, buf, len);
- }
---
-2.17.1
-
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.