From 3540f14481d8f602adafb4b9cc8b1abd07b69e79 Mon Sep 17 00:00:00 2001 From: JingMatrix Date: Sat, 31 Jan 2026 15:51:03 +0100 Subject: [PATCH] Gracefully handle ENOTSUP in ConfigFileManager.chattr0 (#523) The `chattr0` method, which attempts to clear special file attributes (like 'i' for immutable) using `ioctl`, can fail with an `ErrnoException` and the error code `ENOTSUP` (Operation not supported) on certain filesystems or Android environments (e.g., noted on a Android 11 device). When `ioctl` fails with `ENOTSUP`, it means the underlying filesystem does not support the operation of setting/clearing these attributes. In this case, we can safely assume the file/directory is not immutable via this mechanism and treat the operation as a successful non-action. This commit updates `chattr0` to catch `ErrnoException` specifically and return `true` if the error is `OsConstants.ENOTSUP`, preventing unexpected failures in config file management. --- .../java/org/lsposed/lspd/service/ConfigFileManager.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/daemon/src/main/java/org/lsposed/lspd/service/ConfigFileManager.java b/daemon/src/main/java/org/lsposed/lspd/service/ConfigFileManager.java index 6e72014f..1f4d08e0 100644 --- a/daemon/src/main/java/org/lsposed/lspd/service/ConfigFileManager.java +++ b/daemon/src/main/java/org/lsposed/lspd/service/ConfigFileManager.java @@ -193,9 +193,18 @@ public class ConfigFileManager { public static boolean chattr0(Path path) { try { var dir = Os.open(path.toString(), OsConstants.O_RDONLY, 0); + // Clear all special file attributes on the directory HiddenApiBridge.Os_ioctlInt(dir, Process.is64Bit() ? 0x40086602 : 0x40046602, 0); Os.close(dir); return true; + } catch (ErrnoException e) { + // If the operation is not supported (ENOTSUP), it means the filesystem doesn't support attributes. + // We can assume the file is not immutable and proceed. + if (e.errno == OsConstants.ENOTSUP) { + return true; + } + Log.d(TAG, "chattr 0", e); + return false; } catch (Throwable e) { Log.d(TAG, "chattr 0", e); return false;