use set_error instead of printf in library to report errors. From: Ludwig Nussel Signed-off-by: Ludwig Nussel --- 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) { 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 = countsize = round_up_modulo(srcLength,device_sector_size)/SECTOR_SIZE; @@ -138,7 +138,8 @@ static int LUKS_endec_template(char *src, size_t srcLength, 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));