diff options
author | Mohamad Ayyash <mkayyash@google.com> | 2016-04-07 22:15:57 -0700 |
---|---|---|
committer | Mohamad Ayyash <mkayyash@google.com> | 2016-04-07 22:15:57 -0700 |
commit | aa8b3553d9c5b0f89d13df6412af0dd1e25e5a3b (patch) | |
tree | 17187184b87dccc2100193af6b2b8cb6b20108bf | |
parent | a4325d3d28e8d6b0c0509175726620c643c4924d (diff) | |
download | extras-aa8b3553d9c5b0f89d13df6412af0dd1e25e5a3b.tar.gz |
Remove canned_fs_config from ext4_utils
It is now also used in mksquashfs so it was added to libcutils
BUG: 27467028
Change-Id: I81c87938d5b6b200a8ad817f0c64c5ca699f451c
Signed-off-by: Mohamad Ayyash <mkayyash@google.com>
-rw-r--r-- | ext4_utils/Android.mk | 4 | ||||
-rw-r--r-- | ext4_utils/canned_fs_config.c | 116 | ||||
-rw-r--r-- | ext4_utils/canned_fs_config.h | 26 | ||||
-rw-r--r-- | ext4_utils/make_ext4fs_main.c | 2 | ||||
-rwxr-xr-x | squashfs_utils/mksquashfsimage.sh | 11 |
5 files changed, 13 insertions, 146 deletions
diff --git a/ext4_utils/Android.mk b/ext4_utils/Android.mk index 3dd5409a..a8362b22 100644 --- a/ext4_utils/Android.mk +++ b/ext4_utils/Android.mk @@ -34,7 +34,7 @@ include $(BUILD_HOST_STATIC_LIBRARY) include $(CLEAR_VARS) -LOCAL_SRC_FILES := make_ext4fs_main.c canned_fs_config.c +LOCAL_SRC_FILES := make_ext4fs_main.c LOCAL_MODULE := make_ext4fs LOCAL_SHARED_LIBRARIES += libcutils LOCAL_STATIC_LIBRARIES += \ @@ -99,7 +99,7 @@ include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) -LOCAL_SRC_FILES := make_ext4fs_main.c canned_fs_config.c +LOCAL_SRC_FILES := make_ext4fs_main.c LOCAL_MODULE := make_ext4fs LOCAL_SHARED_LIBRARIES := \ libcutils \ diff --git a/ext4_utils/canned_fs_config.c b/ext4_utils/canned_fs_config.c deleted file mode 100644 index 089a8df7..00000000 --- a/ext4_utils/canned_fs_config.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2014 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 <inttypes.h> -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include <limits.h> -#include <stdlib.h> - -#include "private/android_filesystem_config.h" - -#include "canned_fs_config.h" - -typedef struct { - const char* path; - unsigned uid; - unsigned gid; - unsigned mode; - uint64_t capabilities; -} Path; - -static Path* canned_data = NULL; -static int canned_alloc = 0; -static int canned_used = 0; - -static int path_compare(const void* a, const void* b) { - return strcmp(((Path*)a)->path, ((Path*)b)->path); -} - -int load_canned_fs_config(const char* fn) { - FILE* f = fopen(fn, "r"); - if (f == NULL) { - fprintf(stderr, "failed to open %s: %s\n", fn, strerror(errno)); - return -1; - } - - char line[PATH_MAX + 200]; - while (fgets(line, sizeof(line), f)) { - while (canned_used >= canned_alloc) { - canned_alloc = (canned_alloc+1) * 2; - canned_data = (Path*) realloc(canned_data, canned_alloc * sizeof(Path)); - } - Path* p = canned_data + canned_used; - p->path = strdup(strtok(line, " ")); - p->uid = atoi(strtok(NULL, " ")); - p->gid = atoi(strtok(NULL, " ")); - p->mode = strtol(strtok(NULL, " "), NULL, 8); // mode is in octal - p->capabilities = 0; - - char* token = NULL; - do { - token = strtok(NULL, " "); - if (token && strncmp(token, "capabilities=", 13) == 0) { - p->capabilities = strtoll(token+13, NULL, 0); - break; - } - } while (token); - - canned_used++; - } - - fclose(f); - - qsort(canned_data, canned_used, sizeof(Path), path_compare); - printf("loaded %d fs_config entries\n", canned_used); - - return 0; -} - -static const int kDebugCannedFsConfig = 0; - -void canned_fs_config(const char* path, int dir, const char* target_out_path, - unsigned* uid, unsigned* gid, unsigned* mode, uint64_t* capabilities) { - Path key; - key.path = path+1; // canned paths lack the leading '/' - Path* p = (Path*) bsearch(&key, canned_data, canned_used, sizeof(Path), path_compare); - if (p == NULL) { - fprintf(stderr, "failed to find [%s] in canned fs_config\n", path); - exit(1); - } - *uid = p->uid; - *gid = p->gid; - *mode = p->mode; - *capabilities = p->capabilities; - - if (kDebugCannedFsConfig) { - // for debugging, run the built-in fs_config and compare the results. - - unsigned c_uid, c_gid, c_mode; - uint64_t c_capabilities; - fs_config(path, dir, target_out_path, &c_uid, &c_gid, &c_mode, &c_capabilities); - - if (c_uid != *uid) printf("%s uid %d %d\n", path, *uid, c_uid); - if (c_gid != *gid) printf("%s gid %d %d\n", path, *gid, c_gid); - if (c_mode != *mode) printf("%s mode 0%o 0%o\n", path, *mode, c_mode); - if (c_capabilities != *capabilities) - printf("%s capabilities %" PRIx64 " %" PRIx64 "\n", - path, - *capabilities, - c_capabilities); - } -} diff --git a/ext4_utils/canned_fs_config.h b/ext4_utils/canned_fs_config.h deleted file mode 100644 index d9f51ca3..00000000 --- a/ext4_utils/canned_fs_config.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -#ifndef _CANNED_FS_CONFIG_H -#define _CANNED_FS_CONFIG_H - -#include <inttypes.h> - -int load_canned_fs_config(const char* fn); -void canned_fs_config(const char* path, int dir, const char* target_out_path, - unsigned* uid, unsigned* gid, unsigned* mode, uint64_t* capabilities); - -#endif diff --git a/ext4_utils/make_ext4fs_main.c b/ext4_utils/make_ext4fs_main.c index 56ced5b5..323a445b 100644 --- a/ext4_utils/make_ext4fs_main.c +++ b/ext4_utils/make_ext4fs_main.c @@ -27,6 +27,7 @@ #ifdef ANDROID #include <private/android_filesystem_config.h> +#include <private/canned_fs_config.h> #endif #ifndef USE_MINGW @@ -41,7 +42,6 @@ struct selabel_handle; #include "make_ext4fs.h" #include "ext4_utils.h" -#include "canned_fs_config.h" #ifndef USE_MINGW /* O_BINARY is windows-specific flag */ #define O_BINARY 0 diff --git a/squashfs_utils/mksquashfsimage.sh b/squashfs_utils/mksquashfsimage.sh index 1bc2b83b..5f8cfeab 100755 --- a/squashfs_utils/mksquashfsimage.sh +++ b/squashfs_utils/mksquashfsimage.sh @@ -5,7 +5,7 @@ function usage() { cat<<EOT Usage: -${0##*/} SRC_DIR OUTPUT_FILE [-s] [-m MOUNT_POINT] [-d PRODUCT_OUT] [-c FILE_CONTEXTS] [-b BLOCK_SIZE] [-z COMPRESSOR] [-zo COMPRESSOR_OPT] +${0##*/} SRC_DIR OUTPUT_FILE [-s] [-m MOUNT_POINT] [-d PRODUCT_OUT] [-C FS_CONFIG ] [-c FILE_CONTEXTS] [-b BLOCK_SIZE] [-z COMPRESSOR] [-zo COMPRESSOR_OPT] EOT } @@ -42,6 +42,12 @@ if [[ "$1" == "-d" ]]; then shift; shift fi +FS_CONFIG= +if [[ "$1" == "-C" ]]; then + FS_CONFIG=$2 + shift; shift +fi + FILE_CONTEXTS= if [[ "$1" == "-c" ]]; then FILE_CONTEXTS=$2 @@ -74,6 +80,9 @@ fi if [ -n "$PRODUCT_OUT" ]; then OPT="$OPT -product-out $PRODUCT_OUT" fi +if [ -n "$FS_CONFIG" ]; then + OPT="$OPT -fs-config-file $FS_CONFIG" +fi if [ -n "$FILE_CONTEXTS" ]; then OPT="$OPT -context-file $FILE_CONTEXTS" fi |