From: Jo-Philipp Wich Date: Sat, 4 Apr 2015 21:04:32 +0000 (+0200) Subject: libsparse: remove unused files X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=2964e1c7361424c30405b348fe545f7bb3fc290c;p=project%2Fmake_ext4fs.git libsparse: remove unused files Signed-off-by: Jo-Philipp Wich --- diff --git a/libsparse/Android.mk b/libsparse/Android.mk deleted file mode 100644 index 925b98b..0000000 --- a/libsparse/Android.mk +++ /dev/null @@ -1,110 +0,0 @@ -# Copyright 2010 The Android Open Source Project - -LOCAL_PATH:= $(call my-dir) - -libsparse_src_files := \ - backed_block.c \ - output_file.c \ - sparse.c \ - sparse_crc32.c \ - sparse_err.c \ - sparse_read.c - - -include $(CLEAR_VARS) -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include -LOCAL_SRC_FILES := $(libsparse_src_files) -LOCAL_MODULE := libsparse_host -LOCAL_STATIC_LIBRARIES := libz -LOCAL_C_INCLUDES := $(LOCAL_PATH)/include -LOCAL_CFLAGS := -Werror -include $(BUILD_HOST_STATIC_LIBRARY) - - -include $(CLEAR_VARS) -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include -LOCAL_SRC_FILES := $(libsparse_src_files) -LOCAL_MODULE := libsparse -LOCAL_C_INCLUDES += $(LOCAL_PATH)/include -LOCAL_SHARED_LIBRARIES := \ - libz -LOCAL_CFLAGS := -Werror -include $(BUILD_SHARED_LIBRARY) - - -include $(CLEAR_VARS) -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include -LOCAL_SRC_FILES := $(libsparse_src_files) -LOCAL_MODULE := libsparse_static -LOCAL_C_INCLUDES += $(LOCAL_PATH)/include -LOCAL_STATIC_LIBRARIES := libz -LOCAL_CFLAGS := -Werror -include $(BUILD_STATIC_LIBRARY) - - -include $(CLEAR_VARS) -LOCAL_SRC_FILES := simg2img.c \ - sparse_crc32.c -LOCAL_MODULE := simg2img_host -# Need a unique module name, but exe should still be called simg2img -LOCAL_MODULE_STEM := simg2img -LOCAL_STATIC_LIBRARIES := \ - libsparse_host \ - libz -LOCAL_CFLAGS := -Werror -include $(BUILD_HOST_EXECUTABLE) - - -include $(CLEAR_VARS) -LOCAL_SRC_FILES := simg2img.c \ - sparse_crc32.c -LOCAL_MODULE := simg2img -LOCAL_STATIC_LIBRARIES := \ - libsparse_static \ - libz -LOCAL_CFLAGS := -Werror -include $(BUILD_EXECUTABLE) - - -include $(CLEAR_VARS) -LOCAL_SRC_FILES := img2simg.c -LOCAL_MODULE := img2simg_host -# Need a unique module name, but exe should still be called simg2img -LOCAL_MODULE_STEM := img2simg -LOCAL_STATIC_LIBRARIES := \ - libsparse_host \ - libz -LOCAL_CFLAGS := -Werror -include $(BUILD_HOST_EXECUTABLE) - - -include $(CLEAR_VARS) -LOCAL_SRC_FILES := img2simg.c -LOCAL_MODULE := img2simg -LOCAL_STATIC_LIBRARIES := \ - libsparse_static \ - libz -LOCAL_CFLAGS := -Werror -include $(BUILD_EXECUTABLE) - - -ifneq ($(HOST_OS),windows) - -include $(CLEAR_VARS) -LOCAL_SRC_FILES := append2simg.c -LOCAL_MODULE := append2simg -LOCAL_STATIC_LIBRARIES := \ - libsparse_host \ - libz -LOCAL_CFLAGS := -Werror -include $(BUILD_HOST_EXECUTABLE) - -endif - -include $(CLEAR_VARS) -LOCAL_MODULE := simg_dump.py -LOCAL_SRC_FILES := simg_dump.py -LOCAL_MODULE_CLASS := EXECUTABLES -LOCAL_IS_HOST_MODULE := true -LOCAL_CFLAGS := -Werror -include $(BUILD_PREBUILT) diff --git a/libsparse/append2simg.c b/libsparse/append2simg.c deleted file mode 100644 index 1cf827c..0000000 --- a/libsparse/append2simg.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -#define _FILE_OFFSET_BITS 64 -#define _LARGEFILE64_SOURCE 1 -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include - -#include -#include "sparse_file.h" -#include "backed_block.h" - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -#if defined(__APPLE__) && defined(__MACH__) -#define lseek64 lseek -#endif -#if defined(__APPLE__) && defined(__MACH__) -#define lseek64 lseek -#define off64_t off_t -#endif - -void usage() -{ - fprintf(stderr, "Usage: append2simg \n"); -} - -int main(int argc, char *argv[]) -{ - int output; - int output_block; - char *output_path; - struct sparse_file *sparse_output; - - int input; - char *input_path; - off64_t input_len; - - int tmp_fd; - char *tmp_path; - - int ret; - - if (argc == 3) { - output_path = argv[1]; - input_path = argv[2]; - } else { - usage(); - exit(-1); - } - - ret = asprintf(&tmp_path, "%s.append2simg", output_path); - if (ret < 0) { - fprintf(stderr, "Couldn't allocate filename\n"); - exit(-1); - } - - output = open(output_path, O_RDWR | O_BINARY); - if (output < 0) { - fprintf(stderr, "Couldn't open output file (%s)\n", strerror(errno)); - exit(-1); - } - - sparse_output = sparse_file_import_auto(output, true, true); - if (!sparse_output) { - fprintf(stderr, "Couldn't import output file\n"); - exit(-1); - } - - input = open(input_path, O_RDONLY | O_BINARY); - if (input < 0) { - fprintf(stderr, "Couldn't open input file (%s)\n", strerror(errno)); - exit(-1); - } - - input_len = lseek64(input, 0, SEEK_END); - if (input_len < 0) { - fprintf(stderr, "Couldn't get input file length (%s)\n", strerror(errno)); - exit(-1); - } else if (input_len % sparse_output->block_size) { - fprintf(stderr, "Input file is not a multiple of the output file's block size"); - exit(-1); - } - lseek64(input, 0, SEEK_SET); - - output_block = sparse_output->len / sparse_output->block_size; - if (sparse_file_add_fd(sparse_output, input, 0, input_len, output_block) < 0) { - fprintf(stderr, "Couldn't add input file\n"); - exit(-1); - } - sparse_output->len += input_len; - - tmp_fd = open(tmp_path, O_WRONLY | O_CREAT | O_BINARY, 0664); - if (tmp_fd < 0) { - fprintf(stderr, "Couldn't open temporary file (%s)\n", strerror(errno)); - exit(-1); - } - - lseek64(output, 0, SEEK_SET); - if (sparse_file_write(sparse_output, tmp_fd, false, true, false) < 0) { - fprintf(stderr, "Failed to write sparse file\n"); - exit(-1); - } - - sparse_file_destroy(sparse_output); - close(tmp_fd); - close(output); - close(input); - - ret = rename(tmp_path, output_path); - if (ret < 0) { - fprintf(stderr, "Failed to rename temporary file (%s)\n", strerror(errno)); - exit(-1); - } - - free(tmp_path); - - exit(0); -} diff --git a/libsparse/img2simg.c b/libsparse/img2simg.c deleted file mode 100644 index a0db36f..0000000 --- a/libsparse/img2simg.c +++ /dev/null @@ -1,115 +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. - */ - -#define _FILE_OFFSET_BITS 64 -#define _LARGEFILE64_SOURCE 1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -#if defined(__APPLE__) && defined(__MACH__) -#define lseek64 lseek -#define off64_t off_t -#endif - -void usage() -{ - fprintf(stderr, "Usage: img2simg []\n"); -} - -int main(int argc, char *argv[]) -{ - int in; - int out; - int ret; - struct sparse_file *s; - unsigned int block_size = 4096; - off64_t len; - - if (argc < 3 || argc > 4) { - usage(); - exit(-1); - } - - if (argc == 4) { - block_size = atoi(argv[3]); - } - - if (block_size < 1024 || block_size % 4 != 0) { - usage(); - exit(-1); - } - - if (strcmp(argv[1], "-") == 0) { - in = STDIN_FILENO; - } else { - in = open(argv[1], O_RDONLY | O_BINARY); - if (in < 0) { - fprintf(stderr, "Cannot open input file %s\n", argv[1]); - exit(-1); - } - } - - if (strcmp(argv[2], "-") == 0) { - out = STDOUT_FILENO; - } else { - out = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0664); - if (out < 0) { - fprintf(stderr, "Cannot open output file %s\n", argv[2]); - exit(-1); - } - } - - len = lseek64(in, 0, SEEK_END); - lseek64(in, 0, SEEK_SET); - - s = sparse_file_new(block_size, len); - if (!s) { - fprintf(stderr, "Failed to create sparse file\n"); - exit(-1); - } - - sparse_file_verbose(s); - ret = sparse_file_read(s, in, false, false); - if (ret) { - fprintf(stderr, "Failed to read file\n"); - exit(-1); - } - - ret = sparse_file_write(s, out, false, true, false); - if (ret) { - fprintf(stderr, "Failed to write sparse file\n"); - exit(-1); - } - - close(in); - close(out); - - exit(0); -} diff --git a/libsparse/simg2img.c b/libsparse/simg2img.c deleted file mode 100644 index 95e9b5b..0000000 --- a/libsparse/simg2img.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2010 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 -#include -#include -#include -#include -#include - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -void usage() -{ - fprintf(stderr, "Usage: simg2img \n"); -} - -int main(int argc, char *argv[]) -{ - int in; - int out; - int i; - int ret; - struct sparse_file *s; - - if (argc < 3) { - usage(); - exit(-1); - } - - out = open(argv[argc - 1], O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0664); - if (out < 0) { - fprintf(stderr, "Cannot open output file %s\n", argv[argc - 1]); - exit(-1); - } - - for (i = 1; i < argc - 1; i++) { - if (strcmp(argv[i], "-") == 0) { - in = STDIN_FILENO; - } else { - in = open(argv[i], O_RDONLY | O_BINARY); - if (in < 0) { - fprintf(stderr, "Cannot open input file %s\n", argv[i]); - exit(-1); - } - } - - s = sparse_file_import(in, true, false); - if (!s) { - fprintf(stderr, "Failed to read sparse file\n"); - exit(-1); - } - - lseek(out, SEEK_SET, 0); - - ret = sparse_file_write(s, out, false, false, false); - if (ret < 0) { - fprintf(stderr, "Cannot write output file\n"); - exit(-1); - } - sparse_file_destroy(s); - close(in); - } - - close(out); - - exit(0); -} - diff --git a/libsparse/simg2simg.c b/libsparse/simg2simg.c deleted file mode 100644 index 5f9ccf6..0000000 --- a/libsparse/simg2simg.c +++ /dev/null @@ -1,115 +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. - */ - -#define _FILE_OFFSET_BITS 64 -#define _LARGEFILE64_SOURCE 1 -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -void usage() -{ - fprintf(stderr, "Usage: simg2simg \n"); -} - -int main(int argc, char *argv[]) -{ - int in; - int out; - int i; - int ret; - struct sparse_file *s; - int64_t max_size; - struct sparse_file **out_s; - int files; - char filename[4096]; - - if (argc != 4) { - usage(); - exit(-1); - } - - max_size = atoll(argv[3]); - - in = open(argv[1], O_RDONLY | O_BINARY); - if (in < 0) { - fprintf(stderr, "Cannot open input file %s\n", argv[1]); - exit(-1); - } - - s = sparse_file_import(in, true, false); - if (!s) { - fprintf(stderr, "Failed to import sparse file\n"); - exit(-1); - } - - files = sparse_file_resparse(s, max_size, NULL, 0); - if (files < 0) { - fprintf(stderr, "Failed to resparse\n"); - exit(-1); - } - - out_s = calloc(sizeof(struct sparse_file *), files); - if (!out_s) { - fprintf(stderr, "Failed to allocate sparse file array\n"); - exit(-1); - } - - files = sparse_file_resparse(s, max_size, out_s, files); - if (files < 0) { - fprintf(stderr, "Failed to resparse\n"); - exit(-1); - } - - for (i = 0; i < files; i++) { - ret = snprintf(filename, sizeof(filename), "%s.%d", argv[2], i); - if (ret >= (int)sizeof(filename)) { - fprintf(stderr, "Filename too long\n"); - exit(-1); - } - - out = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0664); - if (out < 0) { - fprintf(stderr, "Cannot open output file %s\n", argv[2]); - exit(-1); - } - - ret = sparse_file_write(out_s[i], out, false, true, false); - if (ret) { - fprintf(stderr, "Failed to write sparse file\n"); - exit(-1); - } - close(out); - } - - close(in); - - exit(0); -} diff --git a/libsparse/simg_dump.py b/libsparse/simg_dump.py deleted file mode 100755 index 6ece31d..0000000 --- a/libsparse/simg_dump.py +++ /dev/null @@ -1,169 +0,0 @@ -#! /usr/bin/env python - -# 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. - -from __future__ import print_function -import getopt, posixpath, signal, struct, sys - -def usage(argv0): - print(""" -Usage: %s [-v] sparse_image_file ... - -v verbose output -""" % ( argv0 )) - sys.exit(2) - -def main(): - - signal.signal(signal.SIGPIPE, signal.SIG_DFL) - - me = posixpath.basename(sys.argv[0]) - - # Parse the command line - verbose = 0 # -v - try: - opts, args = getopt.getopt(sys.argv[1:], - "v", - ["verbose"]) - except getopt.GetoptError, e: - print(e) - usage(me) - for o, a in opts: - if o in ("-v", "--verbose"): - verbose += 1 - else: - print("Unrecognized option \"%s\"" % (o)) - usage(me) - - if len(args) == 0: - print("No sparse_image_file specified") - usage(me) - - for path in args: - FH = open(path, 'rb') - header_bin = FH.read(28) - header = struct.unpack(" 1: - header = struct.unpack("<12B", header_bin) - print(" (%02X%02X %02X%02X %02X%02X%02X%02X %02X%02X%02X%02X)" - % (header[0], header[1], header[2], header[3], - header[4], header[5], header[6], header[7], - header[8], header[9], header[10], header[11])) - else: - print() - - offset += chunk_sz - - print(" %10u %7u End" % (FH.tell(), offset)) - - if total_blks != offset: - print("The header said we should have %u output blocks, but we saw %u" - % (total_blks, offset)) - - junk_len = len(FH.read()) - if junk_len: - print("There were %u bytes of extra data at the end of the file." - % (junk_len)) - - sys.exit(0) - -if __name__ == "__main__": - main()