New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erroneously detecting /storage/emulated/legacy as secondary public storage #492

Closed
d4rken opened this Issue Sep 13, 2016 · 2 comments

Comments

1 participant
@d4rken
Owner

d4rken commented Sep 13, 2016

SD Maid erroneously detects /storage/emulated/legacy as secondary public storage:

Storage(location=SDCARD, path=/storage/sdcard0, userHandle=0, flags=[PRIMARY], safUri=null, mount=Mountpoint(path=/storage/sdcard0, blockDevice=/dev/fuse, fileSystemType=FUSE, options=[nodev, group_id=1023, relatime, rw, nosuid, default_permissions, allow_other, user_id=1023, noexec]))
Storage(location=SDCARD, path=/storage/emulated/0, userHandle=-1, flags=[EMULATED, SECONDARY], safUri=null, mount=Mountpoint(path=/storage/emulated/0, blockDevice=/dev/fuse, fileSystemType=FUSE, options=[nodev, group_id=1023, relatime, rw, nosuid, default_permissions, allow_other, user_id=1023, noexec]))
Storage(location=SDCARD, path=/storage/emulated/legacy, userHandle=-1, flags=[SECONDARY], safUri=null, mount=Mountpoint(path=/storage/emulated/legacy, blockDevice=/dev/fuse, fileSystemType=FUSE, options=[nodev, group_id=1023, relatime, rw, nosuid, default_permissions, allow_other, user_id=1023, noexec]))

Correct would be just /storage/emulated/0 as secondary public storage and /storage/sdcard0 as primary public storage. (Yes the system has a storage swap option to use the external(removable) sdcard as internal public storage.

This device has a few confusing mounts

/dev/fuse on /storage/sdcard0 type fuse (rw,nosuid,nodev,noexec,relatime,user_id=1023,group_id=1023,default_permissions,allow_other)
/dev/fuse on /storage/emulated/legacy type fuse (rw,nosuid,nodev,noexec,relatime,user_id=1023,group_id=1023,default_permissions,allow_other)
/dev/fuse on /storage/emulated/0 type fuse (rw,nosuid,nodev,noexec,relatime,user_id=1023,group_id=1023,default_permissions,allow_other)
/dev/block/vold/179:129 on /mnt/media_rw/sdcard0 type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)

Now how does SD Maid come to the conclusion?
System APIs don't return the legacy path:

getExternalCacheDirs(): {/storage/sdcard0/Android/data/eu.thedarken.sdm/cache, /storage/emulated/0/Android/data/eu.thedarken.sdm/cache}

Because SD Maid also checks environment variables:

D/SDM:SdcardModule: EXTERNAL_STORAGE2=null
D/SDM:SdcardModule: EXTERNAL_ALT_STORAGE=null
D/SDM:SdcardModule: SECOND_VOLUME_STORAGE=null
D/SDM:SdcardModule: SECONDARY_STORAGE=/storage/emulated/legacy

Using that variable his a pretty commong practice for not fully supported secondary public storages:

Looks like and oversight of the ROM. Possible solution here would be to just hardcode a check for /storage/emulated/legacy as this is likely never a valid path for a secondary public storage.

F: VERSIONNAME:4.3.2; VERSIONCODE:40303
P: VERSIONNAME:4.0.7; VERSIONCODE:40007
ro.build.id=LMY47D
ro.build.display.id=PSP3457DUO.20160303.1.0.19
ro.build.version.incremental=eng.ccadmin.20160303.165914
ro.build.ap.version=TBW961822_9871_V020136
ro.build.version.sdk=22
ro.build.version.codename=REL
ro.build.version.all_codenames=REL
ro.build.version.release=5.1
ro.build.date=Thu Mar 3 17:00:27 CST 2016
ro.build.date.utc=1456995627
ro.build.type=user
ro.build.user=ccadmin
ro.build.host=BUILD19
ro.build.tags=release-keys
ro.build.flavor=sp7731geaplus_dt_oversea-user
ro.product.model=PSP3457DUO
ro.product.brand=Prestigio
ro.product.name=PSP3457DUO
ro.product.device=KT45B01G
ro.product.board=sp7731gea
ro.product.cpu.abi=armeabi-v7a
ro.product.cpu.abi2=armeabi
ro.product.cpu.abilist=armeabi-v7a,armeabi
ro.product.cpu.abilist32=armeabi-v7a,armeabi
ro.product.cpu.abilist64=
ro.product.manufacturer=Prestigio
ro.product.locale.language=en
ro.product.locale.region=GB
ro.build.product=PSP3457DUO
ro.build.description=PSP3457DUO-user 5.1 LMY47D 03031659 release-keys
ro.build.fingerprint=Prestigio/PSP3457DUO/KT45B01G:5.1/LMY47D/10221943:user/release-keys
ro.build.characteristics=default
ro.product.hardware=SP7731GEA_V1.0.0
ro.product.partitionpath=/dev/block/platform/sdio_emmc/by-name/
ro.product.version=1.0.19

@d4rken

This comment has been minimized.

Owner

d4rken commented Sep 13, 2016

screenshot_2016-09-12-07-08-31

@d4rken

This comment has been minimized.

Owner

d4rken commented Sep 13, 2016

Actually check:
https://source.android.com/devices/storage/config-example.html

The example hardware config reads:

on init
    mkdir /mnt/shell/emulated 0700 shell shell
    mkdir /storage/emulated 0555 root root
    mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw
    mkdir /storage/sdcard1 0700 root root
    export EXTERNAL_STORAGE /storage/emulated/legacy
    export EMULATED_STORAGE_SOURCE /mnt/shell/emulated
    export EMULATED_STORAGE_TARGET /storage/emulated
    export SECONDARY_STORAGE /storage/sdcard1

Maybe the ROM manufactor mistakenly swapped EXTERNAL_STORAGE and SECONDARY_STORAGE...

@d4rken d4rken modified the milestones: Next Tasks, v4.3.3 Sep 14, 2016

@d4rken d4rken closed this Sep 15, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment