1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-07 17:26:09 +02:00

write_in_full: really write in full or return error on disk full.

Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Linus Torvalds 2007-01-11 13:04:11 -08:00 committed by Junio C Hamano
parent d145144c3b
commit f6aa66cb95

View File

@ -37,15 +37,14 @@ int write_in_full(int fd, const void *buf, size_t count)
{
const char *p = buf;
ssize_t total = 0;
ssize_t written = 0;
while (count > 0) {
written = xwrite(fd, p, count);
if (written <= 0) {
if (total)
return total;
else
return written;
size_t written = xwrite(fd, p, count);
if (written < 0)
return -1;
if (!written) {
errno = ENOSPC;
return -1;
}
count -= written;
p += written;