2007-06-05 04:29:16 +02:00
use set_error instead of printf in library to report errors.
2007-10-16 17:49:45 +02:00
From: Ludwig Nussel <ludwig.nussel@suse.de>
2007-06-05 04:29:16 +02:00
Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
2007-10-16 17:49:45 +02:00
---
2007-06-05 04:29:16 +02:00
2007-10-16 17:49:45 +02:00
lib/utils.c | 2 +-
luks/keyencryption.c | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/utils.c b/lib/utils.c
index fbf34bc..b9fc006 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -227,7 +227,7 @@ ssize_t read_blockwise(int fd, void *orig_buf, size_t count) {
2007-06-05 04:29:16 +02:00
while(count) {
r = read(fd,padbuf,bsize);
if(r < 0 || r != bsize) {
- fprintf(stderr, "read failed in read_blockwise.\n");
+ set_error("read failed in read_blockwise()");
goto out;
}
step = count<bsize?count:bsize;
2007-10-16 17:49:45 +02:00
diff --git a/luks/keyencryption.c b/luks/keyencryption.c
index f154a01..de02f50 100644
--- a/luks/keyencryption.c
+++ b/luks/keyencryption.c
@@ -58,7 +58,7 @@ static int setup_mapping(const char *cipher, const char *name,
2007-06-05 04:29:16 +02:00
* device's sector size, otherwise the mapping will be refused.
*/
if(device_sector_size < 0) {
- fprintf(stderr,_("Unable to obtain sector size for %s"),device);
+ set_error(_("Unable to obtain sector size for %s"),device);
return -EINVAL;
}
options->size = round_up_modulo(srcLength,device_sector_size)/SECTOR_SIZE;
2007-10-16 17:49:45 +02:00
@@ -138,7 +138,8 @@ static int LUKS_endec_template(char *src, size_t srcLength,
2007-06-05 04:29:16 +02:00
r = setup_mapping(dmCipherSpec,name,device,hdr->payloadOffset,key,keyLength,sector,srcLength,backend,mode);
if(r < 0) {
- fprintf(stderr,"Failed to setup dm-crypt key mapping.\nCheck kernel for support for the %s cipher spec and verify that %s contains at least %d sectors.\n",
+ if(!get_error())
+ set_error("Failed to setup dm-crypt key mapping.\nCheck kernel for support for the %s cipher spec and verify that %s contains at least %d sectors",
dmCipherSpec,
device,
sector + div_round_up(srcLength,SECTOR_SIZE));