Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
2bef967a
Commit
2bef967a
authored
Mar 29, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make systemproperties more match AOSP
parent
7e419441
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
12 deletions
+15
-12
hacks.h
native/jni/external/systemproperties/include/private/hacks.h
+0
-1
prop_area.h
...al/systemproperties/include/system_properties/prop_area.h
+3
-4
prop_area.cpp
native/jni/external/systemproperties/prop_area.cpp
+8
-6
system_properties.cpp
native/jni/external/systemproperties/system_properties.cpp
+1
-1
resetprop.cpp
native/jni/resetprop/resetprop.cpp
+3
-0
No files found.
native/jni/external/systemproperties/include/private/hacks.h
View file @
2bef967a
...
@@ -12,7 +12,6 @@
...
@@ -12,7 +12,6 @@
#endif
#endif
// Missing functions
// Missing functions
#define fsetxattr(...) syscall(__NR_fsetxattr, __VA_ARGS__)
#define getline compat_getline
#define getline compat_getline
ssize_t
compat_getline
(
char
**
,
size_t
*
,
FILE
*
);
ssize_t
compat_getline
(
char
**
,
size_t
*
,
FILE
*
);
...
...
native/jni/external/systemproperties/include/system_properties/prop_area.h
View file @
2bef967a
...
@@ -110,8 +110,7 @@ class prop_area {
...
@@ -110,8 +110,7 @@ class prop_area {
const
prop_info
*
find
(
const
char
*
name
);
const
prop_info
*
find
(
const
char
*
name
);
bool
add
(
const
char
*
name
,
unsigned
int
namelen
,
const
char
*
value
,
unsigned
int
valuelen
);
bool
add
(
const
char
*
name
,
unsigned
int
namelen
,
const
char
*
value
,
unsigned
int
valuelen
);
/* resetprop */
bool
rm
(
const
char
*
name
);
bool
del
(
const
char
*
name
);
bool
foreach
(
void
(
*
propfn
)(
const
prop_info
*
pi
,
void
*
cookie
),
void
*
cookie
);
bool
foreach
(
void
(
*
propfn
)(
const
prop_info
*
pi
,
void
*
cookie
),
void
*
cookie
);
...
@@ -126,7 +125,7 @@ class prop_area {
...
@@ -126,7 +125,7 @@ class prop_area {
}
}
private
:
private
:
static
prop_area
*
map_fd_r
w
(
const
int
fd
);
static
prop_area
*
map_fd_r
o
(
const
int
fd
);
void
*
allocate_obj
(
const
size_t
size
,
uint_least32_t
*
const
off
);
void
*
allocate_obj
(
const
size_t
size
,
uint_least32_t
*
const
off
);
prop_bt
*
new_prop_bt
(
const
char
*
name
,
uint32_t
namelen
,
uint_least32_t
*
const
off
);
prop_bt
*
new_prop_bt
(
const
char
*
name
,
uint32_t
namelen
,
uint_least32_t
*
const
off
);
...
@@ -138,7 +137,7 @@ class prop_area {
...
@@ -138,7 +137,7 @@ class prop_area {
prop_bt
*
root_node
();
prop_bt
*
root_node
();
/* resetprop
: T
raverse through the trie and find the node */
/* resetprop
new: t
raverse through the trie and find the node */
prop_bt
*
find_prop_bt
(
prop_bt
*
const
bt
,
const
char
*
name
,
bool
alloc_if_needed
);
prop_bt
*
find_prop_bt
(
prop_bt
*
const
bt
,
const
char
*
name
,
bool
alloc_if_needed
);
prop_bt
*
find_prop_bt
(
prop_bt
*
const
bt
,
const
char
*
name
,
uint32_t
namelen
,
bool
alloc_if_needed
);
prop_bt
*
find_prop_bt
(
prop_bt
*
const
bt
,
const
char
*
name
,
uint32_t
namelen
,
bool
alloc_if_needed
);
...
...
native/jni/external/systemproperties/prop_area.cpp
View file @
2bef967a
...
@@ -26,6 +26,8 @@
...
@@ -26,6 +26,8 @@
* SUCH DAMAGE.
* SUCH DAMAGE.
*/
*/
#include "system_properties/prop_area.h"
#include <errno.h>
#include <errno.h>
#include <fcntl.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdlib.h>
...
@@ -39,8 +41,6 @@
...
@@ -39,8 +41,6 @@
#include <async_safe/log.h>
#include <async_safe/log.h>
#include "system_properties/prop_area.h"
constexpr
size_t
PA_SIZE
=
128
*
1024
;
constexpr
size_t
PA_SIZE
=
128
*
1024
;
constexpr
uint32_t
PROP_AREA_MAGIC
=
0x504f5250
;
constexpr
uint32_t
PROP_AREA_MAGIC
=
0x504f5250
;
constexpr
uint32_t
PROP_AREA_VERSION
=
0xfc6ed0ab
;
constexpr
uint32_t
PROP_AREA_VERSION
=
0xfc6ed0ab
;
...
@@ -104,8 +104,7 @@ prop_area* prop_area::map_prop_area_rw(const char* filename, const char* context
...
@@ -104,8 +104,7 @@ prop_area* prop_area::map_prop_area_rw(const char* filename, const char* context
return
pa
;
return
pa
;
}
}
/* resetprop: map_fd_ro -> map_fd_rw */
prop_area
*
prop_area
::
map_fd_ro
(
const
int
fd
)
{
prop_area
*
prop_area
::
map_fd_rw
(
const
int
fd
)
{
struct
stat
fd_stat
;
struct
stat
fd_stat
;
if
(
fstat
(
fd
,
&
fd_stat
)
<
0
)
{
if
(
fstat
(
fd
,
&
fd_stat
)
<
0
)
{
return
nullptr
;
return
nullptr
;
...
@@ -140,7 +139,7 @@ prop_area* prop_area::map_prop_area(const char* filename) {
...
@@ -140,7 +139,7 @@ prop_area* prop_area::map_prop_area(const char* filename) {
int
fd
=
open
(
filename
,
O_CLOEXEC
|
O_NOFOLLOW
|
O_RDWR
);
int
fd
=
open
(
filename
,
O_CLOEXEC
|
O_NOFOLLOW
|
O_RDWR
);
if
(
fd
==
-
1
)
return
nullptr
;
if
(
fd
==
-
1
)
return
nullptr
;
prop_area
*
map_result
=
map_fd_r
w
(
fd
);
prop_area
*
map_result
=
map_fd_r
o
(
fd
);
close
(
fd
);
close
(
fd
);
return
map_result
;
return
map_result
;
...
@@ -275,6 +274,8 @@ prop_bt* prop_area::find_prop_bt(prop_bt* const bt, const char* name, uint32_t n
...
@@ -275,6 +274,8 @@ prop_bt* prop_area::find_prop_bt(prop_bt* const bt, const char* name, uint32_t n
}
}
}
}
/* resetprop new: traverse through the trie and find the node.
* This was originally part of prop_area::find_property. */
prop_bt
*
prop_area
::
find_prop_bt
(
prop_bt
*
const
trie
,
const
char
*
name
,
bool
alloc_if_needed
)
{
prop_bt
*
prop_area
::
find_prop_bt
(
prop_bt
*
const
trie
,
const
char
*
name
,
bool
alloc_if_needed
)
{
if
(
!
trie
)
return
nullptr
;
if
(
!
trie
)
return
nullptr
;
...
@@ -317,6 +318,7 @@ prop_bt *prop_area::find_prop_bt(prop_bt *const trie, const char *name, bool all
...
@@ -317,6 +318,7 @@ prop_bt *prop_area::find_prop_bt(prop_bt *const trie, const char *name, bool all
return
current
;
return
current
;
}
}
/* resetprop: move trie traversal logic out of the function */
const
prop_info
*
prop_area
::
find_property
(
prop_bt
*
const
trie
,
const
char
*
name
,
uint32_t
namelen
,
const
prop_info
*
prop_area
::
find_property
(
prop_bt
*
const
trie
,
const
char
*
name
,
uint32_t
namelen
,
const
char
*
value
,
uint32_t
valuelen
,
const
char
*
value
,
uint32_t
valuelen
,
bool
alloc_if_needed
)
{
bool
alloc_if_needed
)
{
...
@@ -378,7 +380,7 @@ bool prop_area::add(const char* name, unsigned int namelen, const char* value,
...
@@ -378,7 +380,7 @@ bool prop_area::add(const char* name, unsigned int namelen, const char* value,
return
find_property
(
root_node
(),
name
,
namelen
,
value
,
valuelen
,
true
);
return
find_property
(
root_node
(),
name
,
namelen
,
value
,
valuelen
,
true
);
}
}
bool
prop_area
::
del
(
const
char
*
name
)
{
bool
prop_area
::
rm
(
const
char
*
name
)
{
prop_bt
*
node
=
find_prop_bt
(
root_node
(),
name
,
false
);
prop_bt
*
node
=
find_prop_bt
(
root_node
(),
name
,
false
);
if
(
!
node
)
if
(
!
node
)
return
false
;
return
false
;
...
...
native/jni/external/systemproperties/system_properties.cpp
View file @
2bef967a
...
@@ -311,7 +311,7 @@ int SystemProperties::Delete(const char *name) {
...
@@ -311,7 +311,7 @@ int SystemProperties::Delete(const char *name) {
return
-
1
;
return
-
1
;
}
}
bool
ret
=
pa
->
del
(
name
);
bool
ret
=
pa
->
rm
(
name
);
if
(
!
ret
)
{
if
(
!
ret
)
{
return
-
1
;
return
-
1
;
}
}
...
...
native/jni/resetprop/resetprop.cpp
View file @
2bef967a
...
@@ -21,6 +21,9 @@ static bool verbose = false;
...
@@ -21,6 +21,9 @@ static bool verbose = false;
#define system_property_read_callback __system_property_read_callback
#define system_property_read_callback __system_property_read_callback
#define system_property_foreach __system_property_foreach
#define system_property_foreach __system_property_foreach
#define system_property_read(...)
#define system_property_read(...)
extern
"C"
int
fsetxattr
(
int
fd
,
const
char
*
name
,
const
void
*
value
,
size_t
size
,
int
flags
)
{
return
syscall
(
__NR_fsetxattr
,
fd
,
name
,
value
,
size
,
flags
);
}
#else
#else
static
int
(
*
system_property_set
)(
const
char
*
,
const
char
*
);
static
int
(
*
system_property_set
)(
const
char
*
,
const
char
*
);
static
int
(
*
system_property_read
)(
const
prop_info
*
,
char
*
,
char
*
);
static
int
(
*
system_property_read
)(
const
prop_info
*
,
char
*
,
char
*
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment