48 if ((iov == NULL) || (iovcnt > IOV_MAX)) {
49 *totalbytesread = VFS_ERROR;
53 for (i = 0; i < iovcnt; ++i) {
54 if (SSIZE_MAX - buflen < iov[i].iov_len) {
58 buflen += iov[i].iov_len;
66#ifdef LOSCFG_KERNEL_VM
69 buf = (
char *)
malloc(buflen *
sizeof(
char));
73 *totalbytesread = VFS_ERROR;
77 *totalbytesread = (offset == NULL) ? read(fd, buf, buflen)
78 : pread(fd, buf, buflen, *offset);
79 if ((*totalbytesread == VFS_ERROR) || (*totalbytesread == 0)) {
80#ifdef LOSCFG_KERNEL_VM
103 return totalbytesread;
107 bytesleft = totalbytesread;
108 for (i = 0; i < iovcnt; ++i) {
109 bytestoread = iov[i].iov_len;
110 if (bytestoread == 0) {
114 if (bytesleft <= bytestoread) {
122 bytesleft = bytesleft - (bytestoread - ret);
125 bytesleft -= bytestoread;
126 curbuf += bytestoread;
130#ifdef LOSCFG_KERNEL_VM
135 if ((i == 0) && (ret == iov[i].iov_len)) {
141 return totalbytesread - bytesleft;
VOID LOS_VFree(const VOID *addr)
VOID * LOS_VMalloc(size_t size)
void * malloc(size_t size)
动态分配内存块大小
void free(void *ptr)
释放ptr所指向的内存空间
INT32 LOS_CopyFromKernel(VOID *dest, UINT32 max, const VOID *src, UINT32 count)
将内核数据拷贝到用户空间
static char * pread_buf_and_check(int fd, const struct iovec *iov, int iovcnt, ssize_t *totalbytesread, off_t *offset)
ssize_t readv(int fd, const struct iovec *iov, int iovcnt)
ssize_t vfs_readv(int fd, const struct iovec *iov, int iovcnt, off_t *offset)
供系统调用