Skip to content

Commit f6aa66c

Browse files
Linus TorvaldsJunio C Hamano
authored andcommitted
write_in_full: really write in full or return error on disk full.
Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent d145144 commit f6aa66c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

write_or_die.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,14 @@ int write_in_full(int fd, const void *buf, size_t count)
3737
{
3838
const char *p = buf;
3939
ssize_t total = 0;
40-
ssize_t written = 0;
4140

4241
while (count > 0) {
43-
written = xwrite(fd, p, count);
44-
if (written <= 0) {
45-
if (total)
46-
return total;
47-
else
48-
return written;
42+
size_t written = xwrite(fd, p, count);
43+
if (written < 0)
44+
return -1;
45+
if (!written) {
46+
errno = ENOSPC;
47+
return -1;
4948
}
5049
count -= written;
5150
p += written;

0 commit comments

Comments
 (0)