LOCAL_SHARED_LIBRARIES := $(common_shared_libraries)
LOCAL_STATIC_LIBRARIES := $(common_static_libraries)
LOCAL_MODULE_TAGS := eng tests
+LOCAL_CFLAGS := -Werror -Wall -Wno-missing-field-initializers
LOCAL_CXX_STL := libc++
include $(BUILD_STATIC_LIBRARY)
$(common_src_files)
LOCAL_C_INCLUDES := $(common_c_includes)
-LOCAL_CFLAGS := -Werror=format
+LOCAL_CFLAGS := -Werror -Wall -Wno-missing-field-initializers
LOCAL_SHARED_LIBRARIES := $(common_shared_libraries)
LOCAL_STATIC_LIBRARIES := $(common_static_libraries)
LOCAL_SRC_FILES:= vdc.c
LOCAL_MODULE:= vdc
LOCAL_SHARED_LIBRARIES := libcutils
+LOCAL_CFLAGS := -Werror -Wall -Wno-missing-field-initializers
include $(BUILD_EXECUTABLE)
using namespace android;
-namespace
-{
- // How often to check battery in seconds
- const int CHECK_PERIOD = 30;
-
- // How charged should the battery be (percent) to start encrypting
- const int START_THRESHOLD = 10;
-
- // How charged should the battery be (percent) to continue encrypting
- const int CONTINUE_THRESHOLD = 5;
-
- const String16 serviceName("batteryproperties");
-
- sp<IBinder> bs;
- sp<IBatteryPropertiesRegistrar> interface;
-
- bool singletonInitialized = false;
- time_t last_checked = {0};
- int last_result = 100;
-
- int is_battery_ok(int threshold)
- {
- time_t now = time(NULL);
- if (now == -1 || difftime(now, last_checked) < 5) {
- goto finish;
- }
- last_checked = now;
-
- if (!singletonInitialized) {
- bs = defaultServiceManager()->checkService(serviceName);
- if (bs == NULL) {
- SLOGE("No batteryproperties service!");
- goto finish;
- }
-
- interface = interface_cast<IBatteryPropertiesRegistrar>(bs);
- if (interface == NULL) {
- SLOGE("No IBatteryPropertiesRegistrar interface");
- goto finish;
- }
-
- singletonInitialized = true;
- }
-
- {
- BatteryProperty val;
- status_t status = interface
- ->getProperty(android::BATTERY_PROP_CAPACITY, &val);
- if (status == NO_ERROR) {
- SLOGD("Capacity is %d", (int)val.valueInt64);
- last_result = val.valueInt64;
- } else {
- SLOGE("Failed to get battery charge");
- last_result = 100;
- }
- }
-
- finish:
- return last_result >= threshold;
- }
-}
-
extern "C"
{
int is_battery_ok_to_start()
if (!rc) {
cli->sendMsg(ResponseCode::CommandOkay, "volume operation succeeded", false);
} else {
- int erno = errno;
rc = ResponseCode::convertFromErrno();
cli->sendMsg(rc, "volume operation failed", true);
}
void *Devmapper::_align(void *ptr, unsigned int a)
{
- register unsigned long agn = --a;
+ unsigned long agn = --a;
return (void *) (((unsigned long) ptr + agn) & ~agn);
}
}
int Ext4::format(const char *fsPath, unsigned int numSectors, const char *mountpoint) {
- int fd;
const char *args[7];
int rc;
int status;
extern "C" int mount(const char *, const char *, const char *, unsigned long, const void *);
int Fat::check(const char *fsPath) {
- bool rw = true;
if (access(FSCK_MSDOS_PATH, X_OK)) {
SLOGW("Skipping fs checks\n");
return 0;
}
int Fat::format(const char *fsPath, unsigned int numSectors, bool wipe) {
- int fd;
const char *args[11];
int rc;
int status;
}
while ((de = readdir(dir))) {
- int killed = 0;
int pid = getPid(de->d_name);
char name[PATH_MAX];
int Volume::mountVol() {
dev_t deviceNodes[4];
- int n, i, rc = 0;
+ int n, i;
char errmsg[255];
int flags = getFlags();
}
errno = 0;
- int gid;
if (Fat::doMount(devicePath, getMountpoint(), false, false, false,
AID_MEDIA_RW, AID_MEDIA_RW, 0007, true)) {
}
int Volume::unmountVol(bool force, bool revert) {
- int i, rc;
-
int flags = getFlags();
bool providesAsec = (flags & VOL_PROVIDES_ASEC) != 0;
}
void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {
+#ifdef NETLINK_DEBUG
const char *devpath = evt->findParam("DEVPATH");
+#endif
/* Lookup a volume to handle this device */
VolumeCollection::iterator it;
int VolumeManager::findAsec(const char *id, char *asecPath, size_t asecPathLen,
const char **directory) const {
- int dirfd, fd;
- const int idLen = strlen(id);
char *asecName;
if (!isLegalAsecId(id)) {
char dmDevice[255];
bool cleanupDm = false;
- int fd;
+
unsigned int nr_sec = 0;
struct asec_superblock sb;
static int put_crypt_ftr_and_key(struct crypt_mnt_ftr *crypt_ftr)
{
int fd;
- unsigned int nr_sec, cnt;
+ unsigned int cnt;
/* starting_off is set to the SEEK_SET offset
* where the crypto structure starts
*/
static int get_crypt_ftr_and_key(struct crypt_mnt_ftr *crypt_ftr)
{
int fd;
- unsigned int nr_sec, cnt;
+ unsigned int cnt;
off64_t starting_off;
int rc = -1;
char *fname = NULL;
char *fname;
off64_t write_offset;
off64_t erase_offset;
- int found = 0;
int fd;
int ret;
char buffer[DM_CRYPT_BUF_SIZE];
struct dm_ioctl *io;
struct dm_target_versions *v;
- int i;
io = (struct dm_ioctl *) buffer;
char *real_blk_name, char *crypto_blk_name, const char *name)
{
char buffer[DM_CRYPT_BUF_SIZE];
- char master_key_ascii[129]; /* Large enough to hold 512 bit key and null */
- char *crypt_params;
struct dm_ioctl *io;
- struct dm_target_spec *tgt;
unsigned int minor;
int fd;
- int i;
int retval = -1;
int version[3];
char *extra_params;
struct crypt_mnt_ftr *crypt_ftr) {
int fd;
unsigned char key_buf[KEY_LEN_BYTES];
- EVP_CIPHER_CTX e_ctx;
- int encrypted_len, final_len;
/* Get some random bits for a key */
fd = open("/dev/urandom", O_RDONLY);
/* returns < 0 on failure */
static int cryptfs_restart_internal(int restart_main)
{
- char fs_type[32];
- char real_blkdev[MAXPATHLEN];
char crypto_blkdev[MAXPATHLEN];
- char fs_options[256];
- unsigned long mnt_flags;
- struct stat statbuf;
- int rc = -1, i;
+ int rc = -1;
static int restart_successful = 0;
/* Validate that it's OK to call this routine */
char tmp_mount_point[64];
unsigned int orig_failed_decrypt_count;
int rc;
- kdf_func kdf;
- void *kdf_params;
int use_keymaster = 0;
int upgrade = 0;
unsigned char* intermediate_key = 0;
char real_blkdev[MAXPATHLEN], crypto_blkdev[MAXPATHLEN];
struct crypt_mnt_ftr sd_crypt_ftr;
struct stat statbuf;
- int nr_sec, fd;
+ unsigned int nr_sec;
+ int fd;
sprintf(real_blkdev, "/dev/block/vold/%d:%d", major, minor);
off64_t tot_size,
off64_t previously_encrypted_upto)
{
- u32 i;
struct encryptGroupsData data;
struct f2fs_info *f2fs_info = NULL;
int rc = ENABLE_INPLACE_ERR_OTHER;
int previously_encrypted_upto)
{
off64_t cur_encryption_done=0, tot_encryption_size=0;
- int i, rc = -1;
+ int rc = -1;
if (!is_battery_ok_to_start()) {
SLOGW("Not starting encryption due to low battery");
char crypto_blkdev[MAXPATHLEN], real_blkdev[MAXPATHLEN];
unsigned long nr_sec;
unsigned char decrypted_master_key[KEY_LEN_BYTES];
- int rc=-1, fd, i, ret;
+ int rc=-1, fd, i;
struct crypt_mnt_ftr crypt_ftr;
struct crypt_persist_data *pdata;
char encrypted_state[PROPERTY_VALUE_MAX];
int cryptfs_changepw(int crypt_type, const char *newpw)
{
struct crypt_mnt_ftr crypt_ftr;
- unsigned char decrypted_master_key[KEY_LEN_BYTES];
/* This is only allowed after we've successfully decrypted the master key */
if (!master_key_saved) {
int cryptfs_getfield(char *fieldname, char *value, int len)
{
char temp_value[PROPERTY_VALUE_MAX];
- char real_blkdev[MAXPATHLEN];
/* 0 is success, 1 is not encrypted,
* -1 is value not set, -2 is any other error
*/
/* Set the value of the specified field. */
int cryptfs_setfield(char *fieldname, char *value)
{
- struct crypt_persist_data stored_pdata;
- struct crypt_persist_data *pdata_p;
- struct crypt_mnt_ftr crypt_ftr;
char encrypted_state[PROPERTY_VALUE_MAX];
/* 0 is success, -1 is an error */
int rc = -1;