There is a file named bootanimation.zip in /system/media:
1853 -rw-r--r-- 1 root root 2.1M 2018-07-10 17:29 bootanimation.zip
I want to make it writeable.
So I do this in init.rc:
on fs
+ mount ext4 /dev/block/platform/mstar_mci.0/by-name/system /system wait rw
+ chmod 0777 /system/media/bootanimation.zip
mount_all /fstab.m7221
But it is useless.The bootanimation.zip still is -rw-r--r--.
How can I make /system/media/bootanimation.zip rw in init.rc ?
Can someone tell me how to debug init.rc , I can not see any log!
Related
Android rootfs is compressed and split into:
super.raw.00.gz, super.raw.01.gz, super.raw.03.gz, super.raw.04.gz
How to unzip, combine, unpack them to ext4 files that can be mounted ?
Steps are:
Unzip each of the multi-zip files:
gzip -d super.raw.00.gz
gzip -d super.raw.01.gz
gzip -d super.raw.02.gz
gzip -d super.raw.03.gz
Concatenate them to a single file:
cat super.raw.00 super.raw.01 super.raw.02 super.raw.03 > super.raw
Unpack the super image using lpunpack tool. Download link.
./lpunpack super.raw
Mount the image- For eg: system_a
mkdir mount_system
sudo mount -t ext4 -o loop system_a.img mount_system
I use the smartphone emulator in Android Studio for a Nexus 4, API 23.
I took a picture through its camera, and I can check that the file is present at this different paths through the Android Device Monitor:
/data/media/0/DCIM/Camera/IMG_20160408_143726.jpg (rw-rw-r)
/storage/emulated/0/DCIM/Camera/IMG_20160408_143726.jpg (rw-rw)
Nevertheless, in my Activity I got different behaviors when I try to read the file:
new File("/data/media/0/DCIM/Camera/IMG_20160408_143726.jpg");
// isFile at false, canRead at false, length at 0
new File("/storage/emulated/0/DCIM/Camera/IMG_20160408_143726.jpg");
// isFile at true, canRead at true, length with a real value
Why is it so?
it depends on contructor, use this method to get the sdcard path instead, that will find the correct path for all devices
new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera/IMG_20160408_143726.jpg")
You probably would like to grant your app root permission so as to let it work properly. Take a look at this example:
u0_a1#android:/ $ toolbox ls -l /storage/emulated/0/UPDATE*
-rw-rw---- root sdcard_r 4997896 2016-09-08 20:08 UPDATE-SuperSU-v2.78.zip
u0_a1#android:/ $ toolbox ls -l /data/media/0/UPDATE*
/data/media/0/*: Permission denied
1|u0_a1#android:/ $ su
root#android:/ # toolbox ls -l /data/media/0/UPDATE*
-rw-rw-r-- media_rw media_rw 4997896 2016-09-08 20:08 UPDATE-SuperSU-v2.78.zip
Android device, I want to touch a file or dir in /mnt, it say "Read only file system", I don't know how to do. i try fix it with that fix /system, but it no work.
root#android:/ # ls -l
.....
drwxrwxr-x root system 2011-01-01 11:33 mnt
.....
root#android:/ #
root#android:/ # mkdir /mnt/test
mkdir failed for /mnt/test, Read-only file system
255|root#android:/ #
root#android:/ # mount -o remount,rw /mnt
Usage: mount [-r] [-w] [-o options] [-t type] device directory
1|root#android:/ #
can't fix it as /system.
how can i do it?
root#android:/ # id
uid=0(root) gid=0(root)
root#android:/ #
But i can make directory in /mnt/xxx/, like this:
root#android:/ # mkdir /mnt/usb_storage/test
root#android:/ # ls /mnt/usb_storage/test/
root#android:/ # ls /mnt/usb_storage/
test
root#android:/ #
And
i fond difference between /mnt and /mnt/usb_storage in init.rc
look /mnt:
# create mountpoints
mkdir /mnt 0775 root system
look /mnt/usb_storage:
# Directory for multi usb storage
mkdir /mnt/usb_storage 0700 root system
mount tmpfs tmpfs /mnt/usb_storage mode=0755 gid=1000
Yes!I fix it!
create mountpoints
mkdir /mnt 0775 root system
add mount tmpfs tmpfs /mnt/ mode=0755 gid=1000
now i can touch file or make directory in /mnt
root#android:/mnt # mkdir /mnt/test
root#android:/mnt # ls -l /mnt/
....
drwxrwxrwx root root 2011-01-01 11:04 test
drwxrwxrwt root system 2011-01-01 11:00 usb_storage
root#android:/mnt #
Resolved
ramdisk rootfs is read only.
mount -o remount,rw /
you should have to add certain permission into your manifest file..
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
and for more see the following which near to what you looking for
Can't create file in sd-card
my app have root right ,i want to using code to build a dir or file at /system or other dir of device.
i know common java build file as:
File file = new File(destFileName);
if (file.exists()) {
return false;
}
if i can build dir at system like the above code?if i need use su command before build file dir as
Process p = null;
p = Runtime.getRuntime().exec("su");
edit: i have read Create a file in /system directory but i cannot using code write :
" hint: use the "adb shell" and check if the upper steps can lead to success (su && remount -o remount,rw /system && touch /system/test)"
You need to get /system be mounted for write. By default it is read-only. You can use command like mount -o remount,rw /system
You can create dir using mkdir command
You can change the owner user by chown command
After that you can use java code as ususal.
I am using Android Emulator 2.2 version to develop a small application. I am supposed to list all the image files(jpg) files under a directory. I copied the files to "/data" through ADB puash command.
Example : /data/1.jpg
Now I create a File object with the directory path as input and call listFiles api.
File dir = new File(dirPath);
File[] filelist = dir.listFiles();
But the fileList does not contain the image file(1.jpg).
But strangely, If I create a ImageView with hardcoded path "/data/1.jpg", I could see the image getting drawn.
Can some one help me.... where could be the problem
Thanks,
Kowndinya
public int PopulateList(final String dirPath)
{
m_CurrentDirectory = new File(dirPath);
_namelist.clear();
_pathlist.clear();
File[] fileList = m_CurrentDirectory.listFiles(imFilter);
if (fileList != null)
{
for ( int i = 0;i<fileList.length;i++)
{
_namelist.addElement(fileList[i].getName());
_pathlist.addElement(fileList[i].getAbsolutePath());
}
}
notifyDataSetChanged();
return 0;
}
imFilter is an filenamefilter that accepts only files with jpg extension. But if I put break point in the imFilter code, break point does not event hit.
Output of adb shell ls -l /data:
------------------------------------
drwxrwx--t system misc 2010-08-05 15:32 misc
drwxrwx--x shell shell 2010-08-05 15:32 local
drwxrwx--x system system 2010-08-05 15:32 app-private
drwx------ system system 2010-08-05 15:34 backup
drwx------ root root 2010-08-05 15:34 property
drwxrwx--x system system 2010-08-05 15:35 data
-rw-rw-rw- root root 75752 2010-03-30 12:26 zona_ind_012.jpg
drwxrwx--x system system 2010-08-05 16:16 app
drwxr-x--- root log 2010-08-05 15:32 dontpanic
drwxrwx--x system system 2010-08-05 16:25 dalvik-cache
drwxrwxr-x system system 2010-08-05 17:16 system
drwxrwx--- root root 2010-08-05 15:32 lost+found
I explore that code, and see, trouble is in permission. As you can see below, you can't read that dir.Find another dir to collect your files.
**Can read dir:**
/dev =true
/root =false
/data =false
/default.prop =true
/init =false
/init.rc =false
/proc =true
/sbin =false
/sys =true
/system =true
/etc =true
/d =false
/mnt =true
/acct =true
/sdcard =true
/cache =false
/config =false
and that you can see from "ls -l" command.
explain what does mean