1 #include "stdio_impl.h"
4 size_t __stdio_read(FILE *f
, unsigned char *buf
, size_t len
)
6 struct iovec iov
[2] = {
7 { .iov_base
= buf
, .iov_len
= len
- !!f
->buf_size
},
8 { .iov_base
= f
->buf
, .iov_len
= f
->buf_size
}
12 cnt
= iov
[0].iov_len
? syscall(SYS_readv
, f
->fd
, iov
, 2)
13 : syscall(SYS_read
, f
->fd
, iov
[1].iov_base
, iov
[1].iov_len
);
15 f
->flags
|= cnt
? F_ERR
: F_EOF
;
18 if (cnt
<= iov
[0].iov_len
) return cnt
;
19 cnt
-= iov
[0].iov_len
;
21 f
->rend
= f
->buf
+ cnt
;
22 if (f
->buf_size
) buf
[len
-1] = *f
->rpos
++;