mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
9p: treat read return values of 0 as EOF
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@github.com: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
Fixes: eb497943fa ("9p: Convert to using the netfs helper lib to do reads and caching")
Signed-off-by: Barret Rhoden <brho@google.com>
Message-ID: <20260702090941.1298188-1-brho@google.com>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
This commit is contained in:
parent
9b4cf60c6b
commit
a3a6212c7d
|
|
@ -99,6 +99,7 @@ static void v9fs_issue_read(struct netfs_io_subrequest *subreq)
|
|||
char *target;
|
||||
unsigned long long pos = subreq->start + subreq->transferred;
|
||||
int total = 0, err, len, n;
|
||||
size_t to_read = iov_iter_count(&subreq->io_iter);
|
||||
|
||||
if (S_ISLNK(rreq->inode->i_mode)) {
|
||||
/* p9_client_readlink() must not be called for legacy protocols
|
||||
|
|
@ -131,6 +132,8 @@ static void v9fs_issue_read(struct netfs_io_subrequest *subreq)
|
|||
__set_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags);
|
||||
if (pos + total >= i_size_read(rreq->inode))
|
||||
__set_bit(NETFS_SREQ_HIT_EOF, &subreq->flags);
|
||||
if (!err && !total && to_read)
|
||||
__set_bit(NETFS_SREQ_HIT_EOF, &subreq->flags);
|
||||
if (!err && total) {
|
||||
subreq->transferred += total;
|
||||
__set_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user