44 size_t ret, writepart;
46 char *writebuf = NULL;
49 for (i = 0; i < iovcnt; ++i) {
50 writebuf = (
char *)iov[i].iov_base;
51 bytestowrite = iov[i].iov_len;
52 if (bytestowrite == 0) {
60 bytestowrite = (totallen < bytestowrite) ? totallen : bytestowrite;
63 if (ret == bytestowrite) {
67 writepart = bytestowrite - ret;
69 totallen -= writepart;
73 curbuf += bytestowrite;
74 totallen -= bytestowrite;
77 return (
int)((intptr_t)curbuf - (intptr_t)buf);
89 if ((iov == NULL) || (iovcnt > IOV_MAX)) {
93 for (i = 0; i < iovcnt; ++i) {
94 if (SSIZE_MAX - buflen < iov[i].iov_len) {
98 buflen += iov[i].iov_len;
105 totallen = buflen *
sizeof(char);
106#ifdef LOSCFG_KERNEL_VM
109 buf = (
char *)
malloc(totallen);
117#ifdef LOSCFG_KERNEL_VM
126 totalbyteswritten = (offset == NULL) ? write(fd, buf, bytestowrite)
127 : pwrite(fd, buf, bytestowrite, *offset);
128#ifdef LOSCFG_KERNEL_VM
133 return totalbyteswritten;
VOID LOS_VFree(const VOID *addr)
VOID * LOS_VMalloc(size_t size)
void * malloc(size_t size)
动态分配内存块大小
void free(void *ptr)
释放ptr所指向的内存空间
INT32 LOS_CopyToKernel(VOID *dest, UINT32 max, const VOID *src, UINT32 count)
将用户空间的数据拷贝到内核空间
ssize_t vfs_writev(int fd, const struct iovec *iov, int iovcnt, off_t *offset)
ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
static int iov_trans_to_buf(char *buf, ssize_t totallen, const struct iovec *iov, int iovcnt)