Small native code reorganization

This commit is contained in:
topjohnwu 2020-03-09 01:50:30 -07:00
parent d6fdbfe9b7
commit a0998009c1
85 changed files with 216 additions and 317 deletions

4
.gitattributes vendored
View File

@ -18,3 +18,7 @@ tools/** binary
*.png binary *.png binary
*.jpg binary *.jpg binary
*.ttf binary *.ttf binary
# Help GitHub detect languages
native/jni/external/** linguist-vendored
native/jni/systemproperties/** linguist-language=C++

View File

@ -45,8 +45,6 @@ LOCAL_SRC_FILES := \
magiskhide/hide_policy.cpp \ magiskhide/hide_policy.cpp \
resetprop/persist_properties.cpp \ resetprop/persist_properties.cpp \
resetprop/resetprop.cpp \ resetprop/resetprop.cpp \
resetprop/system_property_api.cpp \
resetprop/system_property_set.cpp \
su/su.cpp \ su/su.cpp \
su/connect.cpp \ su/connect.cpp \
su/pts.cpp \ su/pts.cpp \
@ -167,8 +165,6 @@ LOCAL_SRC_FILES := \
core/applet_stub.cpp \ core/applet_stub.cpp \
resetprop/persist_properties.cpp \ resetprop/persist_properties.cpp \
resetprop/resetprop.cpp \ resetprop/resetprop.cpp \
resetprop/system_property_api.cpp \
resetprop/system_property_set.cpp
LOCAL_CFLAGS := -DAPPLET_STUB_MAIN=resetprop_main LOCAL_CFLAGS := -DAPPLET_STUB_MAIN=resetprop_main
LOCAL_LDFLAGS := -static LOCAL_LDFLAGS := -static

View File

@ -1,6 +1,6 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <magisk.h> #include <magisk.hpp>
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
umask(0); umask(0);

View File

@ -4,9 +4,9 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <magisk.h> #include <magisk.hpp>
#include <selinux.h> #include <selinux.hpp>
#include <utils.h> #include <utils.hpp>
using namespace std::literals; using namespace std::literals;

View File

@ -9,12 +9,12 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <magisk.h> #include <magisk.hpp>
#include <db.h> #include <db.hpp>
#include <utils.h> #include <utils.hpp>
#include <daemon.h> #include <daemon.hpp>
#include <resetprop.h> #include <resetprop.hpp>
#include <selinux.h> #include <selinux.hpp>
#include <flags.h> #include <flags.h>
using namespace std; using namespace std;

View File

@ -8,12 +8,12 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <magisk.h> #include <magisk.hpp>
#include <utils.h> #include <utils.hpp>
#include <daemon.h> #include <daemon.hpp>
#include <selinux.h> #include <selinux.hpp>
#include <db.h> #include <db.hpp>
#include <resetprop.h> #include <resetprop.hpp>
#include <flags.h> #include <flags.h>
int SDK_INT = -1; int SDK_INT = -1;

View File

@ -6,10 +6,10 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <magisk.h> #include <magisk.hpp>
#include <db.h> #include <db.hpp>
#include <daemon.h> #include <daemon.hpp>
#include <utils.h> #include <utils.hpp>
#define DB_VERSION 10 #define DB_VERSION 10

View File

@ -5,10 +5,10 @@
#include <libgen.h> #include <libgen.h>
#include <string.h> #include <string.h>
#include <utils.h> #include <utils.hpp>
#include <magisk.h> #include <magisk.hpp>
#include <daemon.h> #include <daemon.hpp>
#include <selinux.h> #include <selinux.hpp>
#include <flags.h> #include <flags.h>
using namespace std::literals; using namespace std::literals;

View File

@ -4,9 +4,9 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <magisk.h> #include <magisk.hpp>
#include <utils.h> #include <utils.hpp>
#include <selinux.h> #include <selinux.hpp>
using namespace std; using namespace std;

View File

@ -6,9 +6,9 @@
#include <fcntl.h> #include <fcntl.h>
#include <endian.h> #include <endian.h>
#include <daemon.h> #include <daemon.hpp>
#include <utils.h> #include <utils.hpp>
#include <logging.h> #include <logging.hpp>
#define ABS_SOCKET_LEN(sun) (sizeof(sa_family_t) + strlen(sun->sun_path + 1) + 1) #define ABS_SOCKET_LEN(sun) (sizeof(sa_family_t) + strlen(sun->sun_path + 1) + 1)

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <logging.h> #include <logging.hpp>
#define MAIN_SOCKET "d30138f2310a9fb9c54a3e0c21f58591" #define MAIN_SOCKET "d30138f2310a9fb9c54a3e0c21f58591"
#define JAVA_PACKAGE_NAME "com.topjohnwu.magisk" #define JAVA_PACKAGE_NAME "com.topjohnwu.magisk"

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <stdlib.h> #include <stdlib.h>
#include <selinux.h> #include <selinux.hpp>
#define ALL NULL #define ALL NULL

View File

@ -5,10 +5,10 @@
#include <fcntl.h> #include <fcntl.h>
#include <vector> #include <vector>
#include <utils.h> #include <utils.hpp>
#include <logging.h> #include <logging.hpp>
#include "init.h" #include "init.hpp"
using namespace std; using namespace std;

View File

@ -8,9 +8,9 @@
#include <vector> #include <vector>
#include <xz.h> #include <xz.h>
#include <magisk.h> #include <magisk.hpp>
#include <cpio.h> #include <cpio.hpp>
#include <utils.h> #include <utils.hpp>
#include <flags.h> #include <flags.h>
#include "binaries.h" #include "binaries.h"
@ -20,7 +20,7 @@
#include "binaries_arch.h" #include "binaries_arch.h"
#endif #endif
#include "init.h" #include "init.hpp"
using namespace std; using namespace std;

View File

@ -3,7 +3,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <vector> #include <vector>
#include <magisk.h> #include <magisk.hpp>
struct cmdline { struct cmdline {
bool skip_initramfs; bool skip_initramfs;

View File

@ -1,5 +1,5 @@
#include <magisk.h> #include <magisk.hpp>
#include <selinux.h> #include <selinux.hpp>
constexpr char magiskrc[] = constexpr char magiskrc[] =
"\n" "\n"

View File

@ -3,12 +3,12 @@
#include <stdio.h> #include <stdio.h>
#include <vector> #include <vector>
#include <utils.h> #include <utils.hpp>
#include <logging.h> #include <logging.hpp>
#include <selinux.h> #include <selinux.hpp>
#include <magisk.h> #include <magisk.hpp>
#include "init.h" #include "init.hpp"
using namespace std; using namespace std;

View File

@ -3,12 +3,12 @@
#include <fcntl.h> #include <fcntl.h>
#include <vector> #include <vector>
#include <magisk.h> #include <magisk.hpp>
#include <magiskpolicy.h> #include <magiskpolicy.hpp>
#include <utils.h> #include <utils.hpp>
#include "init.h" #include "init.hpp"
#include "magiskrc.h" #include "magiskrc.inc"
#ifdef USE_64BIT #ifdef USE_64BIT
#define LIBNAME "lib64" #define LIBNAME "lib64"

View File

@ -9,12 +9,12 @@
#include <mincrypt/sha.h> #include <mincrypt/sha.h>
#include <mincrypt/sha256.h> #include <mincrypt/sha256.h>
#include <utils.h> #include <utils.hpp>
#include <logging.h> #include <logging.hpp>
#include "bootimg.h" #include "bootimg.hpp"
#include "magiskboot.h" #include "magiskboot.hpp"
#include "compress.h" #include "compress.hpp"
using namespace std; using namespace std;

View File

@ -2,7 +2,7 @@
#include <stdint.h> #include <stdint.h>
#include <utility> #include <utility>
#include "format.h" #include "format.hpp"
/**************** /****************
* Other Headers * Other Headers

View File

@ -13,11 +13,11 @@
#include <lz4frame.h> #include <lz4frame.h>
#include <lz4hc.h> #include <lz4hc.h>
#include <logging.h> #include <logging.hpp>
#include <utils.h> #include <utils.hpp>
#include "magiskboot.h" #include "magiskboot.hpp"
#include "compress.h" #include "compress.hpp"
using namespace std; using namespace std;

View File

@ -1,8 +1,8 @@
#pragma once #pragma once
#include <stream.h> #include <stream.hpp>
#include "format.h" #include "format.hpp"
stream_ptr get_encoder(format_t type, stream_ptr &&base); stream_ptr get_encoder(format_t type, stream_ptr &&base);

View File

@ -7,10 +7,10 @@
extern "C" { extern "C" {
#include <libfdt.h> #include <libfdt.h>
} }
#include <utils.h> #include <utils.hpp>
#include "magiskboot.h" #include "magiskboot.hpp"
#include "dtb.h" #include "dtb.hpp"
using namespace std; using namespace std;

View File

@ -1,6 +1,6 @@
#include <string.h> #include <string.h>
#include "format.h" #include "format.hpp"
std::map<std::string_view, format_t> name2fmt; std::map<std::string_view, format_t> name2fmt;
Fmt2Name fmt2name; Fmt2Name fmt2name;

View File

@ -3,9 +3,9 @@
#include <string.h> #include <string.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <utils.h> #include <utils.hpp>
#include "magiskboot.h" #include "magiskboot.hpp"
static void hex2byte(uint8_t *hex, uint8_t *str) { static void hex2byte(uint8_t *hex, uint8_t *str) {
char high, low; char high, low;

View File

@ -5,12 +5,12 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <mincrypt/sha.h> #include <mincrypt/sha.h>
#include <logging.h> #include <logging.hpp>
#include <utils.h> #include <utils.hpp>
#include <flags.h> #include <flags.h>
#include "magiskboot.h" #include "magiskboot.hpp"
#include "compress.h" #include "compress.hpp"
using namespace std; using namespace std;

View File

@ -1,9 +1,9 @@
#include <malloc.h> #include <malloc.h>
#include <string.h> #include <string.h>
#include <utils.h> #include <utils.hpp>
#include "magiskboot.h" #include "magiskboot.hpp"
#define MATCH(p) else if (strncmp(s + skip, p, sizeof(p) - 1) == 0) skip += (sizeof(p) - 1) #define MATCH(p) else if (strncmp(s + skip, p, sizeof(p) - 1) == 0) skip += (sizeof(p) - 1)

View File

@ -2,11 +2,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <utils.h> #include <utils.hpp>
#include <cpio.h> #include <cpio.hpp>
#include "magiskboot.h" #include "magiskboot.hpp"
#include "compress.h" #include "compress.hpp"
using namespace std; using namespace std;

View File

@ -1,11 +1,11 @@
#include <sys/mount.h> #include <sys/mount.h>
#include <magisk.h> #include <magisk.hpp>
#include <utils.h> #include <utils.hpp>
#include <selinux.h> #include <selinux.hpp>
#include <resetprop.h> #include <resetprop.hpp>
#include "magiskhide.h" #include "magiskhide.hpp"
using namespace std; using namespace std;

View File

@ -7,11 +7,11 @@
#include <dirent.h> #include <dirent.h>
#include <string.h> #include <string.h>
#include <magisk.h> #include <magisk.hpp>
#include <utils.h> #include <utils.hpp>
#include <db.h> #include <db.hpp>
#include "magiskhide.h" #include "magiskhide.hpp"
using namespace std; using namespace std;

View File

@ -8,11 +8,11 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <daemon.h> #include <daemon.hpp>
#include <utils.h> #include <utils.hpp>
#include <flags.h> #include <flags.h>
#include "magiskhide.h" #include "magiskhide.hpp"
using namespace std::literals; using namespace std::literals;

View File

@ -10,7 +10,7 @@
#include <map> #include <map>
#include <set> #include <set>
#include <daemon.h> #include <daemon.hpp>
#define SIGTERMTHRD SIGUSR1 #define SIGTERMTHRD SIGUSR1
#define SIGZYGOTE SIGUSR2 #define SIGZYGOTE SIGUSR2

View File

@ -13,10 +13,10 @@
#include <vector> #include <vector>
#include <bitset> #include <bitset>
#include <logging.h> #include <logging.hpp>
#include <utils.h> #include <utils.hpp>
#include "magiskhide.h" #include "magiskhide.hpp"
using namespace std; using namespace std;

View File

@ -1,4 +1,4 @@
#include <magiskpolicy.h> #include <magiskpolicy.hpp>
#include "sepolicy.h" #include "sepolicy.h"

View File

@ -1,10 +1,10 @@
#include <stdio.h> #include <stdio.h>
#include <limits.h> #include <limits.h>
#include <logging.h> #include <logging.hpp>
#include <utils.h> #include <utils.hpp>
#include <flags.h> #include <flags.h>
#include <magiskpolicy.h> #include <magiskpolicy.hpp>
#include "sepolicy.h" #include "sepolicy.h"

View File

@ -5,10 +5,10 @@
#include <cil/cil.h> #include <cil/cil.h>
#include <utils.h> #include <utils.hpp>
#include <logging.h> #include <logging.hpp>
#include <stream.h> #include <stream.hpp>
#include <magiskpolicy.h> #include <magiskpolicy.hpp>
#include "sepolicy.h" #include "sepolicy.h"

View File

@ -1,6 +1,6 @@
#include <logging.h> #include <logging.hpp>
#include <flags.h> #include <flags.h>
#include <magiskpolicy.h> #include <magiskpolicy.hpp>
#include "sepolicy.h" #include "sepolicy.h"

View File

@ -1,7 +1,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <sepol/policydb/expand.h> #include <sepol/policydb/expand.h>
#include <logging.h> #include <logging.hpp>
#include "sepolicy.h" #include "sepolicy.h"

View File

@ -2,9 +2,9 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <magiskpolicy.h> #include <magiskpolicy.hpp>
#include <logging.h> #include <logging.hpp>
#include <utils.h> #include <utils.hpp>
using namespace std; using namespace std;

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
#include <string> #include <string>
#include <logging.h> #include <logging.hpp>
#include "system_properties.h" #include <system_properties.h>
struct prop_t { struct prop_t {
char *name; char *name;

View File

@ -9,9 +9,9 @@
#include <pb.h> #include <pb.h>
#include <pb_decode.h> #include <pb_decode.h>
#include <pb_encode.h> #include <pb_encode.h>
#include <utils.h> #include <utils.hpp>
#include "private/resetprop.h" #include "_resetprop.hpp"
using namespace std; using namespace std;

View File

@ -1,105 +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 _BIONIC_MACROS_H_
#define _BIONIC_MACROS_H_
#include <stdint.h>
// Frameworks OpenGL code currently leaks this header and allows
// collisions with other declarations, e.g., from libnativehelper.
// TODO: Remove once cleaned up. b/18334516
#if !defined(DISALLOW_COPY_AND_ASSIGN)
// DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions.
// It goes in the private: declarations in a class.
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&) = delete; \
void operator=(const TypeName&) = delete
#endif // !defined(DISALLOW_COPY_AND_ASSIGN)
// A macro to disallow all the implicit constructors, namely the
// default constructor, copy constructor and operator= functions.
//
// This should be used in the private: declarations for a class
// that wants to prevent anyone from instantiating it. This is
// especially useful for classes containing only static methods.
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
TypeName() = delete; \
DISALLOW_COPY_AND_ASSIGN(TypeName)
#define BIONIC_ROUND_UP_POWER_OF_2(value) \
((sizeof(value) == 8) \
? (1UL << (64 - __builtin_clzl(static_cast<unsigned long>(value)))) \
: (1UL << (32 - __builtin_clz(static_cast<unsigned int>(value)))))
static constexpr uintptr_t align_down(uintptr_t p, size_t align) {
return p & ~(align - 1);
}
static constexpr uintptr_t align_up(uintptr_t p, size_t align) {
return (p + align - 1) & ~(align - 1);
}
template <typename T>
static inline T* align_down(T* p, size_t align) {
return reinterpret_cast<T*>(align_down(reinterpret_cast<uintptr_t>(p), align));
}
template <typename T>
static inline T* align_up(T* p, size_t align) {
return reinterpret_cast<T*>(align_up(reinterpret_cast<uintptr_t>(p), align));
}
#if defined(__arm__)
// Do not emit anything for arm, clang does not allow emiting an arm unwind
// directive.
// #define BIONIC_STOP_UNWIND asm volatile(".cantunwind")
#define BIONIC_STOP_UNWIND
#elif defined(__aarch64__)
#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined x30")
#elif defined(__i386__)
#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined \%eip")
#elif defined(__x86_64__)
#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined \%rip")
#elif defined (__mips__)
#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined $ra")
#endif
// The arraysize(arr) macro returns the # of elements in an array arr.
// The expression is a compile-time constant, and therefore can be
// used in defining new arrays, for example. If you use arraysize on
// a pointer by mistake, you will get a compile-time error.
//
// One caveat is that arraysize() doesn't accept any array of an
// anonymous type or a type defined inside a function.
//
// This template function declaration is used in defining arraysize.
// Note that the function doesn't need an implementation, as we only
// use its type.
template <typename T, size_t N>
char (&ArraySizeHelper(T (&array)[N]))[N]; // NOLINT(readability/casting)
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
// Used to inform clang's -Wimplicit-fallthrough that a fallthrough is intended. There's no way to
// silence (or enable, apparently) -Wimplicit-fallthrough in C yet.
#ifdef __cplusplus
#define __BIONIC_FALLTHROUGH [[clang::fallthrough]]
#else
#define __BIONIC_FALLTHROUGH
#endif
#endif // _BIONIC_MACROS_H_

View File

@ -1,21 +0,0 @@
#ifndef REDEFS_H
#define REDEFS_H
#define __system_property_set _system_property_set2
#define __system_property_find _system_property_find2
#define __system_property_read_callback _system_property_read_callback2
#define __system_property_foreach __system_property_foreach2
#define __system_property_wait __system_property_wait2
#define __system_property_read __system_property_read2
#define __system_property_get __system_property_get2
#define __system_property_find_nth __system_property_find_nth2
#define __system_property_set_filename __system_property_set_filename2
#define __system_property_area_init __system_property_area_init2
#define __system_property_area_serial __system_property_area_serial2
#define __system_property_add __system_property_add2
#define __system_property_update __system_property_update2
#define __system_property_serial __system_property_serial2
#define __system_properties_init __system_properties_init2
#define __system_property_wait_any __system_property_wait_any2
#endif //REDEFS_H

View File

@ -9,15 +9,15 @@
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#include <logging.h> #include <logging.hpp>
#include <resetprop.h> #include <resetprop.hpp>
#include <utils.h> #include <utils.hpp>
#include <flags.h> #include <flags.h>
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include "private/_system_properties.h" #include <_system_properties.h>
#include "private/system_properties.h"
#include "private/resetprop.h" #include "_resetprop.hpp"
using namespace std; using namespace std;

View File

@ -5,11 +5,11 @@
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <daemon.h> #include <daemon.hpp>
#include <utils.h> #include <utils.hpp>
#include <logging.h> #include <logging.hpp>
#include "su.h" #include "su.hpp"
using namespace std; using namespace std;

View File

@ -17,9 +17,9 @@
#include <errno.h> #include <errno.h>
#include <pthread.h> #include <pthread.h>
#include <logging.h> #include <logging.hpp>
#include "pts.h" #include "pts.hpp"
/** /**
* Helper functions * Helper functions

View File

@ -3,7 +3,7 @@
*/ */
/* /*
* pts.h * pts.hpp
* *
* Manages the pseudo-terminal driver on Linux/Android and provides some * Manages the pseudo-terminal driver on Linux/Android and provides some
* helper functions to handle raw input mode and terminal window resizing * helper functions to handle raw input mode and terminal window resizing

View File

@ -21,12 +21,12 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <daemon.h> #include <daemon.hpp>
#include <utils.h> #include <utils.hpp>
#include <flags.h> #include <flags.h>
#include "su.h" #include "su.hpp"
#include "pts.h" #include "pts.hpp"
int quit_signals[] = { SIGALRM, SIGABRT, SIGHUP, SIGPIPE, SIGQUIT, SIGTERM, SIGINT, 0 }; int quit_signals[] = { SIGALRM, SIGABRT, SIGHUP, SIGPIPE, SIGQUIT, SIGTERM, SIGINT, 0 };

View File

@ -4,8 +4,8 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <memory> #include <memory>
#include <db.h> #include <db.hpp>
#include <utils.h> #include <utils.hpp>
#define DEFAULT_SHELL "/system/bin/sh" #define DEFAULT_SHELL "/system/bin/sh"

View File

@ -12,13 +12,13 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <logging.h> #include <logging.hpp>
#include <daemon.h> #include <daemon.hpp>
#include <utils.h> #include <utils.hpp>
#include <selinux.h> #include <selinux.hpp>
#include "su.h" #include "su.hpp"
#include "pts.h" #include "pts.hpp"
using namespace std; using namespace std;

View File

@ -10,6 +10,8 @@ LOCAL_SRC_FILES := \
prop_area.cpp \ prop_area.cpp \
prop_info.cpp \ prop_info.cpp \
system_properties.cpp \ system_properties.cpp \
system_property_api.cpp \
system_property_set.cpp \
property_info_parser.cpp property_info_parser.cpp
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)

View File

@ -1,14 +0,0 @@
#pragma once
#include <stdio.h>
#include <syscall.h>
#ifndef PR_SET_VMA
#define PR_SET_VMA 0x53564d41
#endif
#ifndef PR_SET_VMA_ANON_NAME
#define PR_SET_VMA_ANON_NAME 0
#endif
#define getline __getline
#define fsetxattr(...) syscall(__NR_fsetxattr, __VA_ARGS__)
ssize_t __getline(char **, size_t *, FILE *);

View File

@ -0,0 +1,35 @@
#pragma once
#include <stdio.h>
#include <syscall.h>
// Missing defines
#ifndef PR_SET_VMA
#define PR_SET_VMA 0x53564d41
#endif
#ifndef PR_SET_VMA_ANON_NAME
#define PR_SET_VMA_ANON_NAME 0
#endif
// Missing functions
#define fsetxattr(...) syscall(__NR_fsetxattr, __VA_ARGS__)
#define getline __getline
ssize_t __getline(char **, size_t *, FILE *);
// Rename symbols
#pragma redefine_extname __system_property_set _system_property_set2
#pragma redefine_extname __system_property_find _system_property_find2
#pragma redefine_extname __system_property_read_callback _system_property_read_callback2
#pragma redefine_extname __system_property_foreach __system_property_foreach2
#pragma redefine_extname __system_property_wait __system_property_wait2
#pragma redefine_extname __system_property_read __system_property_read2
#pragma redefine_extname __system_property_get __system_property_get2
#pragma redefine_extname __system_property_find_nth __system_property_find_nth2
#pragma redefine_extname __system_property_set_filename __system_property_set_filename2
#pragma redefine_extname __system_property_area_init __system_property_area_init2
#pragma redefine_extname __system_property_area_serial __system_property_area_serial2
#pragma redefine_extname __system_property_add __system_property_add2
#pragma redefine_extname __system_property_update __system_property_update2
#pragma redefine_extname __system_property_serial __system_property_serial2
#pragma redefine_extname __system_properties_init __system_properties_init2
#pragma redefine_extname __system_property_wait_any __system_property_wait_any2

View File

@ -33,7 +33,8 @@
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include "redefs.h"
#include "private/hacks.h"
__BEGIN_DECLS __BEGIN_DECLS

View File

@ -30,10 +30,10 @@
#include <stdatomic.h> #include <stdatomic.h>
#include <stdint.h> #include <stdint.h>
#include <sys/system_properties.h> //#include <sys/system_properties.h>
#include "../system_properties.h"
#include "private/bionic_macros.h" #include "private/bionic_macros.h"
#include "hacks.h"
// The C11 standard doesn't allow atomic loads from const fields, // The C11 standard doesn't allow atomic loads from const fields,
// though C++11 does. Fudge it until standards get straightened out. // though C++11 does. Fudge it until standards get straightened out.

View File

@ -30,7 +30,8 @@
#include <stdint.h> #include <stdint.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/system_properties.h> //#include <sys/system_properties.h>
#include "../system_properties.h"
#include "contexts.h" #include "contexts.h"
#include "contexts_pre_split.h" #include "contexts_pre_split.h"

View File

@ -28,7 +28,7 @@
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
//#include <sys/_system_properties.h> //#include <sys/_system_properties.h>
#include "private/_system_properties.h" #include <_system_properties.h>
#include <system_properties/prop_area.h> #include <system_properties/prop_area.h>
#include <system_properties/system_properties.h> #include <system_properties/system_properties.h>

View File

@ -39,7 +39,7 @@
#include <sys/un.h> #include <sys/un.h>
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
//#include <sys/_system_properties.h> //#include <sys/_system_properties.h>
#include "private/_system_properties.h" #include <_system_properties.h>
#include <unistd.h> #include <unistd.h>
#include <async_safe/log.h> #include <async_safe/log.h>
@ -173,7 +173,7 @@ class SocketWriter {
uint32_t uint_buf_[kUintBufSize]; uint32_t uint_buf_[kUintBufSize];
size_t uint_buf_index_; size_t uint_buf_index_;
DISALLOW_IMPLICIT_CONSTRUCTORS(SocketWriter); BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(SocketWriter);
}; };
struct prop_msg { struct prop_msg {

View File

@ -4,9 +4,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <algorithm> #include <algorithm>
#include <utils.h> #include <utils.hpp>
#include <logging.h> #include <logging.hpp>
#include <cpio.h> #include <cpio.hpp>
using namespace std; using namespace std;

View File

@ -7,8 +7,8 @@
#include <string.h> #include <string.h>
#include <libgen.h> #include <libgen.h>
#include <utils.h> #include <utils.hpp>
#include <selinux.h> #include <selinux.hpp>
using namespace std; using namespace std;

View File

@ -6,7 +6,7 @@
#include <functional> #include <functional>
#include <string_view> #include <string_view>
#include "xwrap.h" #include "xwrap.hpp"
#define do_align(p, a) (((p) + (a) - 1) / (a) * (a)) #define do_align(p, a) (((p) + (a) - 1) / (a) * (a))
#define align_off(p, a) (do_align(p, a) - (p)) #define align_off(p, a) (do_align(p, a) - (p))

View File

@ -2,7 +2,7 @@
#include <pthread.h> #include <pthread.h>
#include <deque> #include <deque>
#include <misc.h> #include <../misc.hpp>
template<typename T> template<typename T>
class blocking_queue { class blocking_queue {

View File

@ -6,7 +6,7 @@
#include <map> #include <map>
#include <string_view> #include <string_view>
#include <stream.h> #include <stream.hpp>
struct cpio_newc_header; struct cpio_newc_header;

View File

@ -3,7 +3,7 @@
#include <stdio.h> #include <stdio.h>
#include <memory> #include <memory>
#include "../files.h" #include "../files.hpp"
class stream { class stream {
public: public:

View File

@ -1,6 +0,0 @@
#pragma once
#include "../missing.h"
#include "../xwrap.h"
#include "../files.h"
#include "../misc.h"

View File

@ -0,0 +1,6 @@
#pragma once
#include "../missing.hpp"
#include "../xwrap.hpp"
#include "../files.hpp"
#include "../misc.hpp"

View File

@ -2,7 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <android/log.h> #include <android/log.h>
#include <logging.h> #include <logging.hpp>
#include <flags.h> #include <flags.h>
int nop_log(const char *fmt, va_list ap) { int nop_log(const char *fmt, va_list ap) {

View File

@ -14,8 +14,8 @@
#include <syscall.h> #include <syscall.h>
#include <random> #include <random>
#include <logging.h> #include <logging.hpp>
#include <utils.h> #include <utils.hpp>
int fork_dont_care() { int fork_dont_care() {
int pid = xfork(); int pid = xfork();

View File

@ -8,7 +8,7 @@
#include <errno.h> #include <errno.h>
#include <mntent.h> #include <mntent.h>
#include "missing.h" #include "missing.hpp"
/* Original source: https://opensource.apple.com/source/cvs/cvs-19/cvs/lib/getline.c /* Original source: https://opensource.apple.com/source/cvs/cvs-19/cvs/lib/getline.c
* License: GPL 2 or later * License: GPL 2 or later

View File

@ -6,9 +6,9 @@
#include <syscall.h> #include <syscall.h>
#include <string_view> #include <string_view>
#include <magisk.h> #include <magisk.hpp>
#include <utils.h> #include <utils.hpp>
#include <selinux.h> #include <selinux.hpp>
using namespace std::literals; using namespace std::literals;

View File

@ -1,6 +1,6 @@
#include <utils.h> #include <utils.hpp>
#include <logging.h> #include <logging.hpp>
#include <stream.h> #include <stream.hpp>
static int strm_read(void *v, char *buf, int len) { static int strm_read(void *v, char *buf, int len) {
auto strm = reinterpret_cast<stream *>(v); auto strm = reinterpret_cast<stream *>(v);

View File

@ -10,8 +10,8 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/sendfile.h> #include <sys/sendfile.h>
#include <logging.h> #include <logging.hpp>
#include <utils.h> #include <utils.hpp>
FILE *xfopen(const char *pathname, const char *mode) { FILE *xfopen(const char *pathname, const char *mode) {
FILE *fp = fopen(pathname, mode); FILE *fp = fopen(pathname, mode);