Reapply "kernel: expose umount list to ioctl interface #2950"

This reverts commit 088996da9b.
This commit is contained in:
ShirkNeko
2025-11-20 20:07:59 +08:00
parent cc78812f50
commit 8250c0ecc2
48 changed files with 257 additions and 271 deletions

View File

@@ -38,7 +38,6 @@ private val SPACING_LARGE = 16.dp
data class UmountPathEntry(
val path: String,
val checkMnt: Boolean,
val flags: Int,
val isDefault: Boolean
)
@@ -244,11 +243,11 @@ fun UmountManagerScreen(navigator: DestinationsNavigator) {
if (showAddDialog) {
AddUmountPathDialog(
onDismiss = { showAddDialog = false },
onConfirm = { path, checkMnt, flags ->
onConfirm = { path, flags ->
showAddDialog = false
scope.launch(Dispatchers.IO) {
val success = addUmountPath(path, checkMnt, flags)
val success = addUmountPath(path, flags)
withContext(Dispatchers.Main) {
if (success) {
saveUmountConfig()
@@ -309,10 +308,6 @@ fun UmountPathCard(
Spacer(modifier = Modifier.height(SPACING_SMALL))
Text(
text = buildString {
append(context.getString(R.string.check_mount_type))
append(": ")
append(if (entry.checkMnt) context.getString(R.string.yes) else context.getString(R.string.no))
append(" | ")
append(context.getString(R.string.flags))
append(": ")
append(entry.flags.toUmountFlagName(context))
@@ -353,10 +348,9 @@ fun UmountPathCard(
@Composable
fun AddUmountPathDialog(
onDismiss: () -> Unit,
onConfirm: (String, Boolean, Int) -> Unit
onConfirm: (String, Int) -> Unit
) {
var path by rememberSaveable { mutableStateOf("") }
var checkMnt by rememberSaveable { mutableStateOf(false) }
var flags by rememberSaveable { mutableStateOf("-1") }
AlertDialog(
@@ -374,20 +368,6 @@ fun AddUmountPathDialog(
Spacer(modifier = Modifier.height(SPACING_MEDIUM))
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {
Checkbox(
checked = checkMnt,
onCheckedChange = { checkMnt = it }
)
Spacer(modifier = Modifier.width(SPACING_SMALL))
Text(stringResource(R.string.check_mount_type_overlay))
}
Spacer(modifier = Modifier.height(SPACING_MEDIUM))
OutlinedTextField(
value = flags,
onValueChange = { flags = it },
@@ -403,7 +383,7 @@ fun AddUmountPathDialog(
TextButton(
onClick = {
val flagsInt = flags.toIntOrNull() ?: -1
onConfirm(path, checkMnt, flagsInt)
onConfirm(path, flagsInt)
},
enabled = path.isNotBlank()
) {
@@ -424,12 +404,11 @@ private fun parseUmountPaths(output: String): List<UmountPathEntry> {
return lines.drop(2).mapNotNull { line ->
val parts = line.trim().split(Regex("\\s+"))
if (parts.size >= 4) {
if (parts.size >= 3) {
UmountPathEntry(
path = parts[0],
checkMnt = parts[1].equals("true", ignoreCase = true),
flags = parts[2].toIntOrNull() ?: -1,
isDefault = parts[3].equals("Yes", ignoreCase = true)
flags = parts[1].toIntOrNull() ?: -1,
isDefault = parts[2].equals("Yes", ignoreCase = true)
)
} else null
}

View File

@@ -13,7 +13,6 @@ import android.util.Log
import com.topjohnwu.superuser.CallbackList
import com.topjohnwu.superuser.Shell
import com.topjohnwu.superuser.ShellUtils
import com.topjohnwu.superuser.io.SuFile
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlinx.parcelize.Parcelize
@@ -22,7 +21,6 @@ import com.sukisu.ultra.Natives
import com.sukisu.ultra.ksuApp
import org.json.JSONArray
import java.io.File
import java.util.concurrent.CountDownLatch
/**
@@ -676,15 +674,14 @@ fun readUidScannerFile(): Boolean {
return try {
ShellUtils.fastCmd(shell, "cat /data/adb/ksu/.uid_scanner").trim() == "1"
} catch (_: Exception) {
false
false
}
}
fun addUmountPath(path: String, checkMnt: Boolean, flags: Int): Boolean {
fun addUmountPath(path: String, flags: Int): Boolean {
val shell = getRootShell()
val checkMntFlag = if (checkMnt) "--check-mnt" else ""
val flagsArg = if (flags >= 0) "--flags $flags" else ""
val cmd = "${getKsuDaemonPath()} umount add $path $checkMntFlag $flagsArg"
val cmd = "${getKsuDaemonPath()} umount add $path $flagsArg"
val result = ShellUtils.fastCmdResult(shell, cmd)
Log.i(TAG, "add umount path $path result: $result")
return result