Re: [PATCH] 9p: treat read return values of 0 as EOF

From: Dominique Martinet

Date: Fri Jul 03 2026 - 10:38:59 EST


Barret Rhoden wrote on Thu, Jul 02, 2026 at 09:09:32AM +0000:
> If your 9p server shares a synthetic file system such as sysfs, the file
> size from stat often disagrees with the actual file size.
>
> Treat non-error reads of 0 as EOF, except in the case where the request
> was for 0 bytes.

> Tested:
> git@xxxxxxxxxx:hugelgupf/p9.git, served "/" on 10.0.2.2
>
> bash-5.3# mount -t 9p -o trans=tcp,port=12345,cache=none 10.0.2.2 /tmp/foo
> bash-5.3# cat /tmp/foo/sys/devices/system/cpu/online
> 0-47

David,
that looks like something that should be handled in netfs - is it right
to do this on the 9p side?

I've just tried with qemu and with cache=none I get ENODATA, with
cache=loose I get the data followed by 4094 zeroes...

Interestingly there also are files with 0 size e.g.
/sys/devices/virtual/net/br0/brforward,
and for this one with cache=none I can read it fine, but with
cache=loose I get an empty file.


Barret,
thanks for the patch, please give us a bit of time to check; I'm
sometimes slow to reply (like for your sending the patch first without
the [PATCH] tag in subject) but I did see it, just hard to find time to
review...

Cheers,
--
Dominique