chmod 777 <file> not working with init.rc

4,544 views
Skip to first unread message

Pratik Prajapati

unread,
Sep 20, 2011, 11:48:18 AM9/20/11
to android-d...@googlegroups.com, android-...@googlegroups.com, android...@googlegroups.com, android-porting
Hi There,

I'm setting permission to 777 (R+W+E for all) to a script file. But after kernel built and flashed to the system, permission does not get changed as expected. I understand I can give permission in make file while creating filesystem to be flashed on system. But same thing is happening for some sysfs entries. These sysfs entries are created by drivers at boot up time. I have also tried

on device-added-<device node path>
    chmod 777 <sys fs file name>

But I can not set the mode by this method also. However on console (adb shell) i can change the permission. I'm running on 2.1

Any idea, what could be wrong?

Regards,
Pratik


jagan

unread,
Sep 20, 2011, 11:58:52 AM9/20/11
to android...@googlegroups.com, android-d...@googlegroups.com, android-...@googlegroups.com, android-porting
You can't give the permissions directly on android source.
We need to give the permissions on init.rc.
Better to read the file from   system/core/init/readme.txt

Regards,
Jagan

Pratik Prajapati

unread,
Sep 20, 2011, 12:06:09 PM9/20/11
to android...@googlegroups.com, android-d...@googlegroups.com, android-...@googlegroups.com, android-porting
Hi,

I'm doing below things in init.rc only.

(1)

on device-added-<device node path>
    chmod 777 <sys fs file name>

(2) on boot

    chmod 777 <sys fs file name>

But it does not work.

--
Regards,
Pratik Prajapati

venkata Aravind

unread,
Sep 20, 2011, 11:37:13 PM9/20/11
to android...@googlegroups.com, android-d...@googlegroups.com, android-...@googlegroups.com, android-porting
I think the modified file of your init.rc, is overwritten by build script and the changes are missed out in final image. Better way would be apply the changes to init.rc file at below location.
system/core/rootdir/init.rc

You can try like, pull the init.rc file from the file-system apply the changes and push again. 

Regards
Venkata

venkata Aravind

unread,
Sep 20, 2011, 11:40:57 PM9/20/11
to android...@googlegroups.com

Pratik Prajapati

unread,
Sep 21, 2011, 12:39:03 AM9/21/11
to android...@googlegroups.com
I can see my changes in init.rc when I 'cat' it on adb shell. But still no change in the permission of the file after the device boots up.
Any other guess?

Thanks.
Regards,
Pratik Prajapati



biAji

unread,
Sep 21, 2011, 1:42:02 AM9/21/11
to android...@googlegroups.com

Try logwrapper your chmod command to get some output log

NaveenShrivastva

unread,
Sep 21, 2011, 3:32:56 AM9/21/11
to android...@googlegroups.com
Hello Developer,

U missing the option of unix,

just type

chmod -R ugo+777 <sys fs file name>

chmod -R ugo+rwx <sys fs file name>

seba

unread,
Sep 21, 2011, 4:55:09 AM9/21/11
to Android Linux Kernel Development
Hi,

It looks like the <sys fs file name> does not exist
at the time when init runs the chmod command

R,
Sebastian.


On 20 Wrz, 18:06, Pratik Prajapati <pratik.prajap...@gmail.com> wrote:
> Hi,
>
> I'm doing below things in init.rc only.
>
> (1)
> on device-added-<device node path>
>     chmod 777 <sys fs file name>
>
> (2) on boot
>     chmod 777 <sys fs file name>
>
> But it does not work.
>
> --
> Regards,
> Pratik Prajapati
>

Maddy

unread,
Sep 21, 2011, 6:20:34 AM9/21/11
to Android Linux Kernel Development
Dear Pratik Prajapati,

As per current implementation in android kernel boot process, the
content of init.rc vanishes as soon as the phone is rebooted.
Reason for this behavior is that the init.rc (some other content) are
part of ramdisk (which in turn is part of boot.img not system.img)
This implementation is to enhance security of system.

