summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSami Tolvanen <samitolvanen@google.com>2016-09-01 13:43:51 -0700
committerZheng Zhang <zhzh@google.com>2016-11-20 06:21:21 +0000
commit955d3afe95df7e2ac7de0445777539aabe9aa3a5 (patch)
treea6162a831b0c975315c10d30a37c266188e6ca53
parentcace33a52a3b4f7360219bae1f209ebc5d3fadcb (diff)
downloadextras-955d3afe95df7e2ac7de0445777539aabe9aa3a5.tar.gz
DO NOT MERGE: fec: remove unneeded target executable
Bug: 32789520 Change-Id: Ic925814191b8ac952b584a994cf455f871a8ee0c (cherrypicked from commit 4c716c92a691e6b39e8e65a397f9b6e91f9e07ee)
-rw-r--r--verity/fec/Android.mk21
-rw-r--r--verity/fec/image.cpp53
2 files changed, 1 insertions, 73 deletions
diff --git a/verity/fec/Android.mk b/verity/fec/Android.mk
index c13f5775..5fff9c37 100644
--- a/verity/fec/Android.mk
+++ b/verity/fec/Android.mk
@@ -19,23 +19,4 @@ LOCAL_STATIC_LIBRARIES := \
LOCAL_SHARED_LIBRARIES := libbase
LOCAL_CFLAGS += -Wall -Werror -O3
LOCAL_C_INCLUDES += external/fec
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_CLANG := true
-LOCAL_SANITIZE := integer
-LOCAL_MODULE := fec
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-LOCAL_SRC_FILES := main.cpp image.cpp
-LOCAL_MODULE_TAGS := optional
-LOCAL_STATIC_LIBRARIES := \
- libcrypto_static \
- libfec \
- libfec_rs \
- libbase \
- libext4_utils_static \
- libsquashfs_utils \
- libcutils
-LOCAL_CFLAGS += -Wall -Werror -O3 -DIMAGE_NO_SPARSE=1
-LOCAL_C_INCLUDES += external/fec
-include $(BUILD_EXECUTABLE)
+include $(BUILD_HOST_EXECUTABLE) \ No newline at end of file
diff --git a/verity/fec/image.cpp b/verity/fec/image.cpp
index 780d9810..7c1eab76 100644
--- a/verity/fec/image.cpp
+++ b/verity/fec/image.cpp
@@ -33,9 +33,7 @@ extern "C" {
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
-#ifndef IMAGE_NO_SPARSE
#include <sparse/sparse.h>
-#endif
#include "image.h"
#if defined(__linux__)
@@ -66,31 +64,6 @@ void image_free(image *ctx)
image_init(ctx);
}
-#ifdef IMAGE_NO_SPARSE
-static uint64_t get_size(int fd)
-{
- struct stat st;
-
- if (fstat(fd, &st) == -1) {
- FATAL("failed to fstat: %s\n", strerror(errno));
- }
-
- uint64_t size = 0;
-
- if (S_ISBLK(st.st_mode)) {
- if (ioctl(fd, BLKGETSIZE64, &size) == -1) {
- FATAL("failed to ioctl(BLKGETSIZE64): %s\n", strerror(errno));
- }
- } else if (S_ISREG(st.st_mode)) {
- size = st.st_size;
- } else {
- FATAL("unknown file mode: %d\n", (int)st.st_mode);
- }
-
- return size;
-}
-#endif
-
static void calculate_rounds(uint64_t size, image *ctx)
{
if (!size) {
@@ -105,7 +78,6 @@ static void calculate_rounds(uint64_t size, image *ctx)
ctx->rounds = fec_div_round_up(ctx->blocks, ctx->rs_n);
}
-#ifndef IMAGE_NO_SPARSE
static int process_chunk(void *priv, const void *data, int len)
{
image *ctx = (image *)priv;
@@ -118,25 +90,14 @@ static int process_chunk(void *priv, const void *data, int len)
ctx->pos += len;
return 0;
}
-#endif
static void file_image_load(const std::vector<int>& fds, image *ctx)
{
uint64_t size = 0;
-#ifndef IMAGE_NO_SPARSE
std::vector<struct sparse_file *> files;
-#endif
for (auto fd : fds) {
uint64_t len = 0;
-
-#ifdef IMAGE_NO_SPARSE
- if (ctx->sparse) {
- FATAL("sparse files not supported\n");
- }
-
- len = get_size(fd);
-#else
struct sparse_file *file;
if (ctx->sparse) {
@@ -151,7 +112,6 @@ static void file_image_load(const std::vector<int>& fds, image *ctx)
len = sparse_file_len(file, false, false);
files.push_back(file);
-#endif /* IMAGE_NO_SPARSE */
size += len;
}
@@ -172,18 +132,6 @@ static void file_image_load(const std::vector<int>& fds, image *ctx)
ctx->output = ctx->input;
ctx->pos = 0;
-#ifdef IMAGE_NO_SPARSE
- for (auto fd : fds) {
- uint64_t len = get_size(fd);
-
- if (!android::base::ReadFully(fd, &ctx->input[ctx->pos], len)) {
- FATAL("failed to read: %s\n", strerror(errno));
- }
-
- ctx->pos += len;
- close(fd);
- }
-#else
for (auto file : files) {
sparse_file_callback(file, false, false, process_chunk, ctx);
sparse_file_destroy(file);
@@ -192,7 +140,6 @@ static void file_image_load(const std::vector<int>& fds, image *ctx)
for (auto fd : fds) {
close(fd);
}
-#endif
}
bool image_load(const std::vector<std::string>& filenames, image *ctx)