├── .classpath
├── .cproject
├── .externalToolBuilders
└── org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder.launch
├── .gitattributes
├── .gitignore
├── .project
├── .settings
├── org.eclipse.cdt.codan.core.prefs
├── org.eclipse.core.resources.prefs
└── org.eclipse.jdt.core.prefs
├── AndroidManifest.xml
├── README.md
├── jni
├── Android.mk
├── Application.mk
├── edify
│ ├── Android.mk
│ ├── expr.c
│ ├── expr.h
│ ├── lexer.cpp
│ ├── main.c
│ ├── parser.cpp
│ ├── parser.h
│ └── yydefs.h
├── ext4_utils
│ ├── Android.mk
│ ├── allocate.c
│ ├── allocate.h
│ ├── canned_fs_config.c
│ ├── canned_fs_config.h
│ ├── contents.c
│ ├── contents.h
│ ├── crc16.c
│ ├── ext2simg.c
│ ├── ext4.h
│ ├── ext4_extents.h
│ ├── ext4_kernel_headers.h
│ ├── ext4_sb.c
│ ├── ext4_sb.h
│ ├── ext4_utils.c
│ ├── ext4_utils.h
│ ├── ext4fixup.c
│ ├── ext4fixup.h
│ ├── ext4fixup_main.c
│ ├── extent.c
│ ├── extent.h
│ ├── indirect.c
│ ├── indirect.h
│ ├── jbd2.h
│ ├── make_ext4fs.c
│ ├── make_ext4fs.h
│ ├── make_ext4fs_main.c
│ ├── setup_fs.c
│ ├── sha1.c
│ ├── sha1.h
│ ├── uuid.c
│ ├── uuid.h
│ ├── wipe.c
│ ├── wipe.h
│ └── xattr.h
├── libmincrypt
│ ├── Android.mk
│ ├── dsa_sig.c
│ ├── dsa_sig.h
│ ├── hash-internal.h
│ ├── p256.c
│ ├── p256.h
│ ├── p256_ec.c
│ ├── p256_ecdsa.c
│ ├── p256_ecdsa.h
│ ├── rsa.c
│ ├── rsa.h
│ ├── sha.c
│ ├── sha.h
│ ├── sha256.c
│ └── sha256.h
├── libsparse
│ ├── Android.mk
│ ├── append2simg.c
│ ├── backed_block.c
│ ├── backed_block.h
│ ├── defs.h
│ ├── img2simg.c
│ ├── include
│ │ └── sparse
│ │ │ └── sparse.h
│ ├── output_file.c
│ ├── output_file.h
│ ├── simg2img.c
│ ├── simg2simg.c
│ ├── sparse.c
│ ├── sparse_crc32.c
│ ├── sparse_crc32.h
│ ├── sparse_defs.h
│ ├── sparse_err.c
│ ├── sparse_file.h
│ ├── sparse_format.h
│ └── sparse_read.c
├── minzip
│ ├── Android.mk
│ ├── Bits.h
│ ├── DirUtil.c
│ ├── DirUtil.h
│ ├── Hash.c
│ ├── Hash.h
│ ├── Inlines.c
│ ├── Log.h
│ ├── SysUtil.c
│ ├── SysUtil.h
│ ├── Zip.c
│ ├── Zip.h
│ └── inline_magic.h
├── mtdutils
│ ├── Android.mk
│ ├── flash_image.c
│ ├── mounts.c
│ ├── mounts.h
│ ├── mtd-abi.h
│ ├── mtd-user.h
│ ├── mtdutils.c
│ └── mtdutils.h
├── safe-iop
│ ├── Android.mk
│ ├── include
│ │ └── safe_iop.h
│ └── src
│ │ └── safe_iop.c
├── update-binary
│ ├── Android.mk
│ ├── install.c
│ ├── install.h
│ ├── update-binary.c
│ └── update-binary.h
└── zlib
│ ├── Android.mk
│ ├── src
│ ├── adler32.c
│ ├── compress.c
│ ├── crc32.c
│ ├── crc32.h
│ ├── deflate.c
│ ├── deflate.h
│ ├── gzclose.c
│ ├── gzguts.h
│ ├── gzlib.c
│ ├── gzread.c
│ ├── gzwrite.c
│ ├── infback.c
│ ├── inffast.c
│ ├── inffast.h
│ ├── inffixed.h
│ ├── inflate.c
│ ├── inflate.h
│ ├── inftrees.c
│ ├── inftrees.h
│ ├── trees.c
│ ├── trees.h
│ ├── uncompr.c
│ ├── zconf.h
│ ├── zlib.h
│ ├── zutil.c
│ └── zutil.h
│ ├── zconf.h
│ ├── zlib.h
│ └── zutil.h
├── project.properties
└── res
├── drawable-hdpi
└── ic_launcher.png
├── drawable-mdpi
└── ic_launcher.png
├── drawable-xhdpi
└── ic_launcher.png
└── values
├── strings.xml
└── styles.xml
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.cproject:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 |
5 | # Folder config file
6 | Desktop.ini
7 |
8 | # Recycle Bin used on file shares
9 | $RECYCLE.BIN/
10 |
11 | # Windows Installer files
12 | *.cab
13 | *.msi
14 | *.msm
15 | *.msp
16 |
17 | # Windows shortcuts
18 | *.lnk
19 |
20 | # =========================
21 | # Operating System Files
22 | # =========================
23 |
24 | # OSX
25 | # =========================
26 |
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 |
31 | # Thumbnails
32 | ._*
33 |
34 | # Files that might appear in the root of a volume
35 | .DocumentRevisions-V100
36 | .fseventsd
37 | .Spotlight-V100
38 | .TemporaryItems
39 | .Trashes
40 | .VolumeIcon.icns
41 |
42 | # Directories potentially created on remote AFP share
43 | .AppleDB
44 | .AppleDesktop
45 | Network Trash Folder
46 | Temporary Items
47 | .apdisk
48 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Custom_update-binary
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.andmore.ResourceManagerBuilder
16 |
17 |
18 |
19 |
20 | org.eclipse.andmore.PreCompilerBuilder
21 |
22 |
23 |
24 |
25 | org.eclipse.jdt.core.javabuilder
26 |
27 |
28 |
29 |
30 | org.eclipse.andmore.ApkBuilder
31 |
32 |
33 |
34 |
35 | org.eclipse.ui.externaltools.ExternalToolBuilder
36 | full,incremental,
37 |
38 |
39 | LaunchConfigHandle
40 | <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder.launch
41 |
42 |
43 |
44 |
45 |
46 | org.eclipse.andmore.AndroidNature
47 | org.eclipse.jdt.core.javanature
48 | org.eclipse.cdt.core.cnature
49 | org.eclipse.cdt.core.ccnature
50 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
51 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
52 |
53 |
54 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//jni/libxslt/libxslt/xslt.c=UTF-8
3 | encoding/=UTF-8
4 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
3 | org.eclipse.jdt.core.compiler.compliance=1.7
4 | org.eclipse.jdt.core.compiler.source=1.7
5 |
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
9 |
10 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Conventional update-binary for Android recovery (Eclipse NDK build)---Mainly for CWM/TWRP Recovery
2 |
3 | Some people may curious how does update-binary in your update.zip is created...And what is going on inside of it
4 |
5 | This show you how to compile it in normal way.
6 |
7 | # Features
8 | 1. Execution speed is faster, binary size is much smaller than AOSP rom generated binary, even without any PE compression.
9 | 2. Function is shrinked, but added set file permission.
10 | 3. Compatible with most platform, ARM, x86, etc.
11 | 4. SELinux is deleted from code.
12 |
13 | # Usage and common errors
14 | ## Usage
15 | Create a script file call "updater-script" inside your zip folder, e.g: ZIPFILE/META-INF/com/google/android/, edit your script here.
16 |
17 | Put your compiled update-binary into that folder too, pack your zip correctly(7zip deflate) will do the job, finally test your zip installer.
18 | ## Errors
19 | 1. Incompatible binary is used. You may using x86 binary on ARM devices.
20 | 2. Check your script, wrong syntax will cause error.
21 |
22 | # Example "updater-script" from [JamesDSPManager .zip installer](https://github.com/james34602/JamesDSPManager):
23 | ```
24 | ui_print("**********************************************");
25 | ui_print("*Installing JamesDSP for Android 5.X.X or above (ARM)*");
26 | ui_print("**********************************************");
27 | run_program("/sbin/busybox", "mount", "/system");
28 | delete_recursive("/system/app/MusicFX");
29 | delete_recursive("/system/priv-app/MusicFX");
30 | delete_recursive("/system/priv-app/AudioFX");
31 | delete_recursive("/system/priv-app/SoundAlive_20_L");
32 | delete_recursive("/system/priv-app/SoundAlive_30");
33 | delete_recursive("/data/data/org.cyanogenmod.audiofx");
34 | delete_recursive("/data/data/com.android.musicfx");
35 | delete_recursive("/data/data/com.sec.android.app.soundalive");
36 | delete("/system/app/DSPManager_All.apk");
37 | delete("/system/lib/libjamesDSPImpulseToolbox.so");
38 | delete("/system/lib/soundfx/libjamesdsp.so");
39 | delete("/system/vendor/etc/audio_effects.conf");
40 | package_extract_dir("system", "/system");
41 | ui_print("Fixing permissions...");
42 | set_perm(0, 0, 0644, "/system/app/DSPManager_All.apk");
43 | set_perm(0, 0, 0644, "/system/lib/libjamesDSPImpulseToolbox.so");
44 | set_perm(0, 0, 0644, "/system/lib/soundfx/libjamesdsp.so");
45 | set_perm(0, 0, 0644, "/system/vendor/etc/audio_effects.conf");
46 | run_program("/sbin/busybox", "umount", "/system");
47 | ui_print("**********************************************");
48 | ui_print("* Installation complete... *");
49 | ui_print("* Please reboot and launch JamesDSP *");
50 | ui_print("**********************************************");
51 | show_progress(0.100000, 0);
52 | ```
--------------------------------------------------------------------------------
/jni/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH:= $(call my-dir)
2 | include $(CLEAR_VARS)
3 | include $(call all-makefiles-under,$(LOCAL_PATH))
--------------------------------------------------------------------------------
/jni/Application.mk:
--------------------------------------------------------------------------------
1 | APP_OPTIM := release
2 | APP_ABI := armeabi-v7a x86
--------------------------------------------------------------------------------
/jni/edify/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 | edify_src_files := \
4 | lexer.cpp \
5 | parser.cpp \
6 | expr.c
7 | LOCAL_SRC_FILES := $(edify_src_files)
8 | LOCAL_CPPFLAGS += -ffunction-sections -fdata-sections -Ofast -ftree-vectorize -DNDEBUG
9 | LOCAL_CFLAGS += -ffunction-sections -fdata-sections -Ofast -ftree-vectorize -DNDEBUG
10 | LOCAL_MODULE := libedify
11 | include $(BUILD_STATIC_LIBRARY)
12 |
--------------------------------------------------------------------------------
/jni/edify/expr.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2009 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #ifndef _EXPRESSION_H
18 | #define _EXPRESSION_H
19 |
20 | #include
21 |
22 | #include "yydefs.h"
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | #define MAX_STRING_LEN 1024
29 |
30 | typedef struct Expr Expr;
31 |
32 | typedef struct {
33 | // Optional pointer to app-specific data; the core of edify never
34 | // uses this value.
35 | void* cookie;
36 |
37 | // The source of the original script. Must be NULL-terminated,
38 | // and in writable memory (Evaluate may make temporary changes to
39 | // it but will restore it when done).
40 | char* script;
41 |
42 | // The error message (if any) returned if the evaluation aborts.
43 | // Should be NULL initially, will be either NULL or a malloc'd
44 | // pointer after Evaluate() returns.
45 | char* errmsg;
46 | } State;
47 |
48 | #define VAL_STRING 1 // data will be NULL-terminated; size doesn't count null
49 | #define VAL_BLOB 2
50 |
51 | typedef struct {
52 | int type;
53 | ssize_t size;
54 | char* data;
55 | } Value;
56 |
57 | typedef Value* (*Function)(const char* name, State* state,
58 | int argc, Expr* argv[]);
59 |
60 | struct Expr {
61 | Function fn;
62 | char* name;
63 | int argc;
64 | Expr** argv;
65 | int start, end;
66 | };
67 |
68 | // Take one of the Expr*s passed to the function as an argument,
69 | // evaluate it, return the resulting Value. The caller takes
70 | // ownership of the returned Value.
71 | Value* EvaluateValue(State* state, Expr* expr);
72 |
73 | // Take one of the Expr*s passed to the function as an argument,
74 | // evaluate it, assert that it is a string, and return the resulting
75 | // char*. The caller takes ownership of the returned char*. This is
76 | // a convenience function for older functions that want to deal only
77 | // with strings.
78 | char* Evaluate(State* state, Expr* expr);
79 |
80 | // Glue to make an Expr out of a literal.
81 | Value* Literal(const char* name, State* state, int argc, Expr* argv[]);
82 |
83 | // Functions corresponding to various syntactic sugar operators.
84 | // ("concat" is also available as a builtin function, to concatenate
85 | // more than two strings.)
86 | Value* ConcatFn(const char* name, State* state, int argc, Expr* argv[]);
87 | Value* LogicalAndFn(const char* name, State* state, int argc, Expr* argv[]);
88 | Value* LogicalOrFn(const char* name, State* state, int argc, Expr* argv[]);
89 | Value* LogicalNotFn(const char* name, State* state, int argc, Expr* argv[]);
90 | Value* SubstringFn(const char* name, State* state, int argc, Expr* argv[]);
91 | Value* EqualityFn(const char* name, State* state, int argc, Expr* argv[]);
92 | Value* InequalityFn(const char* name, State* state, int argc, Expr* argv[]);
93 | Value* SequenceFn(const char* name, State* state, int argc, Expr* argv[]);
94 |
95 | // Convenience function for building expressions with a fixed number
96 | // of arguments.
97 | Expr* Build(Function fn, YYLTYPE loc, int count, ...);
98 |
99 | // Global builtins, registered by RegisterBuiltins().
100 | Value* IfElseFn(const char* name, State* state, int argc, Expr* argv[]);
101 | Value* AssertFn(const char* name, State* state, int argc, Expr* argv[]);
102 | Value* AbortFn(const char* name, State* state, int argc, Expr* argv[]);
103 |
104 |
105 | // For setting and getting the global error string (when returning
106 | // NULL from a function).
107 | void SetError(const char* message); // makes a copy
108 | const char* GetError(); // retains ownership
109 | void ClearError();
110 |
111 |
112 | typedef struct {
113 | const char* name;
114 | Function fn;
115 | } NamedFunction;
116 |
117 | // Register a new function. The same Function may be registered under
118 | // multiple names, but a given name should only be used once.
119 | void RegisterFunction(const char* name, Function fn);
120 |
121 | // Register all the builtins.
122 | void RegisterBuiltins();
123 |
124 | // Call this after all calls to RegisterFunction() but before parsing
125 | // any scripts to finish building the function table.
126 | void FinishRegistration();
127 |
128 | // Find the Function for a given name; return NULL if no such function
129 | // exists.
130 | Function FindFunction(const char* name);
131 |
132 |
133 | // --- convenience functions for use in functions ---
134 |
135 | // Evaluate the expressions in argv, giving 'count' char* (the ... is
136 | // zero or more char** to put them in). If any expression evaluates
137 | // to NULL, free the rest and return -1. Return 0 on success.
138 | int ReadArgs(State* state, Expr* argv[], int count, ...);
139 |
140 | // Evaluate the expressions in argv, giving 'count' Value* (the ... is
141 | // zero or more Value** to put them in). If any expression evaluates
142 | // to NULL, free the rest and return -1. Return 0 on success.
143 | int ReadValueArgs(State* state, Expr* argv[], int count, ...);
144 |
145 | // Evaluate the expressions in argv, returning an array of char*
146 | // results. If any evaluate to NULL, free the rest and return NULL.
147 | // The caller is responsible for freeing the returned array and the
148 | // strings it contains.
149 | char** ReadVarArgs(State* state, int argc, Expr* argv[]);
150 |
151 | // Evaluate the expressions in argv, returning an array of Value*
152 | // results. If any evaluate to NULL, free the rest and return NULL.
153 | // The caller is responsible for freeing the returned array and the
154 | // Values it contains.
155 | Value** ReadValueVarArgs(State* state, int argc, Expr* argv[]);
156 |
157 | // Use printf-style arguments to compose an error message to put into
158 | // *state. Returns NULL.
159 | Value* ErrorAbort(State* state, const char* format, ...) __attribute__((format(printf, 2, 3)));
160 |
161 | // Wrap a string into a Value, taking ownership of the string.
162 | Value* StringValue(char* str);
163 |
164 | // Free a Value object.
165 | void FreeValue(Value* v);
166 |
167 | int parse_string(const char* str, Expr** root, int* error_count);
168 |
169 | #ifdef __cplusplus
170 | } // extern "C"
171 | #endif
172 |
173 | #endif // _EXPRESSION_H
174 |
--------------------------------------------------------------------------------
/jni/edify/parser.h:
--------------------------------------------------------------------------------
1 | #ifndef parser_h
2 | #define parser_h
3 | /* A Bison parser, made by GNU Bison 2.7. */
4 |
5 | /* Bison interface for Yacc-like parsers in C
6 |
7 | Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
8 |
9 | This program is free software: you can redistribute it and/or modify
10 | it under the terms of the GNU General Public License as published by
11 | the Free Software Foundation, either version 3 of the License, or
12 | (at your option) any later version.
13 |
14 | This program is distributed in the hope that it will be useful,
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | GNU General Public License for more details.
18 |
19 | You should have received a copy of the GNU General Public License
20 | along with this program. If not, see . */
21 |
22 | /* As a special exception, you may create a larger work that contains
23 | part or all of the Bison parser skeleton and distribute that work
24 | under terms of your choice, so long as that work isn't itself a
25 | parser generator using the skeleton or a modified version thereof
26 | as a parser skeleton. Alternatively, if you modify or redistribute
27 | the parser skeleton itself, you may (at your option) remove this
28 | special exception, which will cause the skeleton and the resulting
29 | Bison output files to be licensed under the GNU General Public
30 | License without this special exception.
31 |
32 | This special exception was added by the Free Software Foundation in
33 | version 2.2 of Bison. */
34 |
35 | #ifndef YY_YY_OUT_TARGET_PRODUCT_GENERIC_OBJ_STATIC_LIBRARIES_LIBEDIFY_INTERMEDIATES_PARSER_HPP_INCLUDED
36 | # define YY_YY_OUT_TARGET_PRODUCT_GENERIC_OBJ_STATIC_LIBRARIES_LIBEDIFY_INTERMEDIATES_PARSER_HPP_INCLUDED
37 | /* Enabling traces. */
38 | #ifndef YYDEBUG
39 | # define YYDEBUG 0
40 | #endif
41 | #if YYDEBUG
42 | extern int yydebug;
43 | #endif
44 |
45 | /* Tokens. */
46 | #ifndef YYTOKENTYPE
47 | # define YYTOKENTYPE
48 | /* Put the tokens into the symbol table, so that GDB and other debuggers
49 | know about them. */
50 | enum yytokentype {
51 | AND = 258,
52 | OR = 259,
53 | SUBSTR = 260,
54 | SUPERSTR = 261,
55 | EQ = 262,
56 | NE = 263,
57 | IF = 264,
58 | THEN = 265,
59 | ELSE = 266,
60 | ENDIF = 267,
61 | STRING = 268,
62 | BAD = 269
63 | };
64 | #endif
65 |
66 |
67 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
68 | typedef union YYSTYPE
69 | {
70 | /* Line 2058 of yacc.c */
71 | #line 40 "bootable/recovery/edify/parser.y"
72 |
73 | char* str;
74 | Expr* expr;
75 | struct {
76 | int argc;
77 | Expr** argv;
78 | } args;
79 |
80 |
81 | /* Line 2058 of yacc.c */
82 | #line 81 "out/target/product/generic/obj/STATIC_LIBRARIES/libedify_intermediates/parser.hpp"
83 | } YYSTYPE;
84 | # define YYSTYPE_IS_TRIVIAL 1
85 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */
86 | # define YYSTYPE_IS_DECLARED 1
87 | #endif
88 |
89 | #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
90 | typedef struct YYLTYPE
91 | {
92 | int first_line;
93 | int first_column;
94 | int last_line;
95 | int last_column;
96 | } YYLTYPE;
97 | # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
98 | # define YYLTYPE_IS_DECLARED 1
99 | # define YYLTYPE_IS_TRIVIAL 1
100 | #endif
101 |
102 | extern YYSTYPE yylval;
103 | extern YYLTYPE yylloc;
104 | #ifdef YYPARSE_PARAM
105 | #if defined __STDC__ || defined __cplusplus
106 | int yyparse (void *YYPARSE_PARAM);
107 | #else
108 | int yyparse ();
109 | #endif
110 | #else /* ! YYPARSE_PARAM */
111 | #if defined __STDC__ || defined __cplusplus
112 | int yyparse (Expr** root, int* error_count);
113 | #else
114 | int yyparse ();
115 | #endif
116 | #endif /* ! YYPARSE_PARAM */
117 |
118 | #endif /* !YY_YY_OUT_TARGET_PRODUCT_GENERIC_OBJ_STATIC_LIBRARIES_LIBEDIFY_INTERMEDIATES_PARSER_HPP_INCLUDED */
119 | #endif
120 |
--------------------------------------------------------------------------------
/jni/edify/yydefs.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2009 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #ifndef _YYDEFS_H_
18 | #define _YYDEFS_H_
19 |
20 | #define YYLTYPE YYLTYPE
21 | typedef struct {
22 | int start, end;
23 | } YYLTYPE;
24 |
25 | #define YYLLOC_DEFAULT(Current, Rhs, N) \
26 | do { \
27 | if (N) { \
28 | (Current).start = YYRHSLOC(Rhs, 1).start; \
29 | (Current).end = YYRHSLOC(Rhs, N).end; \
30 | } else { \
31 | (Current).start = YYRHSLOC(Rhs, 0).start; \
32 | (Current).end = YYRHSLOC(Rhs, 0).end; \
33 | } \
34 | } while (0)
35 |
36 | int yylex();
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/jni/ext4_utils/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH:= $(call my-dir)
2 | libext4_utils_src_files := \
3 | make_ext4fs.c \
4 | ext4fixup.c \
5 | ext4_utils.c \
6 | allocate.c \
7 | contents.c \
8 | extent.c \
9 | indirect.c \
10 | uuid.c \
11 | sha1.c \
12 | wipe.c \
13 | crc16.c \
14 | ext4_sb.c
15 |
16 | include $(CLEAR_VARS)
17 | LOCAL_SRC_FILES := $(libext4_utils_src_files)
18 | LOCAL_CPPFLAGS += -ffunction-sections -fdata-sections -Ofast -ftree-vectorize -DNDEBUG
19 | LOCAL_CFLAGS += -ffunction-sections -fdata-sections -Ofast -ftree-vectorize -DNDEBUG
20 | LOCAL_MODULE := libext4_utils_static
21 | LOCAL_STATIC_LIBRARIES += \
22 | libsparse_static
23 | include $(BUILD_STATIC_LIBRARY)
24 |
--------------------------------------------------------------------------------
/jni/ext4_utils/allocate.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #ifndef _ALLOCATE_H_
18 | #define _ALLOCATE_H_
19 |
20 | #define EXT4_ALLOCATE_FAILED (u32)(~0)
21 |
22 | #include "ext4_utils.h"
23 |
24 | struct region;
25 |
26 | struct region_list {
27 | struct region *first;
28 | struct region *last;
29 | struct region *iter;
30 | u32 partial_iter;
31 | };
32 |
33 | struct block_allocation {
34 | struct region_list list;
35 | struct region_list oob_list;
36 | char* filename;
37 | struct block_allocation* next;
38 | };
39 |
40 |
41 | void block_allocator_init();
42 | void block_allocator_free();
43 | u32 allocate_block();
44 | struct block_allocation *allocate_blocks(u32 len);
45 | int block_allocation_num_regions(struct block_allocation *alloc);
46 | int block_allocation_len(struct block_allocation *alloc);
47 | struct ext4_inode *get_inode(u32 inode);
48 | struct ext4_xattr_header *get_xattr_block_for_inode(struct ext4_inode *inode);
49 | void reduce_allocation(struct block_allocation *alloc, u32 len);
50 | u32 get_block(struct block_allocation *alloc, u32 block);
51 | u32 get_oob_block(struct block_allocation *alloc, u32 block);
52 | void get_next_region(struct block_allocation *alloc);
53 | void get_region(struct block_allocation *alloc, u32 *block, u32 *len);
54 | u32 get_free_blocks(u32 bg);
55 | u32 get_free_inodes(u32 bg);
56 | u32 reserve_inodes(int bg, u32 inodes);
57 | void add_directory(u32 inode);
58 | u16 get_directories(int bg);
59 | u16 get_bg_flags(int bg);
60 | void init_unused_inode_tables(void);
61 | u32 allocate_inode();
62 | void free_alloc(struct block_allocation *alloc);
63 | int reserve_oob_blocks(struct block_allocation *alloc, int blocks);
64 | int advance_blocks(struct block_allocation *alloc, int blocks);
65 | int advance_oob_blocks(struct block_allocation *alloc, int blocks);
66 | int last_region(struct block_allocation *alloc);
67 | void rewind_alloc(struct block_allocation *alloc);
68 | void append_region(struct block_allocation *alloc,
69 | u32 block, u32 len, int bg);
70 | struct block_allocation *create_allocation();
71 | int append_oob_allocation(struct block_allocation *alloc, u32 len);
72 | void print_blocks(FILE* f, struct block_allocation *alloc);
73 |
74 | #endif
75 |
--------------------------------------------------------------------------------
/jni/ext4_utils/canned_fs_config.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | #include "private/android_filesystem_config.h"
24 |
25 | #include "canned_fs_config.h"
26 |
27 | typedef struct {
28 | const char* path;
29 | unsigned uid;
30 | unsigned gid;
31 | unsigned mode;
32 | uint64_t capabilities;
33 | } Path;
34 |
35 | static Path* canned_data = NULL;
36 | static int canned_alloc = 0;
37 | static int canned_used = 0;
38 |
39 | static int path_compare(const void* a, const void* b) {
40 | return strcmp(((Path*)a)->path, ((Path*)b)->path);
41 | }
42 |
43 | int load_canned_fs_config(const char* fn) {
44 | FILE* f = fopen(fn, "r");
45 | if (f == NULL) {
46 | fprintf(stderr, "failed to open %s: %s\n", fn, strerror(errno));
47 | return -1;
48 | }
49 |
50 | char line[PATH_MAX + 200];
51 | while (fgets(line, sizeof(line), f)) {
52 | while (canned_used >= canned_alloc) {
53 | canned_alloc = (canned_alloc+1) * 2;
54 | canned_data = (Path*) realloc(canned_data, canned_alloc * sizeof(Path));
55 | }
56 | Path* p = canned_data + canned_used;
57 | p->path = strdup(strtok(line, " "));
58 | p->uid = atoi(strtok(NULL, " "));
59 | p->gid = atoi(strtok(NULL, " "));
60 | p->mode = strtol(strtok(NULL, " "), NULL, 8); // mode is in octal
61 | p->capabilities = 0;
62 |
63 | char* token = NULL;
64 | do {
65 | token = strtok(NULL, " ");
66 | if (token && strncmp(token, "capabilities=", 13) == 0) {
67 | p->capabilities = strtoll(token+13, NULL, 0);
68 | break;
69 | }
70 | } while (token);
71 |
72 | canned_used++;
73 | }
74 |
75 | fclose(f);
76 |
77 | qsort(canned_data, canned_used, sizeof(Path), path_compare);
78 | printf("loaded %d fs_config entries\n", canned_used);
79 |
80 | return 0;
81 | }
82 |
83 | void canned_fs_config(const char* path, int dir,
84 | unsigned* uid, unsigned* gid, unsigned* mode, uint64_t* capabilities) {
85 | Path key;
86 | key.path = path+1; // canned paths lack the leading '/'
87 | Path* p = (Path*) bsearch(&key, canned_data, canned_used, sizeof(Path), path_compare);
88 | if (p == NULL) {
89 | fprintf(stderr, "failed to find [%s] in canned fs_config\n", path);
90 | exit(1);
91 | }
92 | *uid = p->uid;
93 | *gid = p->gid;
94 | *mode = p->mode;
95 | *capabilities = p->capabilities;
96 |
97 | #if 0
98 | // for debugging, run the built-in fs_config and compare the results.
99 |
100 | unsigned c_uid, c_gid, c_mode;
101 | uint64_t c_capabilities;
102 | fs_config(path, dir, &c_uid, &c_gid, &c_mode, &c_capabilities);
103 |
104 | if (c_uid != *uid) printf("%s uid %d %d\n", path, *uid, c_uid);
105 | if (c_gid != *gid) printf("%s gid %d %d\n", path, *gid, c_gid);
106 | if (c_mode != *mode) printf("%s mode 0%o 0%o\n", path, *mode, c_mode);
107 | if (c_capabilities != *capabilities) printf("%s capabilities %llx %llx\n", path, *capabilities, c_capabilities);
108 | #endif
109 | }
110 |
--------------------------------------------------------------------------------
/jni/ext4_utils/canned_fs_config.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #ifndef _CANNED_FS_CONFIG_H
18 | #define _CANNED_FS_CONFIG_H
19 |
20 | #include
21 |
22 | int load_canned_fs_config(const char* fn);
23 | void canned_fs_config(const char* path, int dir,
24 | unsigned* uid, unsigned* gid, unsigned* mode, uint64_t* capabilities);
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/jni/ext4_utils/contents.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #ifndef _DIRECTORY_H_
18 | #define _DIRECTORY_H_
19 |
20 | struct dentry {
21 | char *path;
22 | char *full_path;
23 | const char *filename;
24 | char *link;
25 | unsigned long size;
26 | u8 file_type;
27 | u16 mode;
28 | u16 uid;
29 | u16 gid;
30 | u32 *inode;
31 | u32 mtime;
32 | char *secon;
33 | uint64_t capabilities;
34 | };
35 |
36 | u32 make_directory(u32 dir_inode_num, u32 entries, struct dentry *dentries,
37 | u32 dirs);
38 | u32 make_file(const char *filename, u64 len);
39 | u32 make_link(const char *link);
40 | int inode_set_permissions(u32 inode_num, u16 mode, u16 uid, u16 gid, u32 mtime);
41 | int inode_set_selinux(u32 inode_num, const char *secon);
42 | int inode_set_capabilities(u32 inode_num, uint64_t capabilities);
43 | struct block_allocation* get_saved_allocation_chain();
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/jni/ext4_utils/crc16.c:
--------------------------------------------------------------------------------
1 | /*-
2 | * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
3 | * code or tables extracted from it, as desired without restriction.
4 | */
5 |
6 | /* CRC32 code derived from work by Gary S. Brown. */
7 |
8 | /* Code taken from FreeBSD 8 */
9 |
10 | /* Converted to crc16 */
11 |
12 | #include "ext4_utils.h"
13 |
14 | static u16 crc16_tab[] = {
15 | 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
16 | 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
17 | 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
18 | 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
19 | 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
20 | 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
21 | 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
22 | 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
23 | 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
24 | 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
25 | 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
26 | 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
27 | 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
28 | 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
29 | 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
30 | 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
31 | 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
32 | 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
33 | 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
34 | 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
35 | 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
36 | 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
37 | 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
38 | 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
39 | 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
40 | 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
41 | 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
42 | 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
43 | 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
44 | 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
45 | 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
46 | 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040,
47 | };
48 |
49 | u16 ext4_crc16(u16 crc_in, const void *buf, int size)
50 | {
51 | const u8 *p = buf;
52 | u16 crc = crc_in;
53 |
54 | while (size--)
55 | crc = crc16_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
56 |
57 | return crc;
58 | }
59 |
--------------------------------------------------------------------------------
/jni/ext4_utils/ext2simg.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #define _FILE_OFFSET_BITS 64
18 | #define _LARGEFILE64_SOURCE 1
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | #include
29 |
30 | #include "ext4_utils.h"
31 | #include "make_ext4fs.h"
32 | #include "allocate.h"
33 |
34 | #if defined(__APPLE__) && defined(__MACH__)
35 | #define off64_t off_t
36 | #endif
37 |
38 | #ifndef USE_MINGW /* O_BINARY is windows-specific flag */
39 | #define O_BINARY 0
40 | #endif
41 |
42 | extern struct fs_info info;
43 |
44 | static int verbose = 0;
45 |
46 | static void usage(char *path)
47 | {
48 | fprintf(stderr, "%s [ options ]