Revision 7b5f699d
b/osdep.c | ||
---|---|---|
243 | 243 |
return ret; |
244 | 244 |
} |
245 | 245 |
|
246 |
/* |
|
247 |
* A variant of write(2) which handles partial write. |
|
248 |
* |
|
249 |
* Return the number of bytes transferred. |
|
250 |
* Set errno if fewer than `count' bytes are written. |
|
251 |
*/ |
|
252 |
ssize_t qemu_write_full(int fd, const void *buf, size_t count) |
|
253 |
{ |
|
254 |
ssize_t ret = 0; |
|
255 |
ssize_t total = 0; |
|
256 |
|
|
257 |
while (count) { |
|
258 |
ret = write(fd, buf, count); |
|
259 |
if (ret < 0) { |
|
260 |
if (errno == EINTR) |
|
261 |
continue; |
|
262 |
break; |
|
263 |
} |
|
264 |
|
|
265 |
count -= ret; |
|
266 |
buf += ret; |
|
267 |
total += ret; |
|
268 |
} |
|
269 |
|
|
270 |
return total; |
|
271 |
} |
|
272 |
|
|
246 | 273 |
#ifndef _WIN32 |
247 | 274 |
/* |
248 | 275 |
* Creates a pipe with FD_CLOEXEC set on both file descriptors |
b/qemu-common.h | ||
---|---|---|
161 | 161 |
void qemu_mutex_unlock_iothread(void); |
162 | 162 |
|
163 | 163 |
int qemu_open(const char *name, int flags, ...); |
164 |
ssize_t qemu_write_full(int fd, const void *buf, size_t count); |
|
164 | 165 |
void qemu_set_cloexec(int fd); |
165 | 166 |
|
166 | 167 |
#ifndef _WIN32 |
Also available in: Unified diff