Skip to content

Commit

Permalink
make compilable when in lib/api mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bwalex committed Jul 3, 2011
1 parent bc488b4 commit a6e7a9d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
5 changes: 4 additions & 1 deletion Makefile
@@ -1,6 +1,9 @@
all: all:
gcc -O0 -Wall -g tc-play.c crc32.c safe_mem.c io.c crypto.c hdr.c openssl/openssl/libcrypto.a -o tc-play -ldevmapper -lprop -lutil gcc -O0 -Wall -g tc-play.c crc32.c safe_mem.c io.c crypto.c hdr.c openssl/openssl/libcrypto.a -o tc-play -ldevmapper -lprop -lutil
experimental: experimental:
gcc -O0 -Wall -g tc-play.c crc32.c safe_mem.c io.c crypto-dev.c hdr.c openssl/openssl/libcrypto.a -o tc-play -ldevmapper -lprop -lutil gcc -O0 -Wall -g main.c tc-play.c crc32.c safe_mem.c io.c crypto-dev.c hdr.c openssl/openssl/libcrypto.a -o tc-play -ldevmapper -lprop -lutil
lib:
gcc -c -fPIC -O0 -Wall -g tc-play-api.c tc-play.c crc32.c safe_mem.c io.c crypto-dev.c hdr.c
gcc -shared -Wl -o libtcplay.so tc-play-api.o tc-play.o crc32.o safe_mem.o io.o crypto-dev.o hdr.o
clean: clean:
rm -f tc-play tc-play.core *.o ktrace.out rm -f tc-play tc-play.core *.o ktrace.out
14 changes: 8 additions & 6 deletions tc-play-api.c
Expand Up @@ -27,6 +27,8 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */


#include <stdlib.h>
#include <unistd.h>
#include <errno.h> #include <errno.h>


#include "tc-play.h" #include "tc-play.h"
Expand Down Expand Up @@ -79,7 +81,7 @@ tc_api_create_volume(tc_api_op *api_opts)


create_hidden = 0; create_hidden = 0;


if (tc_size_hidden_in_blocks > 0) { if (api_opts->tc_size_hidden_in_blocks > 0) {
create_hidden = 1; create_hidden = 1;
for (n_hkeyfiles = 0; (n_hkeyfiles < MAX_KEYFILES) && for (n_hkeyfiles = 0; (n_hkeyfiles < MAX_KEYFILES) &&
(api_opts->tc_keyfiles_hidden[n_hkeyfiles] != NULL); (api_opts->tc_keyfiles_hidden[n_hkeyfiles] != NULL);
Expand All @@ -93,7 +95,7 @@ tc_api_create_volume(tc_api_op *api_opts)
check_prf_algo(api_opts->tc_prf_hash, 1), check_prf_algo(api_opts->tc_prf_hash, 1),
check_cipher_chain(api_opts->tc_cipher, 1), check_cipher_chain(api_opts->tc_cipher, 1),
api_opts->tc_passphrase, api_opts->tc_passphrase_hidden, api_opts->tc_passphrase, api_opts->tc_passphrase_hidden,
tc_size_hidden_in_blocks, 0 /* non-interactive */); api_opts->tc_size_hidden_in_blocks, 0 /* non-interactive */);


return (err) ? TC_ERR : TC_OK; return (err) ? TC_ERR : TC_OK;
} }
Expand All @@ -114,11 +116,11 @@ tc_api_map_volume(tc_api_op *api_opts)
(api_opts->tc_keyfiles[nkeyfiles] != NULL); nkeyfiles++) (api_opts->tc_keyfiles[nkeyfiles] != NULL); nkeyfiles++)
; ;


err = map_volume(api_opts->tc_map_name, api_opts->device, err = map_volume(api_opts->tc_map_name, api_opts->tc_device,
/* sflag */ 0, /* sys_dev */ NULL, /* sflag */ 0, /* sys_dev */ NULL,
/* protect_hidden */ 0, api_opts->tc_keyfiles, nkeyfiles, /* protect_hidden */ 0, api_opts->tc_keyfiles, nkeyfiles,
/* h_keyfiles[] */ NULL, /* n_hkeyfiles */ 0, /* h_keyfiles[] */ NULL, /* n_hkeyfiles */ 0,
api_opts->passphrase, /* passphrase_hidden */ NULL, api_opts->tc_passphrase, /* passphrase_hidden */ NULL,
api_opts->tc_interactive_prompt, api_opts->tc_password_retries); api_opts->tc_interactive_prompt, api_opts->tc_password_retries);


return (err) ? TC_ERR : TC_OK; return (err) ? TC_ERR : TC_OK;
Expand All @@ -129,7 +131,7 @@ tc_api_check_cipher(tc_api_op *api_opts)
{ {
struct tc_cipher_chain *chain; struct tc_cipher_chain *chain;


if (api_opts == NULL || api_opts->tc_cipher == NULL) if (api_opts == NULL || api_opts->tc_cipher == NULL) {
errno = EFAULT; errno = EFAULT;
return TC_ERR; return TC_ERR;
} }
Expand All @@ -146,7 +148,7 @@ tc_api_check_prf_hash(tc_api_op *api_opts)
{ {
struct pbkdf_prf_algo *prf_hash; struct pbkdf_prf_algo *prf_hash;


if (api_opts == NULL || api_opts->tc_prf_hash == NULL) if (api_opts == NULL || api_opts->tc_prf_hash == NULL) {
errno = EFAULT; errno = EFAULT;
return TC_ERR; return TC_ERR;
} }
Expand Down
6 changes: 3 additions & 3 deletions tc-play-api.h
Expand Up @@ -36,7 +36,7 @@ typedef struct tc_api_op {
char *tc_cipher; char *tc_cipher;
char *tc_prf_hash; char *tc_prf_hash;
char *tc_passphrase; char *tc_passphrase;
char *tc_keyfiles[]; char **tc_keyfiles;


/* Fields for mapping */ /* Fields for mapping */
char *tc_map_name; char *tc_map_name;
Expand All @@ -46,10 +46,10 @@ typedef struct tc_api_op {
/* Fields for creation */ /* Fields for creation */
size_t tc_size_hidden_in_blocks; size_t tc_size_hidden_in_blocks;
char *tc_passphrase_hidden; char *tc_passphrase_hidden;
char *tc_keyfiles_hidden[]; char **tc_keyfiles_hidden;
} tc_api_op; } tc_api_op;


int tc_api_init(void); int tc_api_init(int verbose);
int tc_api_uninit(void); int tc_api_uninit(void);
int tc_api_create_volume(tc_api_op *api_opts); int tc_api_create_volume(tc_api_op *api_opts);
int tc_api_map_volume(tc_api_op *api_opts); int tc_api_map_volume(tc_api_op *api_opts);
Expand Down

0 comments on commit a6e7a9d

Please sign in to comment.