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
7f18616c
Commit
7f18616c
authored
Oct 09, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prune unused nodes from trie
parent
2fef98a5
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
54 additions
and
15 deletions
+54
-15
_system_properties.h
...ni/external/systemproperties/include/_system_properties.h
+1
-1
prop_area.h
...al/systemproperties/include/system_properties/prop_area.h
+4
-1
system_properties.h
...mproperties/include/system_properties/system_properties.h
+1
-1
prop_area.cpp
native/jni/external/systemproperties/prop_area.cpp
+42
-6
system_properties.cpp
native/jni/external/systemproperties/system_properties.cpp
+2
-2
system_property_api.cpp
native/jni/external/systemproperties/system_property_api.cpp
+2
-2
resetprop.cpp
native/jni/resetprop/resetprop.cpp
+2
-2
No files found.
native/jni/external/systemproperties/include/_system_properties.h
View file @
7f18616c
...
@@ -109,7 +109,7 @@ int __system_property_add(const char* __name, unsigned int __name_length, const
...
@@ -109,7 +109,7 @@ int __system_property_add(const char* __name, unsigned int __name_length, const
**
**
** Returns 0 on success, -1 if the property area is full.
** Returns 0 on success, -1 if the property area is full.
*/
*/
int
__system_property_delete
(
const
char
*
__name
);
int
__system_property_delete
(
const
char
*
__name
,
bool
__trim_node
);
/* Update the value of a system property returned by
/* Update the value of a system property returned by
** __system_property_find. Can only be done by a single process
** __system_property_find. Can only be done by a single process
...
...
native/jni/external/systemproperties/include/system_properties/prop_area.h
View file @
7f18616c
...
@@ -110,7 +110,7 @@ class prop_area {
...
@@ -110,7 +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
);
bool
rm
(
const
char
*
name
);
bool
rm
(
const
char
*
name
,
bool
trim_node
);
bool
foreach
(
void
(
*
propfn
)(
const
prop_info
*
pi
,
void
*
cookie
),
void
*
cookie
);
bool
foreach
(
void
(
*
propfn
)(
const
prop_info
*
pi
,
void
*
cookie
),
void
*
cookie
);
...
@@ -140,6 +140,9 @@ class prop_area {
...
@@ -140,6 +140,9 @@ class prop_area {
/* resetprop new: traverse through the trie and find the node */
/* resetprop new: traverse 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
);
/* resetprop new: trim unneeded nodes from trie */
bool
prune_node
(
prop_bt
*
const
node
);
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
);
const
prop_info
*
find_property
(
prop_bt
*
const
trie
,
const
char
*
name
,
uint32_t
namelen
,
const
prop_info
*
find_property
(
prop_bt
*
const
trie
,
const
char
*
name
,
uint32_t
namelen
,
...
...
native/jni/external/systemproperties/include/system_properties/system_properties.h
View file @
7f18616c
...
@@ -67,7 +67,7 @@ class SystemProperties {
...
@@ -67,7 +67,7 @@ class SystemProperties {
int
Get
(
const
char
*
name
,
char
*
value
);
int
Get
(
const
char
*
name
,
char
*
value
);
int
Update
(
prop_info
*
pi
,
const
char
*
value
,
unsigned
int
len
);
int
Update
(
prop_info
*
pi
,
const
char
*
value
,
unsigned
int
len
);
int
Add
(
const
char
*
name
,
unsigned
int
namelen
,
const
char
*
value
,
unsigned
int
valuelen
);
int
Add
(
const
char
*
name
,
unsigned
int
namelen
,
const
char
*
value
,
unsigned
int
valuelen
);
int
Delete
(
const
char
*
name
);
int
Delete
(
const
char
*
name
,
bool
trim_node
);
uint32_t
Serial
(
const
prop_info
*
pi
);
uint32_t
Serial
(
const
prop_info
*
pi
);
uint32_t
WaitAny
(
uint32_t
old_serial
);
uint32_t
WaitAny
(
uint32_t
old_serial
);
bool
Wait
(
const
prop_info
*
pi
,
uint32_t
old_serial
,
uint32_t
*
new_serial_ptr
,
bool
Wait
(
const
prop_info
*
pi
,
uint32_t
old_serial
,
uint32_t
*
new_serial_ptr
,
...
...
native/jni/external/systemproperties/prop_area.cpp
View file @
7f18616c
...
@@ -380,7 +380,40 @@ bool prop_area::add(const char* name, unsigned int namelen, const char* value,
...
@@ -380,7 +380,40 @@ 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
::
rm
(
const
char
*
name
)
{
bool
prop_area
::
prune_node
(
prop_bt
*
const
node
)
{
bool
is_leaf
=
true
;
if
(
atomic_load_explicit
(
&
node
->
children
,
memory_order_relaxed
)
!=
0
)
{
if
(
prune_node
(
to_prop_bt
(
&
node
->
children
)))
{
atomic_store_explicit
(
&
node
->
children
,
0
,
memory_order_release
);
}
else
{
is_leaf
=
false
;
}
}
if
(
atomic_load_explicit
(
&
node
->
left
,
memory_order_relaxed
)
!=
0
)
{
if
(
prune_node
(
to_prop_bt
(
&
node
->
left
)))
{
atomic_store_explicit
(
&
node
->
left
,
0
,
memory_order_release
);
}
else
{
is_leaf
=
false
;
}
}
if
(
atomic_load_explicit
(
&
node
->
right
,
memory_order_relaxed
)
!=
0
)
{
if
(
prune_node
(
to_prop_bt
(
&
node
->
right
)))
{
atomic_store_explicit
(
&
node
->
right
,
0
,
memory_order_release
);
}
else
{
is_leaf
=
false
;
}
}
if
(
is_leaf
&&
atomic_load_explicit
(
&
node
->
prop
,
memory_order_relaxed
)
==
0
)
{
// Wipe out this node
memset
(
node
->
name
,
0
,
node
->
namelen
);
memset
(
node
,
0
,
sizeof
(
*
node
));
return
true
;
}
return
false
;
}
bool
prop_area
::
rm
(
const
char
*
name
,
bool
trim_node
)
{
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
;
...
@@ -392,19 +425,22 @@ bool prop_area::rm(const char *name) {
...
@@ -392,19 +425,22 @@ bool prop_area::rm(const char *name) {
}
}
// De-reference the existing property ASAP
// De-reference the existing property ASAP
uint_least32_t
new_offset
=
0
;
atomic_store_explicit
(
&
node
->
prop
,
0
,
memory_order_release
);
atomic_store_explicit
(
&
node
->
prop
,
new_offset
,
memory_order_release
);
if
(
info
)
{
if
(
info
)
{
//
Directly w
ipe out the old info
//
W
ipe out the old info
if
(
info
->
is_long
())
{
if
(
info
->
is_long
())
{
char
*
value
=
const_cast
<
char
*>
(
info
->
long_value
());
char
*
value
=
const_cast
<
char
*>
(
info
->
long_value
());
auto
len
=
strlen
(
value
);
memset
(
value
,
0
,
strlen
(
value
));
memset
(
value
,
0
,
len
);
}
}
memset
(
info
->
name
,
0
,
strlen
(
info
->
name
));
memset
(
info
,
0
,
sizeof
(
*
info
));
memset
(
info
,
0
,
sizeof
(
*
info
));
}
}
if
(
trim_node
)
{
prune_node
(
root_node
());
}
return
true
;
return
true
;
}
}
...
...
native/jni/external/systemproperties/system_properties.cpp
View file @
7f18616c
...
@@ -295,7 +295,7 @@ int SystemProperties::Add(const char* name, unsigned int namelen, const char* va
...
@@ -295,7 +295,7 @@ int SystemProperties::Add(const char* name, unsigned int namelen, const char* va
return
0
;
return
0
;
}
}
int
SystemProperties
::
Delete
(
const
char
*
name
)
{
int
SystemProperties
::
Delete
(
const
char
*
name
,
bool
trim_node
)
{
if
(
!
initialized_
)
{
if
(
!
initialized_
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -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
->
rm
(
name
);
bool
ret
=
pa
->
rm
(
name
,
trim_node
);
if
(
!
ret
)
{
if
(
!
ret
)
{
return
-
1
;
return
-
1
;
}
}
...
...
native/jni/external/systemproperties/system_property_api.cpp
View file @
7f18616c
...
@@ -100,8 +100,8 @@ int __system_property_add(const char* name, unsigned int namelen, const char* va
...
@@ -100,8 +100,8 @@ int __system_property_add(const char* name, unsigned int namelen, const char* va
}
}
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
int
__system_property_delete
(
const
char
*
nam
e
)
{
int
__system_property_delete
(
const
char
*
name
,
bool
trim_nod
e
)
{
return
system_properties
.
Delete
(
name
);
return
system_properties
.
Delete
(
name
,
trim_node
);
}
}
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
...
...
native/jni/resetprop/resetprop.cpp
View file @
7f18616c
...
@@ -176,7 +176,7 @@ struct resetprop : public sysprop {
...
@@ -176,7 +176,7 @@ struct resetprop : public sysprop {
// Always delete existing read-only properties, because they could be
// Always delete existing read-only properties, because they could be
// long properties and cannot directly go through __system_property_update
// long properties and cannot directly go through __system_property_update
if
(
pi
!=
nullptr
&&
str_starts
(
name
,
"ro."
))
{
if
(
pi
!=
nullptr
&&
str_starts
(
name
,
"ro."
))
{
delprop
(
name
,
false
);
__system_property_delete
(
name
,
false
/* Do NOT trim node */
);
pi
=
nullptr
;
pi
=
nullptr
;
}
}
...
@@ -228,7 +228,7 @@ struct resetprop : public sysprop {
...
@@ -228,7 +228,7 @@ struct resetprop : public sysprop {
return
1
;
return
1
;
LOGD
(
"resetprop: delete prop [%s]
\n
"
,
name
);
LOGD
(
"resetprop: delete prop [%s]
\n
"
,
name
);
int
ret
=
__system_property_delete
(
name
);
int
ret
=
__system_property_delete
(
name
,
true
);
if
(
persist
&&
str_starts
(
name
,
"persist."
))
{
if
(
persist
&&
str_starts
(
name
,
"persist."
))
{
if
(
persist_deleteprop
(
name
))
if
(
persist_deleteprop
(
name
))
ret
=
0
;
ret
=
0
;
...
...
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