/*
- * Copyright (C) 2006-2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2006-2009 Andre Noll <maan@tuebingen.mpg.de>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
#include "log.h"
#include "osl.h"
-#include "error.h"
#include "util.h"
/**
*len = 0;
while (*len < total) {
int ret = __write(fd, buf + *len, total - *len);
- if (ret < 0)
+ if (ret < 0) {
+ ERROR_LOG("write error: %s\n", strerror(errno));
return ret;
+ }
*len += ret;
}
return 1;
if (ret >= 0)
return ret;
- return -E_OSL_OPEN;
+ return errno == ENOENT? -E_OSL_NOENT : -E_OSL_OPEN;
}
/**
if (ret < 0)
return ret;
fd = ret;
- ret = write_all(fd, buf, &size);
- if (ret < 0)
- goto out;
+ if (size != 0) {
+ ret = write_all(fd, buf, &size);
+ if (ret < 0)
+ goto out;
+ }
ret = 1;
out:
close(fd);
return ret;
fd = ret;
if (fstat(fd, &file_status) < 0) {
- ret = -E_OSL_FSTAT;
+ ret = errno == ENOENT? -E_OSL_NOENT : -E_OSL_STAT;
goto out;
}
*size = file_status.st_size;
n = vsnprintf(p, size, fmt, ap);
va_end(ap);
/* If that worked, return the string. */
- if (n > -1 && n < size)
+ if (n > -1 && (unsigned)n < size)
break;
/* Else try again with more space. */
if (n > -1) /* glibc 2.1 */