Hello Samuel,

Something like this fixes the D_WOULD_BLOCK errno for me.
--8<---------------cut here---------------start------------->8---
diff --git a/trans/streamio.c b/trans/streamio.c
index e42ff908..93057146 100644
--- a/trans/streamio.c
+++ b/trans/streamio.c
@@ -1049,6 +1049,8 @@ device_read_reply_inband (mach_port_t reply, 
kern_return_t errorcode,
 
   input_pending = 0;
   err = errorcode;
+  if (err == D_WOULD_BLOCK)
+    err = EWOULDBLOCK;
   if (!err)
     {
       if (datalen == 0)
--8<---------------cut here---------------end--------------->8---


This error is then returned by the initial check for the global error in 
dev_read.


One other thing that I found is that the "last" line in the kernel log is 
missing a terminating newline. Is there a way to add it?
Thanks.


Apr 21, 2025, 15:24 by samuel.thiba...@gnu.org:

> Ludovic Courtès, le lun. 21 avril 2025 16:59:03 +0200, a ecrit:
>
>> Samuel Thibault <samuel.thiba...@gnu.org> writes:
>> > dev_read starts with if (err) return err;. Various functions do not
>> > define their own err variable. I don't know the original reason for
>> > this, but this looks fishy to me, and local variables should probably
>> > always be used, patch welcome.
>>
>> I wondered about that: access to the underlying device is serialized
>> (‘trivfs_S_io_read’ & co. start by acquiring ‘global_lock’), and there’s
>> this global ‘err’ variable, and I thought the intent may be to memorize
>> what error occurred previously and avoid initiating a new device
>> operation until it is cleared.
>>
>> So at least this seems to be internally consistent, no?
>>
>
> Possibly, but this is surprising, and I would be not surprised at all
> that some changeset got this wrong. See e.g. start_output which uses the
> global variable while start_input which doesn't. At the very least, I
> would call this global variable another way.
>
> Samuel
>


Reply via email to