How can I use O_DIRECT or O_SYNC on an external SD card with Android KitKat

狂风中的少年 提交于 2019-12-21 06:04:59

问题


I work for a company that makes an SD memory card that includes a hardware encryption engine. We interact with the encryption module by writing/reading to a special file.

Starting with KitKat, the O_DIRECT flag does not seem to be supported on the external SD card. Without O_DIRECT or O_SYNC support, the OS will returned cached data when we read the encryption engine's response from the SD card (via our special file).

Is there a procedure to open a file on the eternal SD card, read/write, with either O_DIRECT or O_SYNC?


回答1:


If you have root-access to your phone you can write a 1 to /proc/sys/vm/drop_caches to clear the page cache (see http://linux-mm.org/Drop_Caches). After that command the next read on the sdcard will return the non-cached data.

For stock-devices (where you have no permission to /proc/sys/vm/drop_caches) there is a issue in the AOSP (you may star it): https://code.google.com/p/android/issues/detail?id=67406



来源:https://stackoverflow.com/questions/21873726/how-can-i-use-o-direct-or-o-sync-on-an-external-sd-card-with-android-kitkat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!