问题描述:

I have compiled android 4.2.1 from the MTK official source tree.The phone have a internal storage as an EXTERNAL_STORAGE(sdcard0) and SDCARD as SECONDARY_STORAGE(sdcard1), no emulated. But all apps report 0 space left(include "Settings") in both.

mount output:

/dev/block/vold/179:8 /storage/sdcard0 vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0

/dev/block/vold/179:97 /storage/sdcard1 vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0

/etc/platform.xml:

<permission name="android.permission.READ_EXTERNAL_STORAGE" >

<group gid="media_r" />

<group gid="sdcard_r" />

</permission>

<permission name="android.permission.WRITE_EXTERNAL_STORAGE" >

<group gid="sdcard_r" />

<group gid="sdcard_rw" />

<group gid="media_r" />

<group gid="media_rw" />

</permission>

<permission name="android.permission.WRITE_MEDIA_STORAGE" >

<group gid="sdcard_rw" />

<group gid="media_rw" />

</permission>

<permission name="android.permission.ACCESS_ALL_EXTERNAL_STORAGE" >

<group gid="sdcard_r" />

<group gid="sdcard_rw" />

<group gid="sdcard_all" />

<group gid="media_rw" />

<group gid="media_r" />

</permission>

I add debug code in packages/apps/Settings/src/com/android/settings/deviceinfo/StorageMeasurment.java:

private void measureApproximateStorage(IMediaContainerService imcs) {

..........

try {

final long[] stats = imcs.getFileSystemStats(path);

mTotalSize = stats[0];

mAvailSize = stats[1];

Log.d(TAG, "## total size:" + mTotalSize + " path:" + path);

} catch (Exception e) {

Log.w(TAG, "Problem in container service", e);

}

sendInternalApproximateUpdate();

}

when click the "Settings" => "Storage" ,the log show:

D/StorageMeasurement( 1454): ## total size:2142347264 path:/data

D/StorageMeasurement( 1454): ## total size:0 path:/storage/sdcard1

D/StorageMeasurement( 1454): ## total size:0 path:/storage/sdcard0

Trace imcs.getFileSystemStats() till native call statfs in libcore/luni/src/main/native/libcore_io_Posix.cpp

then add debug code in it:

static jobject Posix_statfs(JNIEnv* env, jobject, jstring javaPath) {

ScopedUtfChars path(env, javaPath);

if (path.c_str() == NULL) {

return NULL;

}

struct statfs sb;

int rc = TEMP_FAILURE_RETRY(statfs(path.c_str(), &sb));

ALOGE("[My Debug]## path:%s blocks:%llu rc:%d uid:%d gid:%d",

path.c_str(), sb.f_blocks, rc, getuid(), getgid());

if (rc == -1) {

throwErrnoException(env, "statfs");

return NULL;

}

return makeStructStatFs(env, sb);

}

the log show:

E/Posix ( 1524): [My Debug]## path:/storage/sdcard1 blocks:0 rc:0 uid:10018 gid:10018

E/Posix ( 1524): [My Debug]## path:/storage/sdcard0 blocks:0 rc:0 uid:10018 gid:10018

It's very strange , df (which call statfs) in shell is work:

[email protected]:/ # df

Filesystem Size Used Free Blksize

/dev 483M 52K 483M 4096

/mnt/secure 483M 0K 483M 4096

/mnt/asec 483M 0K 483M 4096

/mnt/obb 483M 0K 483M 4096

/system 648M 365M 282M 4096

/data 1G 175M 1G 4096

/cache 124M 4M 119M 4096

/mnt/cd-rom 1M 1M 0K 2048

/protect_f 8M 4M 4M 4096

/protect_s 8M 4M 4M 4096

/storage/sdcard0 865M 864M 464K 16384

/mnt/secure/asec 865M 864M 464K 16384

/storage/sdcard1 28G 5G 23G 16384

and read/write sdcard0 and sdcard1 is ok in shell.

Even I remount sdcard0 and sdcard1 as fmask,dmask =0000 still 0 space left and debug log show 0 block.

相关阅读:
Top