Question

I want to run glibc within Android ICS Emulator, for which I have bundled the glibc as a separate folder in AOSP root folder, with Android.mk in it with below contents:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
$(shell mkdir -p $(TARGET_OUT)/glibc/)
$(shell cp -rf $(LOCAL_PATH)/* `pwd`/$(TARGET_OUT)/glibc/)

It copies the entire glibc folder to out/target/product/generic/system/ folder. And make snod includes it in the system.img

There is startglibc.sh and init.sh script withing glibc folder which gets copied to /system/glibc & /system/glibc/root/ folder respectively.

I have busybox compiled and copied to /system/bin/ folder.

Content of /system/glibc/startglibc.sh is as below:

BUSYBOX=/system/bin/busybox
mnt=/system/glibc

export PATH=/usr/bin:/usr/sbin:/bin:$PATH
export ROOT=/root

${BUSYBOX} chroot $mnt /root/init.sh

The startglibc.sh is invoked from init.goldfish.rc as below:

service myscript /system/bin/busybox ash /system/glibc/startglibc.sh
    class main
    oneshot

I have given 777 and root:root as file permission for init.sh using system/core/include/private/android_filesystem_config.h as below:

{ 00777, AID_ROOT,      AID_ROOT,     "system/glibc/root/init.sh" },

During boot time the startglibc.sh script is getting called but while executing chroot it gives permission denied error.

Am I missing anything for doing chroot using init.sh? Or am I copying the glibc folder wrongly during Android AOSP build?

Était-ce utile?

La solution

I was able to successfully do chroot. Below is what I did:

chroot requires not only the init script or /bin/sh with execute permission, but most of the file system folders like bin. etc. var. etc. for creating a new root.

Hence, I gave below in system/core/include/private/android_filesystem_config.h

{ 00755, AID_ROOT,      AID_ROOT,     "system/glibc/" },
{ 00755, AID_ROOT,      AID_ROOT,     "system/glibc/*" },

Because when I copy the entire folder during AOSP build, by default the permission for all the files and folders in copied folder is 644 and hence the necessary folders required for chroot do not have execute permission.

Also, if any of the folder within the copied needs additional permission, then we can specify the same below above code.

I really loved the way android gives the permissions to filesystem. It is extremely configurable.

I hope this helps somebody else as well.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top