diff options
author | Jaegeuk Kim <jaegeuk@google.com> | 2017-11-14 19:18:09 -0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@google.com> | 2017-11-17 13:22:47 -0800 |
commit | 441f34764125dace5910a03e6a6f2c9bad48a3a6 (patch) | |
tree | 6a2aed990df13c3cf948bd7e5740e34b3fe385b0 /f2fs_utils | |
parent | 5944afdd9f38f74c334390f2e69daf37b34d7bb6 (diff) | |
download | extras-441f34764125dace5910a03e6a6f2c9bad48a3a6.tar.gz |
f2fs_utils: enable mac build by removing dead codes
We don't need to compile some dead codes, since we start to use make_f2fs built
from external/f2fs-tools directly.
Bug: 69298953
Change-Id: If4e3babcf0b3868a3368e89787b251d305719a0f
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Diffstat (limited to 'f2fs_utils')
-rw-r--r-- | f2fs_utils/Android.bp | 122 | ||||
-rw-r--r-- | f2fs_utils/f2fs_dlutils.c | 65 | ||||
-rw-r--r-- | f2fs_utils/f2fs_ioutils.c | 243 | ||||
-rw-r--r-- | f2fs_utils/f2fs_utils.c | 76 | ||||
-rw-r--r-- | f2fs_utils/make_f2fs.h | 33 | ||||
-rw-r--r-- | f2fs_utils/make_f2fs_main.c | 91 |
6 files changed, 0 insertions, 630 deletions
diff --git a/f2fs_utils/Android.bp b/f2fs_utils/Android.bp index 9c20a1ce..b5d6c9b2 100644 --- a/f2fs_utils/Android.bp +++ b/f2fs_utils/Android.bp @@ -1,127 +1,5 @@ // Copyright 2017 The Android Open Source Project -cc_library_host_static { - name: "libf2fs_utils_host", - defaults: ["system-extras-cflags-defaults"], - - srcs: ["f2fs_utils.c"], - - static_libs: [ - "libsparse", - "libz", - ], - - include_dirs: [ - "external/f2fs-tools/include", - "external/f2fs-tools/mkfs", - ], - - target: { - darwin: { - enabled: false, - }, - }, -} - -cc_library_host_static { - name: "libf2fs_ioutils_host", - defaults: ["system-extras-cflags-defaults"], - - srcs: ["f2fs_ioutils.c"], - - include_dirs: [ - "external/f2fs-tools/include", - "external/f2fs-tools/mkfs", - ], - - static_libs: [ - "libselinux", - "libsparse", - "libext2_uuid", - "libz", - ], - - target: { - darwin: { - enabled: false, - }, - }, -} - -cc_library_host_static { - name: "libf2fs_dlutils_host", - defaults: ["system-extras-cflags-defaults"], - - srcs: ["f2fs_dlutils.c"], - - include_dirs: [ - "external/f2fs-tools/include", - "external/f2fs-tools/mkfs", - ], - - target: { - darwin: { - enabled: false, - }, - }, -} - -cc_library_shared { - name: "libf2fs_dlutils", - defaults: ["system-extras-cflags-defaults"], - - srcs: ["f2fs_dlutils.c"], - - include_dirs: [ - "external/f2fs-tools/include", - "external/f2fs-tools/mkfs", - ], - - target: { - darwin: { - enabled: false, - }, - }, -} - -cc_library_static { - name: "libf2fs_dlutils_static", - defaults: ["system-extras-cflags-defaults"], - - srcs: ["f2fs_dlutils.c"], - - include_dirs: [ - "external/f2fs-tools/include", - "external/f2fs-tools/mkfs", - ], - - target: { - darwin: { - enabled: false, - }, - }, -} - -cc_library_static { - name: "libf2fs_utils_static", - defaults: ["system-extras-cflags-defaults"], - - srcs: ["f2fs_utils.c"], - - include_dirs: [ - "external/f2fs-tools/include", - "external/f2fs-tools/mkfs", - ], - - static_libs: ["libsparse"], - - target: { - darwin: { - enabled: false, - }, - }, -} - cc_library_shared { name: "libf2fs_sparseblock", defaults: ["system-extras-cflags-defaults"], diff --git a/f2fs_utils/f2fs_dlutils.c b/f2fs_utils/f2fs_dlutils.c deleted file mode 100644 index 4b5e13ea..00000000 --- a/f2fs_utils/f2fs_dlutils.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#define _LARGEFILE64_SOURCE - -#include <stdio.h> - -#include <dlfcn.h> -#include <assert.h> - -#include <f2fs_fs.h> -#include <f2fs_format_utils.h> -#define F2FS_DYN_LIB "libf2fs_fmt_host_dyn.so" - -int (*f2fs_format_device_dl)(void); -void (*f2fs_init_configuration_dl)(void); - -int f2fs_format_device(void) { - assert(f2fs_format_device_dl); - return f2fs_format_device_dl(); -} -void f2fs_init_configuration(void) { - assert(f2fs_init_configuration_dl); - f2fs_init_configuration_dl(); -} - -int dlopenf2fs() { - void* f2fs_lib; - - f2fs_lib = dlopen(F2FS_DYN_LIB, RTLD_NOW); - if (!f2fs_lib) { - return -1; - } - f2fs_format_device_dl = dlsym(f2fs_lib, "f2fs_format_device"); - f2fs_init_configuration_dl = dlsym(f2fs_lib, "f2fs_init_configuration"); - if (!f2fs_format_device_dl || !f2fs_init_configuration_dl) { - return -1; - } - return 0; -} diff --git a/f2fs_utils/f2fs_ioutils.c b/f2fs_utils/f2fs_ioutils.c deleted file mode 100644 index c9275ff2..00000000 --- a/f2fs_utils/f2fs_ioutils.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#define _LARGEFILE64_SOURCE - -#include <assert.h> -#include <asm/types.h> -#include <dlfcn.h> -#include <errno.h> -#include <fcntl.h> -#include <linux/fs.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> /* memset() */ -#include <sys/param.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#include <f2fs_fs.h> -#include <f2fs_format_utils.h> - -#include <sparse/sparse.h> - -struct selabel_handle; - -#include "make_f2fs.h" - -#ifdef _WIN32 - -#include <winsock2.h> - -/* These match the Linux definitions of these flags. - L_xx is defined to avoid conflicting with the win32 versions. -*/ -#define L_S_IRUSR 00400 -#define L_S_IWUSR 00200 -#define L_S_IXUSR 00100 -#define S_IRWXU (L_S_IRUSR | L_S_IWUSR | L_S_IXUSR) -#define S_IRGRP 00040 -#define S_IWGRP 00020 -#define S_IXGRP 00010 -#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) -#define S_IROTH 00004 -#define S_IWOTH 00002 -#define S_IXOTH 00001 -#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) -#define S_ISUID 0004000 -#define S_ISGID 0002000 -#define S_ISVTX 0001000 - -#else - -#include <selinux/selinux.h> -#include <selinux/label.h> - -#define O_BINARY 0 - -#endif - -struct f2fs_configuration c; -struct sparse_file *f2fs_sparse_file; - -struct buf_item { - void *buf; - size_t len; - struct buf_item *next; -}; - -struct buf_item *buf_list; - -static int __get_device_fd(__u64 *offset) -{ - __u64 blk_addr = *offset >> F2FS_BLKSIZE_BITS; - int i; - - for (i = 0; i < c.ndevs; i++) { - if (c.devices[i].start_blkaddr <= blk_addr && - c.devices[i].end_blkaddr >= blk_addr) { - *offset -= - c.devices[i].start_blkaddr << F2FS_BLKSIZE_BITS; - return c.devices[i].fd; - } - } - return -1; -} - -static int dev_write_fd(void *buf, __u64 offset, size_t len) -{ - int fd = __get_device_fd(&offset); - - if (lseek64(fd, (off64_t)offset, SEEK_SET) < 0) - return -1; - ssize_t written = write(fd, buf, len); - if (written == -1) - return -1; - if ((size_t)written != len) - return -1; - return 0; -} - -void flush_sparse_buffs() -{ - while (buf_list) { - struct buf_item *bi = buf_list; - buf_list = buf_list->next; - free(bi->buf); - free(bi); - } -} - -static int dev_write_sparse(void *buf, __u64 byte_offset, size_t byte_len) -{ - struct buf_item *bi = calloc(1, sizeof(struct buf_item)); - - if (bi == NULL) { - return -ENOMEM; - } - bi->buf = malloc(byte_len); - if (bi->buf == NULL) { - free(bi); - return -ENOMEM; - } - - bi->len = byte_len; - memcpy(bi->buf, buf, byte_len); - bi->next = buf_list; - buf_list = bi; - - sparse_file_add_data(f2fs_sparse_file, bi->buf, byte_len, byte_offset/F2FS_BLKSIZE); - return 0; -} - -void f2fs_finalize_device(void) -{ -} - -int f2fs_trim_devices(void) -{ - return 0; -} - -/* - * IO interfaces - */ -int dev_read_version(void *buf, __u64 offset, size_t len) -{ - return 0; -} - -int dev_read(void *buf, __u64 offset, size_t len) -{ - return 0; -} - -int dev_readahead(__u64 offset, size_t len) -{ - return 0; -} - -int dev_write(void *buf, __u64 offset, size_t len) -{ - int fd = __get_device_fd(&offset); - - if (fd >= 0) { - return dev_write_fd(buf, offset, len); - } else { - return dev_write_sparse(buf, offset, len); - } -} - -int dev_write_block(void *buf, __u64 blk_addr) -{ - assert(false); // Must not be invoked. - return 0; -} - -int dev_write_dump(void *buf, __u64 offset, size_t len) -{ - assert(false); // Must not be invoked. - return 0; -} - -int dev_fill(void *buf, __u64 offset, size_t len) -{ - int fd = __get_device_fd(&offset); - int ret; - if (fd >= 0) { - return dev_write_fd(buf, offset, len); - } - // sparse file fills with zero by default. - // return sparse_file_add_fill(f2fs_sparse_file, ((__u8*)(bi->buf))[0], byte_len, byte_offset/F2FS_BLKSIZE); - return 0; -} - -int dev_fill_block(void *buf, __u64 blk_addr) -{ - assert(false); // Must not be invoked. - return 0; -} - -int dev_read_block(void *buf, __u64 blk_addr) -{ - assert(false); // Must not be invoked. - return 0; -} - -int dev_read_blocks(void *buf, __u64 addr, __u32 nr_blks) -{ - assert(false); // Must not be invoked. - return 0; -} - -int dev_reada_block(__u64 blk_addr) -{ - assert(false); // Must not be invoked. - return 0; -} diff --git a/f2fs_utils/f2fs_utils.c b/f2fs_utils/f2fs_utils.c deleted file mode 100644 index 0aa2f7a2..00000000 --- a/f2fs_utils/f2fs_utils.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#define _LARGEFILE64_SOURCE - -#include <fcntl.h> -#include <string.h> - -#include <f2fs_fs.h> -#include <f2fs_format_utils.h> - -#include <sparse/sparse.h> - -struct selabel_handle; - -#include "make_f2fs.h" - -extern void flush_sparse_buffs(); - -struct f2fs_configuration c; -struct sparse_file *f2fs_sparse_file; -extern int dlopenf2fs(); - -static void reset_f2fs_info() { - memset(&c, 0, sizeof(c)); - if (f2fs_sparse_file) { - sparse_file_destroy(f2fs_sparse_file); - f2fs_sparse_file = NULL; - } -} - -int make_f2fs_sparse_fd(int fd, long long len, - const char *mountpoint, struct selabel_handle *sehnd) -{ - if (dlopenf2fs() < 0) { - return -1; - } - reset_f2fs_info(); - f2fs_init_configuration(); - len &= ~((__u64)(F2FS_BLKSIZE - 1)); - c.sector_size = DEFAULT_SECTOR_SIZE; - c.total_sectors = len / c.sector_size; - c.start_sector = 0; - f2fs_sparse_file = sparse_file_new(F2FS_BLKSIZE, len); - f2fs_format_device(); - sparse_file_write(f2fs_sparse_file, fd, /*gzip*/0, /*sparse*/1, /*crc*/0); - sparse_file_destroy(f2fs_sparse_file); - flush_sparse_buffs(); - f2fs_sparse_file = NULL; - return 0; -} diff --git a/f2fs_utils/make_f2fs.h b/f2fs_utils/make_f2fs.h deleted file mode 100644 index f02694ae..00000000 --- a/f2fs_utils/make_f2fs.h +++ /dev/null @@ -1,33 +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. - */ - -#ifndef _MAKE_F2FS_H_ -#define _MAKE_F2FS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -struct selabel_handle; - -int make_f2fs_sparse_fd(int fd, long long len, - const char *mountpoint, struct selabel_handle *sehnd); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/f2fs_utils/make_f2fs_main.c b/f2fs_utils/make_f2fs_main.c deleted file mode 100644 index bceb23cd..00000000 --- a/f2fs_utils/make_f2fs_main.c +++ /dev/null @@ -1,91 +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 <fcntl.h> -#include <libgen.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#if defined(__linux__) -#include <linux/fs.h> -#elif defined(__APPLE__) && defined(__MACH__) -#include <sys/disk.h> -#endif - -#include "make_f2fs.h" - -#ifndef _WIN32 /* O_BINARY is windows-specific flag */ -#define O_BINARY 0 -#endif - -static void usage(char *path) -{ - fprintf(stderr, "%s -l <len>\n", basename(path)); - fprintf(stderr, " <filename>\n"); -} - -int main(int argc, char **argv) -{ - int opt; - const char *filename = NULL; - int fd; - int exitcode; - long long len; - while ((opt = getopt(argc, argv, "l:")) != -1) { - switch (opt) { - case 'l': - len = atoll(optarg); - break; - default: /* '?' */ - usage(argv[0]); - exit(EXIT_FAILURE); - } - } - - - if (optind >= argc) { - fprintf(stderr, "Expected filename after options\n"); - usage(argv[0]); - exit(EXIT_FAILURE); - } - - filename = argv[optind++]; - - if (optind < argc) { - fprintf(stderr, "Unexpected argument: %s\n", argv[optind]); - usage(argv[0]); - exit(EXIT_FAILURE); - } - - if (strcmp(filename, "-")) { - fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); - if (fd < 0) { - perror("open"); - return EXIT_FAILURE; - } - } else { - fd = STDOUT_FILENO; - } - - exitcode = make_f2fs_sparse_fd(fd, len, NULL, NULL); - - close(fd); - if (exitcode && strcmp(filename, "-")) - unlink(filename); - return exitcode; -} |