Therefore any content change in init.rc will have no impact upon
reboot.

~Maddy

On Sep 21, 10:42 am, biAji <biaji...@gmail.com> wrote:
> Try logwrapper your chmod command to get some output log
> On 2011-9-21 下午12:39, "Pratik Prajapati" <pratik.prajap...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I can see my changes in init.rc when I 'cat' it on adb shell. But still no
> > change in the permission of the file after the device boots up.
> > Any other guess?
>
> > Thanks.
>
> > On Tue, Sep 20, 2011 at 8:40 PM, venkata Aravind
> > <venkata.arav...@gmail.com>wrote:
>
> >> I think the modified file of your init.rc, is overwritten by build script
> >> and the changes are missed out in final image. Better way would be apply
> the
> >> changes to init.rc file at below location.
> >> system/core/rootdir/init.rc
>
> >> You can try like, pull the init.rc file from the file-system apply
> >> the changes and push again.
>
> >> Regards
> >> Venkata
>
> >> On Wed, Sep 21, 2011 at 1:06 AM, Pratik Prajapati <
> >> pratik.prajap...@gmail.com> wrote:
>
> >>> Hi,
>
> >>> I'm doing below things in init.rc only.
>
> >>> (1)
>
> >>> on device-added-<device node path>
> >>> chmod 777 <sys fs file name>
>
> >>> (2) on boot
>
> >>> chmod 777 <sys fs file name>
>
> >>> But it does not work.
>
> >>> --
> >>> Regards,
> >>> Pratik Prajapati
>

Pratik Prajapati

unread,
Sep 23, 2011, 1:26:59 PM9/23/11
to android...@googlegroups.com
Hi Maddy,

I understand its part of ramdisk. I'm not changing init.rc on the device. I'm changing init.rc in my build environment. So that it gets reflected to the system when I flash the images. After flashing the images I can see my changes in init.rc, but chmod command is not doing its job. I'm running android 2.1

Any inputs?

--
Regards,
Pratik Prajapati

Mitesh Patel

unread,
Sep 23, 2011, 1:34:20 PM9/23/11
to android...@googlegroups.com
Pradeep I'll check

Thanks - Mitesh
Sent from BlackBerry® on Airtel


From: Pratik Prajapati <pratik.p...@gmail.com>
Date: Fri, 23 Sep 2011 10:26:59 -0700
Subject: Re: [android-kernel] Re: chmod 777 <file> not working with init.rc

ekwang

unread,
Sep 28, 2011, 12:46:14 PM9/28/11
to android...@googlegroups.com, android-d...@googlegroups.com, android-...@googlegroups.com, android-porting, pratik.p...@gmail.com
How about giving permission before to do that?

chown system sysetm <sys fs file name>
chmod 777 <sys fs file name>

Lee.

Pratik Prajapati

unread,
Sep 28, 2011, 2:10:08 PM9/28/11
to android...@googlegroups.com
I have tried that too. chown  does not work either.

--
Regards,
Pratik Prajapati

Sylvain Huard

unread,
Nov 2, 2011, 3:38:28 PM11/2/11
to android...@googlegroups.com, android-d...@googlegroups.com, android-...@googlegroups.com, android-porting, pratik.p...@gmail.com
I had a very similar problem with a "chmod 0777 filename" not working in my init.rc. It took me hours to figure it out. Just in case you face the same thing, here is what was my problem. The directory where "filename" was had less rights than what I wanted for "filename". So, even though filename was supposed to be 0777, the effective rights were the one of "parent directory". To fix it I did:
chmod 0777 "parentdirectory"
chmod 0777 "parentdirectory/filename"


Pratik Prajapati

unread,
Nov 4, 2011, 6:22:08 PM11/4/11
to android...@googlegroups.com, android-d...@googlegroups.com, android-...@googlegroups.com, android-porting
Ok. Thanks. In fact I modified the driver which was exporting this sysfs entry. Not driver creates the the entry with 777 perm only.

--
Regards,
Pratik Prajapati
Reply all
Reply to author
Forward
0 new messages