• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help Acess denied to internal memory /sdcard

Daxorp

Newbie
Hello,

On my tablet /sdcard and equivalent folders (/storage/emulated/0, /storage/emulated/legacy, /storage/sdcard0) and all /storage (so external_SD) are not accessible anymore. So I can not launch most applications.

In command line from the tablet with ConnectBot, cd /sdcard, ls gives opendir failed: permission denied. Idem for /storage.

But in root after su, files are here. And also with ADB (even not root this time).

So the problem is only with the tablet and the normal user which can not access to the internal and external memory.


Before that I try the app "GL to SD", and it does the same as SDFix by modifiing the file /etc/permissions/platform.xml. As I don't want, I remove the app and move back platform.xml.bak to platform.xml but with not the good rights, so I set them (644). I reboot to verify and I was in that situation.

First can this file be linked with my problem or not? What can I do to recover access to internal memory?

I have a LG G pad 7 with Android 5.02.
 
Last edited:
Welcome to our AndroidForums, Daxorp.

No obvious solutions from me, but a couple of questions for you to help eliminate some things:

1. Do you have persistent root on this device? (i.e., it's not just a temporary root, correct?)

2. Is your platform.xml file owned by root:root (i.e., it's owner and group) and are the permissions indeed 0644 ("rx-r--r--")?

Here's what my file looks like (even though it's located in the /system partition):​

root@hammerhead:/ # ls -l /system/etc/permissions/platform.xml
-rw-r--r-- root root 6281 1971-04-06 13:15 platform.xml​

3. Also, my WRITE_EXTERNAL_STORAGE permissions are set to this (bearing in mind that I've got a Nexus 5 running 5.1.1):

<permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
<group gid="sdcard_r" />
<group gid="sdcard_rw" />
</permission>​

4. Can you diff your platforms.xml and the platform.xml.back files to show the differences?

Cheers!
 
Thank you for your answer.

1. Yes, it's persistent root but SuperSU asks me each time.

2. Yes, I checked platform.xml is own by root:root and 644. That was not the case the 1st time I boot, but now it's correct everything should work. But maybe it's not involved in the problem... :-|

3. I have the same.

4. The app just add a line "<group gid="media_rw" />"
But now I check and re-check this file, I'm pretty sure the problem is elsewhere.


Access is denied to /storage and its subdirectories (/emulated, /sdcard0, /external_SD...) but not for root, so are there some permissions that could have been changed for the normal user?
 
Hmm, not sure...

But it's good that root access verifies that the files exist, so that does indeed indicate some other permission / security issue.

How about the ownership of the files in your /storage/emulated/0 folder?

Here's the top part of my list of files:

root@hammerhead:/storage/emulated/0 # ls -l /storage/emulated/0
drwxrwx--- root sdcard_r 1971-01-05 14:33 Alarms
drwxrwx--x root sdcard_r 2015-07-04 10:39 Android
drwxrwx--- root sdcard_r 2015-06-13 09:06 Books
drwxrwx--- root sdcard_r 2015-05-24 11:40 DCIM
drwxrwx--- root sdcard_r 2015-07-17 13:04 Download
drwxrwx--- root sdcard_r 1971-01-05 14:33 Movies
drwxrwx--- root sdcard_r 1971-01-05 14:33 Music
drwxrwx--- root sdcard_r 2014-12-20 16:08 Notifications
drwxrwx--- root sdcard_r 2015-03-21 22:08 Pictures
drwxrwx--- root sdcard_r 1971-01-05 14:33 Podcasts
drwxrwx--- root sdcard_r 1971-01-05 14:33 Ringtones
drwxrwx--- root sdcard_r 2015-08-26 20:48 SH_IMAGES
drwxrwx--- root sdcard_r 1971-01-05 18:50 TWRP
drwxrwx--- root sdcard_r 2015-07-11 11:26 TitaniumBackup
-rw-rw---- root sdcard_r 4017098 2015-03-19 23:19 UPDATE-SuperSU-v2.46.zip
-rw-rw---- root sdcard_r 2472 2015-06-27 14:29 after.txt
drwxrwx--- root sdcard_r 2015-05-21 22:33 afwall
drwxrwx--- root sdcard_r 2014-12-20 15:19 amazon

Does yours also indicate the sdcard_r group for the files and directories in you SD card?
 
I also get the "Permission denied" error when I use su to login to another account:

root@hammerhead:/storage/emulated/0 # su - u0_a87
su - u0_a87
u0_a87@hammerhead:/storage/emulated/0 $ ls -l mSecure
ls -l mSecure
opendir failed, Permission denied
1|u0_a87@hammerhead:/storage/emulated/0 $

Lemme grab my testing device and I'll install the changes to the platform.xml file and see how this operates.

Back later...
 
How about the ownership of the files in your /storage/emulated/0 folder?

With root or ADB, I don't have /storage/emulated/0, but only /storage/emulated/legacy (if I remember well, this was the case also before the problem).

But in /storage/emulated/legacy or /storage/sdcard0 I also have
drwxrwx--- root sdcard_r ...

(and idem in /storage/external_SD).

Is it possible that /storage is not mounted for normal user?


With ADB:

shell@e7wifi:/ $ ls -l /storage/emulated/0
/storage/emulated/0: No such file or directory

shell@e7wifi:/ $ ls -l /storage/emulated/legacy
drwxrwx--x root sdcard_r 2015-07-26 15:45 Android
drwxrwx--- root sdcard_r 2015-07-27 17:57 AppCenter
drwxrwx--- root sdcard_r 2015-07-23 01:39 DCIM
drwxrwx--- root sdcard_r 2015-08-18 16:58 DevexpertNET
drwxrwx--- root sdcard_r 2014-05-26 07:42 Download
drwxrwx--- root sdcard_r 2015-07-23 01:32 Movies
drwxrwx--- root sdcard_r 2013-01-01 06:44 Pictures
drwxrwx--- root sdcard_r 2015-07-29 21:54 QuickMemo+
drwxrwx--- root sdcard_r 2015-07-23 01:31 Ringtones
drwxrwx--- root sdcard_r 2015-07-23 01:57 VoiceRecorder
drwxrwx--- root sdcard_r 2015-07-28 18:01 backups
drwxrwx--- root sdcard_r 2015-08-20 00:53 keepass

shell@e7wifi:/ $ ls -l /storage
drwx------ root root 1970-01-01 18:48 USBstorage1
drwx------ root root 1970-01-01 18:48 USBstorage2
drwx------ root root 1970-01-01 18:48 USBstorage3
drwx------ root root 1970-01-01 18:48 USBstorage4
drwx------ root root 1970-01-01 18:48 USBstorage5
drwx------ root root 1970-01-01 18:48 USBstorage6
dr-xr-xr-x root root 1970-01-01 18:48 emulated
drwxrwx--x root sdcard_r 2014-05-26 09:45 external_SD
lrwxrwxrwx root root 1970-01-01 18:48 sdcard0 -> /storage/emulated/legacy

shell@e7wifi:/storage/emulated $ ls -l /storage/emulated
drwxrwx--x root sdcard_r 2015-08-28 19:03 legacy

(Exactly the same with root. But from the tablet only root can access all these directories...)
 
Last edited:
Lemme grab my testing device and I'll install the changes to the platform.xml file and see how this operates.


I put the original platform.xml. If you can test something, try to:
- give it permissions rw- --- --- (not sure but the app "GLtoSD" did that)
- reboot
- give back the permissions rw- r-- r--
- reboot and look in a file explorer if it works.

If yes, my problem is not from here, but I read someone with the same problem even after setting again the rights (but it's weird!).


PS: Anyway, thanks for your time and help, I'm on this problem for hours. :-/
 
Well, I apparently don't even need the <group gid="media_rw" /> permission for my 5.1.1--I seem to remember talk about Google relaxing the security/permissions restriction that is/was leading to the issues you're experiencing.

Not sure if the path to the SD card differences are relevant here...

Can you post the section in your platform.xml file showing ALL of the permissions related to external storage? Here are mine (from the stock file):

<permission name="android.permission.READ_EXTERNAL_STORAGE" >
<group gid="sdcard_r" />
</permission>

<permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
<group gid="sdcard_r" />
<group gid="sdcard_rw" />
</permission>

<permission name="android.permission.ACCESS_ALL_EXTERNAL_STORAGE" >
<group gid="sdcard_r" />
<group gid="sdcard_rw" />
<group gid="sdcard_all" />
</permission>

<permission name="android.permission.WRITE_MEDIA_STORAGE" >
<group gid="media_rw" />
</permission>

<permission name="android.permission.ACCESS_MTP" >
<group gid="mtp" />
</permission>

Dunno, lemme keep thinking / playing with this...

If I feel really enterprising, I might flash 4.x back on my test N5 for you to see what's up, but I'm thinking that your issue is not just a straight "SD fix" type of issue.
 
<permission name="android.permission.READ_EXTERNAL_STORAGE" >
<group gid="sdcard_r" />
</permission>

<permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
<group gid="sdcard_r" />
<group gid="sdcard_rw" />
</permission>

<permission name="android.permission.ACCESS_ALL_EXTERNAL_STORAGE"
<group gid="sdcard_r" />
<group gid="sdcard_rw" />
<group gid="sdcard_all" />
</permission>

<permission name="android.permission.WRITE_MEDIA_STORAGE" >
<group gid="media_rw" />
</permission>

<permission name="android.permission.ACCESS_MTP" >
<group gid="mtp" />
</permission>



Yes maybe a "SD Fix" problem. I write to the developer of "GLtoSD" to ask if his app does something else. But I think the platform.xml.bak is really my original file.

But as I said someone else has troubles with the permissions (http://android.stackexchange.com/questions/85732/permissions-for-system-etc). That's why I said try to set them wrong then good again!

I'm not on Android 4.x but 5.02.


(PS: I attach the whole file, but I really think the backup was correct.)
 

Attachments

Last edited:
Thanks!

Yeah, I just realized my su - <userid> tests were probably invalid--the shell isn't asking for the permissions that are involved here. I'll have to re-test with a file-explorer app (I've one of my own I can test with).

Also, I suggested 4.x to test with since we know that's about when Google made the change for this permission issue with the SD card (I'll have to nail-down exactly which version, though) so I can test with a known state.
 
Access is denied to SD card, but to internal memory too!

Do you think clearing the Dalvik-cache can help? (Edit: I try and no.)

I start thinking to reinstall the stock Android with the LG support tool... which means loosing everything I guess.
I can download some directories with ADB, but I will have some work to reinstall everything. :-(
 
Last edited:
I think you're right: the problem is the file platform.xml and it's not read at all. It's the same if I delete it.
I also can not use Wifi or Bluetooth, and in command line, only root can ping (this is defined is platform.xml too).

Maybe the 1st boot with the wrong permissions makes this file been deleted from another file and it's not read at boot... How can we know where this file is called to verify this? :-|
 
Last edited:
One thing I noticed was that you kept referencing /etc/permissions/platform.xml whereas my file is stored in /system/etc/permissions/platform.xml.

Do you have a /system/etc/permissions/platform.xml file?
 
As you're the only one to help me and you seem to be short of ideas, I will launch the "force upgrade" with LG support tool.
I read it keeps the data as a normal update. I should only need to re-root after.
Thanks for your help, I hope to do the same for you one day. :)
 
I have found and done this : restorecon -v -R /data/media
not restorecon -FR /data/media/0

I will re-root and try but the tablet is not rooted anymore. Like the guy in the link above, the "force upgrade" doesn't repair... :(
It keeps the apps and data so I think I need to totally reset the tablet. :(

Can I just delete some data and restore them later? I did a backup with adb but I don't know what it's really save.
 
No, still nothing with restorecon. :(

As re-install the system doesn't repair, this is a problem with data... What does really erase a factory reset?
Maybe I can try to move the data one by one to see when it works again.
 
Last edited:
OK guys. Thanks for your help, but I can do nothing more, so I do a factory reset. I recover the access to storage but... I'm now starting the long process to reinstall my apps (the adb backup with APK does not work, only the one without APK, I'm not lucky!). :eek:
 
Back
Top Bottom