From 253368a0726120efa57664cdd1d088af099a3d81 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Tue, 25 Nov 2014 15:00:52 -0600 Subject: Reduce libs needed for decrypt and clean up old decypt files Trim cryptfs.c to remove functions that TWRP does not use for decrypt and remove the need for libfs_mgr from cryptfs.c by passing some items to cryptfs.c from the partition manager. Add support for new fstab flags: encryptable and forceencrypt=/path/to/cryptokey For example: flags=forceencrypt=/dev/block/platform/sdhci-tegra.3/by-name/MD1 Note that "footer" is the default, so you do not need to set this flag on devices that use the footer for the crypto key. Also add mounttodecrypt if you need to mount a partition during the decrypt cycle for firmware of proprietary libs. Clean up decrypt and only support one version Android 5.0 lollipop decrypt should be backwards compatible with older versions so we will only support one version, 1.3 that came with 5.0 lollipop. Remove support for Samsung TouchWiz decrypt. It does not work with the latest versions of Samsung encryption anyway and it has not been updated to work with any AOSP decryption higher than 1.1 Change-Id: I2d9c6e31df50268c91ee642c2fa090f901d9d5c9 --- crypto/fs_mgr/fs_mgr_main.c | 114 -------------------------------------------- 1 file changed, 114 deletions(-) delete mode 100644 crypto/fs_mgr/fs_mgr_main.c (limited to 'crypto/fs_mgr/fs_mgr_main.c') diff --git a/crypto/fs_mgr/fs_mgr_main.c b/crypto/fs_mgr/fs_mgr_main.c deleted file mode 100644 index 4bde4a1da..000000000 --- a/crypto/fs_mgr/fs_mgr_main.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include "fs_mgr_priv.h" - -char *me = ""; - -static void usage(void) -{ - ERROR("%s: usage: %s <-a | -n mnt_point blk_dev | -u> \n", me, me); - exit(1); -} - -/* Parse the command line. If an error is encountered, print an error message - * and exit the program, do not return to the caller. - * Return the number of argv[] entries consumed. - */ -static void parse_options(int argc, char *argv[], int *a_flag, int *u_flag, int *n_flag, - char **n_name, char **n_blk_dev) -{ - me = basename(strdup(argv[0])); - - if (argc <= 1) { - usage(); - } - - if (!strcmp(argv[1], "-a")) { - if (argc != 3) { - usage(); - } - *a_flag = 1; - } - if (!strcmp(argv[1], "-n")) { - if (argc != 5) { - usage(); - } - *n_flag = 1; - *n_name = argv[2]; - *n_blk_dev = argv[3]; - } - if (!strcmp(argv[1], "-u")) { - if (argc != 3) { - usage(); - } - *u_flag = 1; - } - - /* If no flag is specified, it's an error */ - if (!(*a_flag | *n_flag | *u_flag)) { - usage(); - } - - /* If more than one flag is specified, it's an error */ - if ((*a_flag + *n_flag + *u_flag) > 1) { - usage(); - } - - return; -} - -int main(int argc, char *argv[]) -{ - int a_flag=0; - int u_flag=0; - int n_flag=0; - char *n_name; - char *n_blk_dev; - char *fstab_file; - struct fstab *fstab; - - klog_init(); - klog_set_level(6); - - parse_options(argc, argv, &a_flag, &u_flag, &n_flag, &n_name, &n_blk_dev); - - /* The name of the fstab file is last, after the option */ - fstab_file = argv[argc - 1]; - - fstab = fs_mgr_read_fstab(fstab_file); - - if (a_flag) { - return fs_mgr_mount_all(fstab); - } else if (n_flag) { - return fs_mgr_do_mount(fstab, n_name, n_blk_dev, 0); - } else if (u_flag) { - return fs_mgr_unmount_all(fstab); - } else { - ERROR("%s: Internal error, unknown option\n", me); - exit(1); - } - - fs_mgr_free_fstab(fstab); - - /* Should not get here */ - exit(1); -} - -- cgit v1.2.3