blob: 11f60905525364482a4d7387c0d74511fb14367f [file] [log] [blame]
Jeremy Kerr1a0e03b2016-03-08 17:57:11 +08001
2
3#include <err.h>
4#include <unistd.h>
5
6#include "console-server.h"
7
8int write_buf_to_fd(int fd, const uint8_t *buf, size_t len)
9{
10 size_t pos;
11 ssize_t rc;
12
13 for (pos = 0; pos < len; pos += rc) {
14 rc = write(fd, buf + pos, len - pos);
15 if (rc <= 0) {
16 warn("Write error");
17 return -1;
18 }
19 }
20
21 return 0;
22}
23