summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChaosmaster <chaosmaster@chaosv.de>2020-02-06 03:00:24 +0100
committernebrassy <nebras30@gmail.com>2020-04-26 11:52:56 +0200
commit79f442c6af70ac9fd6dd9435f2be6719cce7eac1 (patch)
treeeb4bbc2f08ab1c324629899682bfd016f5e4c6bf
parent95e98fce7d424d284fd140d5fb76959d90e6b0e4 (diff)
libresetprop: Fix compilation in 7.1
Change-Id: I3ef6c4f41f1c460d5e4da71c88de085e5aea4c2a
-rw-r--r--include/db.h18
-rw-r--r--resetprop/resetprop.cpp2
-rw-r--r--systemproperties/include/hacks.h11
-rw-r--r--utils/file.cpp5
-rw-r--r--utils/files.h12
-rw-r--r--utils/include/cpio.h8
-rw-r--r--utils/misc.cpp2
-rw-r--r--utils/misc.h10
-rw-r--r--utils/selinux.cpp2
9 files changed, 54 insertions, 16 deletions
diff --git a/include/db.h b/include/db.h
index d994b9e..e2d5ddd 100644
--- a/include/db.h
+++ b/include/db.h
@@ -3,17 +3,23 @@
#include <sys/stat.h>
#include <map>
#include <string>
+#ifndef __ANDROID_API_O__
+#include <experimental/string_view>
+#define STRING_VIEW std::experimental::string_view
+#else
#include <string_view>
+#define STRING_VIEW std::string_view
+#endif
#include <functional>
template <class T, size_t num>
class db_data_base {
public:
- T& operator [](std::string_view key) {
+ T& operator [](STRING_VIEW key) {
return data[getKeyIdx(key)];
}
- const T& operator [](std::string_view key) const {
+ const T& operator [](STRING_VIEW key) const {
return data[getKeyIdx(key)];
}
@@ -27,7 +33,7 @@ public:
protected:
T data[num + 1];
- virtual int getKeyIdx(std::string_view key) const = 0;
+ virtual int getKeyIdx(STRING_VIEW key) const = 0;
};
/***************
@@ -79,7 +85,7 @@ public:
db_settings();
protected:
- int getKeyIdx(std::string_view key) const override;
+ int getKeyIdx(STRING_VIEW key) const override;
};
/**************
@@ -100,7 +106,7 @@ enum {
class db_strings : public db_data_base<std::string, DB_STRING_NUM> {
protected:
- int getKeyIdx(std::string_view key) const override;
+ int getKeyIdx(STRING_VIEW key) const override;
};
/*************
@@ -141,7 +147,7 @@ struct su_access {
* Public Functions *
********************/
-typedef std::map<std::string_view, std::string_view> db_row;
+typedef std::map<STRING_VIEW, STRING_VIEW> db_row;
typedef std::function<bool(db_row&)> db_row_cb;
int get_db_settings(db_settings &cfg, int key = -1);
diff --git a/resetprop/resetprop.cpp b/resetprop/resetprop.cpp
index 44d424f..8779635 100644
--- a/resetprop/resetprop.cpp
+++ b/resetprop/resetprop.cpp
@@ -80,7 +80,7 @@ illegal:
static void read_props(const prop_info *pi, void *read_cb) {
__system_property_read_callback(
- pi, [](auto cb, auto name, auto value, auto) {
+ pi, [](void * cb, const char * name, const char * value, uint32_t) {
((read_cb_t *) cb)->exec(name, value);
}, read_cb);
}
diff --git a/systemproperties/include/hacks.h b/systemproperties/include/hacks.h
index 678368e..b5d1b92 100644
--- a/systemproperties/include/hacks.h
+++ b/systemproperties/include/hacks.h
@@ -16,3 +16,14 @@ ssize_t __getline(char **, size_t *, FILE *);
#ifndef __BIONIC_ALIGN
#define __BIONIC_ALIGN(__value, __alignment) (((__value) + (__alignment)-1) & ~((__alignment)-1))
#endif
+
+#ifndef XATTR_SECURITY_PREFIX
+#define XATTR_SECURITY_PREFIX "security."
+#define XATTR_SECURITY_PREFIX_LEN (sizeof(XATTR_SECURITY_PREFIX) - 1)
+#endif
+#ifndef XATTR_SELINUX_SUFFIX
+#define XATTR_SELINUX_SUFFIX "selinux"
+#endif
+#ifndef XATTR_NAME_SELINUX
+#define XATTR_NAME_SELINUX XATTR_SECURITY_PREFIX XATTR_SELINUX_SUFFIX
+#endif
diff --git a/utils/file.cpp b/utils/file.cpp
index efd9eb6..f6039a0 100644
--- a/utils/file.cpp
+++ b/utils/file.cpp
@@ -11,6 +11,9 @@
#include <selinux.h>
using namespace std;
+#ifndef __ANDROID_API_O__
+using namespace std::experimental;
+#endif
ssize_t fd_path(int fd, char *path, size_t size) {
snprintf(path, size, "/proc/self/fd/%d", fd);
@@ -356,7 +359,7 @@ void write_zero(int fd, size_t size) {
}
}
-void file_readline(bool trim, const char *file, const std::function<bool(std::string_view)> &fn) {
+void file_readline(bool trim, const char *file, const std::function<bool(STRING_VIEW)> &fn) {
FILE *fp = xfopen(file, "re");
if (fp == nullptr)
return;
diff --git a/utils/files.h b/utils/files.h
index 7ec32ab..f51e7ec 100644
--- a/utils/files.h
+++ b/utils/files.h
@@ -4,7 +4,13 @@
#include <sys/stat.h>
#include <mntent.h>
#include <functional>
+#ifndef __ANDROID_API_O__
+#include <experimental/string_view>
+#define STRING_VIEW std::experimental::string_view
+#else
#include <string_view>
+#define STRING_VIEW std::string_view
+#endif
#include "xwrap.h"
@@ -35,13 +41,13 @@ void clone_attr(const char *source, const char *target);
void fd_full_read(int fd, void **buf, size_t *size);
void full_read(const char *filename, void **buf, size_t *size);
void write_zero(int fd, size_t size);
-void file_readline(bool trim, const char *file, const std::function<bool(std::string_view)> &fn);
+void file_readline(bool trim, const char *file, const std::function<bool(STRING_VIEW)> &fn);
static inline void file_readline(const char *file,
- const std::function<bool(std::string_view)> &fn) {
+ const std::function<bool(STRING_VIEW)> &fn) {
file_readline(false, file, fn);
}
void parse_prop_file(const char *file,
- const std::function<bool(std::string_view, std::string_view)> &fn);
+ const std::function<bool(STRING_VIEW, STRING_VIEW)> &fn);
void *__mmap(const char *filename, size_t *size, bool rw);
void frm_rf(int dirfd, std::initializer_list<const char *> excl = {});
void clone_dir(int src, int dest, bool overwrite = true);
diff --git a/utils/include/cpio.h b/utils/include/cpio.h
index 51a2514..5142193 100644
--- a/utils/include/cpio.h
+++ b/utils/include/cpio.h
@@ -4,7 +4,13 @@
#include <string>
#include <memory>
#include <map>
+#ifndef __ANDROID_API_O__
+#include <experimental/string_view>
+#define STRING_VIEW std::experimental::string_view
+#else
#include <string_view>
+#define STRING_VIEW std::string_view
+#endif
#include <stream.h>
@@ -35,7 +41,7 @@ struct cpio_entry : public cpio_entry_base {
~cpio_entry() override { free(data); };
};
-typedef std::map<std::string_view, std::unique_ptr<cpio_entry_base>> entry_map;
+typedef std::map<STRING_VIEW, std::unique_ptr<cpio_entry_base>> entry_map;
class cpio {
public:
diff --git a/utils/misc.cpp b/utils/misc.cpp
index 2db95f5..59a354a 100644
--- a/utils/misc.cpp
+++ b/utils/misc.cpp
@@ -154,7 +154,7 @@ void set_nice_name(const char *name) {
prctl(PR_SET_NAME, name);
}
-bool ends_with(const std::string_view &s1, const std::string_view &s2) {
+bool ends_with(const STRING_VIEW &s1, const STRING_VIEW &s2) {
unsigned l1 = s1.length();
unsigned l2 = s2.length();
return l1 < l2 ? false : s1.compare(l1 - l2, l2, s2) == 0;
diff --git a/utils/misc.h b/utils/misc.h
index ac0d51f..be0ef95 100644
--- a/utils/misc.h
+++ b/utils/misc.h
@@ -3,7 +3,13 @@
#include <pthread.h>
#include <string>
#include <functional>
+#ifndef __ANDROID_API_O__
+#include <experimental/string_view>
+#define STRING_VIEW std::experimental::string_view
+#else
#include <string_view>
+#define STRING_VIEW std::string_view
+#endif
#define UID_ROOT 0
#define UID_SHELL 2000
@@ -62,7 +68,7 @@ reversed_container<T> reversed(T &base) {
int parse_int(const char *s);
static inline int parse_int(std::string s) { return parse_int(s.data()); }
-static inline int parse_int(std::string_view s) { return parse_int(s.data()); }
+static inline int parse_int(STRING_VIEW s) { return parse_int(s.data()); }
int new_daemon_thread(void *(*start_routine) (void *), void *arg = nullptr,
const pthread_attr_t *attr = nullptr);
@@ -96,7 +102,7 @@ int exec_command_sync(Args &&...args) {
return exec_command_sync(exec, args...);
}
-bool ends_with(const std::string_view &s1, const std::string_view &s2);
+bool ends_with(const STRING_VIEW &s1, const STRING_VIEW &s2);
int fork_dont_care();
int fork_no_zombie();
int strend(const char *s1, const char *s2);
diff --git a/utils/selinux.cpp b/utils/selinux.cpp
index 616f1a9..0973d4c 100644
--- a/utils/selinux.cpp
+++ b/utils/selinux.cpp
@@ -4,7 +4,7 @@
#include <fcntl.h>
#include <string.h>
#include <syscall.h>
-#include <string_view>
+#include <experimental/string_view>
#include <magisk.h>
#include <utils.h>