/*
- * Copyright (C) 2006-2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2006-2009 Andre Noll <maan@systemlinux.org>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
#include "log.h"
#include "osl.h"
-#include "error.h"
#include "util.h"
/**
ret = write(fd, buf, size);
if ((ret < 0) && (errno == EAGAIN || errno == EINTR))
continue;
- return ret >= 0? ret : -ERRNO_TO_ERROR(errno);
+ return ret >= 0? ret : -E_OSL_WRITE;
}
}
*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 -ERRNO_TO_ERROR(errno);
+ return errno == ENOENT? -E_OSL_NOENT : -E_OSL_OPEN;
}
/**
return ret;
fd = ret;
if (fstat(fd, &file_status) < 0) {
- ret = -ERRNO_TO_ERROR(errno);
+ ret = errno == ENOENT? -E_OSL_NOENT : -E_OSL_STAT;
goto out;
}
*size = file_status.st_size;
err = errno;
ERROR_LOG("munmap (%p/%zu) failed: %s\n", start, length,
strerror(err));
- return -ERRNO_TO_ERROR(err);
+ return -E_OSL_MUNMAP;
}
/**
if (statbuf.st_size < size)
return ret;
if (truncate(path, statbuf.st_size - size) < 0)
- return -ERRNO_TO_ERROR(errno);
+ return -E_OSL_TRUNCATE;
return 1;
}