The return value check of the write call is completely bogus. We check if we have written at minimum sizeof(struct envfs_super) bytes instead of all bytes. Properly check for all bytes written instead and allow write to write less bytes than requested. Do not use write_full because this file is compiled for userspace aswell. Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- common/environment.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/common/environment.c b/common/environment.c index 9f4e098..bf813b4 100644 --- a/common/environment.c +++ b/common/environment.c @@ -201,11 +201,16 @@ int envfs_save(const char *filename, const char *dirname) goto out1; } - if (write(envfd, buf, size + sizeof(struct envfs_super)) < - sizeof(struct envfs_super)) { - perror("write"); - ret = -1; /* FIXME */ - goto out; + size += sizeof(struct envfs_super); + + while (size) { + ssize_t now = write(envfd, buf, size); + if (now < 0) { + ret = -errno; + goto out; + } + + size -= now; } ret = 0; -- 1.9.1 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox