1

I am building a custom Android os by inserting some my own code into Android OS code file "/art/runtime/art_method.cc". In my code, I want to read a text file by calling the following read file function:

FILE* f = fopen(file_name,"r");

However, I find that the inserted code cannot read the text file when the Android OS is running.

The version of Android OS source code is android-8.1.0_r40

I read a post in stack overflow: Read/write files within a Linux kernel module but it is related to the Linux kernel but not the android kernel. There are no C head files in the accepted answer for Android OS source code.

So, I want to know how to read the file in the Android kernel.

Thank you very much!

Jaymin
  • 2,879
  • 3
  • 19
  • 35
  • 1
    I have deleted my post as it did not add anything new to what you already know. But, it is important to note: 1) File I/O in the way you are proposing is highly discouraged from within Linux. (This would include the Android variant of Linux.) 2) Android OS, although based on a highly customized variant of Linux, is not Linux. If you choose to go against recommendations _not_ to do File I/O, then find the API/methods that are provided within the Android OS environment, and do not be surprised that _regular_ Linux API calls are not provided. – ryyker Nov 28 '18 at 13:39

0 Answers0