File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,22 @@ mod android {
45
45
}
46
46
}
47
47
48
+ pub fn untag ( & mut self , fd : c_int ) {
49
+ weak ! ( fn android_fdsan_exchange_owner_tag( c_int, u64 , u64 ) -> u64 ) ;
50
+ match android_fdsan_exchange_owner_tag. get ( ) {
51
+ Some ( f) => {
52
+ let prev = unsafe { f ( fd, self . 0 , 0 ) } ;
53
+ if prev != self . 0 {
54
+ panic ! ( "attempted to release ownership of not-owned file descriptor" ) ;
55
+ }
56
+ }
57
+
58
+ None => { }
59
+ }
60
+
61
+ self . 0 = 0 ;
62
+ }
63
+
48
64
pub fn close ( & mut self , fd : c_int ) {
49
65
weak ! ( fn android_fdsan_close_with_tag( c_int, u64 ) -> c_int) ;
50
66
match android_fdsan_close_with_tag. get ( ) {
@@ -99,6 +115,15 @@ impl FileDesc {
99
115
}
100
116
101
117
/// Extracts the actual file descriptor without closing it.
118
+ #[ cfg( target_os = "android" ) ]
119
+ pub fn into_raw ( mut self ) -> c_int {
120
+ let fd = self . fd ;
121
+ self . tag . untag ( fd) ;
122
+ mem:: forget ( self ) ;
123
+ fd
124
+ }
125
+
126
+ #[ cfg( not( target_os = "android" ) ) ]
102
127
pub fn into_raw ( self ) -> c_int {
103
128
let fd = self . fd ;
104
129
mem:: forget ( self ) ;
You can’t perform that action at this time.
0 commit comments