Why can't I delete a folder in /config/sdcardfs as root (Termux)?


Question

I'm looking to delete a folder that is in /config/sdcardfs. My device is rooted and I'm trying as superuser. I still get the results operation not permitted.


What do I need to do to get the permission to do this.


I have tried to do sudo rm -rf name-of-folder with no success.
I have also tried to do it after running tsu (Termux's version of su). No success.


P.S.

I haven't had any issues deleting in other places even in places I need root permission (for example in the /data folder.


Answer

SHORT ANSWER


You don't need to delete anything in /config. What appear inside the directory aren't actual files. They are cleared and repopulated on device restart.


You can't delete /config/sdcardfs directory. SDCard FileSystem (sdcardfs) is a core OS component. Your device (or at least storage) won't be usable without sdcardfs properly configured.


DETAILS


Android is based on Linux kernel. Kernel is the backbone of OS which handles hardware components and many other core functionalities. The other part of OS: userspace talks to kernel space through different mechanisms like syscalls, sockets and virtual filesystems. procfs, sysfs and configfs are common virtual/pseudo filesystems i.e. they live in RAM. Kernel exports information about processes, hardware devices, and drivers etc. to user space through virtual files in these filesystems.


/proc and /sys are mostly read-only, except a few interfaces to which userspace can write some values in order to make configurations. configfs (which is mounted at /config on Android devices) is relatively a new addition to Linux kernel. It allows userspace to make relatively bigger kernel configurations by creating large number of virtual files in sub-directories under /config.


Android uses configfs at least for two purposes:



In order to make file sharing among apps possible, Android sets fixed permissions on files in external storage (be it physically internal or external). To achieve this, at start, Android used FUSE for filesystem emulation, then sdcardfs replaced it. For more details see my answer to What is /storage/emulated/0/? and Android's Storage Journey, in particular the concept of synthesized permissions.


So it's the Android OS which creates and deletes virtual files in /config/sdcardfs/ in order to let kernel know which permissions to enforce on which files/directories in external storage (/sdcard as well as physically external SD cards, USB drives etc).


Additionally Android uses sdcardfs to assign three GIDs: AID_MEDIA_AUDIO (1055), AID_MEDIA_VIDEO (1056) and AID_MEDIA_IMAGE (1057) to media files by providing their relevant list of file extensions in /config/sdcardfs/extensions/. It's to quickly categorize files without scanning all of them. See some details in this answer.


So deleting something in /config/sdcardfs (and in kernel's other virtual filesystems as well) doesn't make sense if you don't know what you are doing. That would do no good except breaking storage functionality on your device.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes