]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/LibC/Uefi/writev.c
3 * Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software must
16 * display the following acknowledgement:
18 * This product includes software developed by Intel Corporation and its
21 * 4. Neither the name of Intel Corporation or its contributors may be used to
22 * endorse or promote products derived from this software without specific
23 * prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR CONTRIBUTORS BE LIABLE FOR
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
32 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 Functions implementing the standard "writev" system call interface
52 #include <LibConfig.h>
55 #include <efi_interface.h>
61 #include "./filedesc.h"
63 #include <libc_debug.h>
84 // BSD writev interface for libc
87 // File Descriptor (index into file descriptor table)
89 // size of iovec array
92 // number of bytes written
98 const struct iovec
*iov
,
102 const struct iovec
*pVecTmp
;
109 // See how much memory we'll need
112 for (i
= 0, TotalBytes
= 0, pVecTmp
= iov
; i
< (size_t)iovcnt
; i
++, pVecTmp
++) {
113 TotalBytes
+= pVecTmp
->iov_len
;
117 // Allocate a contiguous buffer
120 pBuf
= (char*)malloc (TotalBytes
);
127 // Copy vectors to the buffer
130 for (; iovcnt
; iovcnt
--) {
131 bcopy(iov
->iov_base
, pBuf
, iov
->iov_len
);
132 pBuf
+= iov
->iov_len
;
137 // Use standard write(2) then free buffer
140 ret
= write (fd
, pBuf
, TotalBytes
);