I am trying to leverage cryptsetup functionality in a custom ramdisk image via AOSP. I would like to call cryptsetup to interact with a specified location during the early-init process of booting. I have downloaded https://android.googlesource.com/platform/external/cryptsetup/ to my /external/ directory, afterwards I added #include <libcryptsetup.h> into my system/core/init/first_stage_init.cpp file, at the bottom right before the call to
execv(path, const_cast<char**>(args));
I then edited my system/core/init/Android.bp file cc_binary init_first_stage section and added
include_dirs: [
"external/cryptsetup/lib",
"external/",
"external/cryptsetup",
],
This allowed the include statement
#include <libcryptsetup.h>
to work fine and I can compile. However if I try to use functionality, for example as a test:
struct crypt_device *cd = NULL;
crypt_free(cd);
I get the error:
undefined reference to `crypt_free'
I am now running into linking issues.
I have tried adding libcryptsetup,cryptsetup,and other variations to
shared_libs,system_shared_libs,static_libs
I have also tried adding -lcrypsetup
to the cflags
array. All with no luck, usually resulting in the error:
error: -lcryptsetup: 'linker' input unused [-Werror,-Wunused-command-line-argument]
I have also tried calling to execv to see if I would be able to call the cryptsetup binaries rather than using the libcryptsetup API, however, no calls to execv other than the call to init seem to be executed. I assume it has to do with SELinux polcies. Information in regard to how I can successfully interact with cryptsetup at early-init would be appreciated. Please provide full file paths (ex not just Android.mk but the full path to it) and direct location references as I am new to the AOSP environment. My build environment is Linux computer 5.19.0-43-generic #44~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC x86_64 x86_64 x86_64 GNU/Linux. I am building for android bramble arm64 currently.