accesing a sys/class

874 views
Skip to first unread message

ajay

unread,
Jan 11, 2011, 10:21:57 PM1/11/11
to Android Linux Kernel Development
hi,

I have written a pseudo driver which creates a file(sample) in sys/
class/sampledriver in the phone.when i try to open the file i get an
error no 13.

but i have observed that we can remove this error by chmod 777 sys/
class/sampledriver/sample


but this type of hack is not possible on a phone which is rooted.

pls reply how to solve this issue.



Thanks and regards,
Ajay

Chris Stratton

unread,
Jan 15, 2011, 10:39:56 AM1/15/11
to Android Linux Kernel Development
I think you mean not possible to chmod the file on a phone which is
not rooted.

And the answer is that you cannot solve this problem on a secured
device.

Nor can you load custom kernel drivers on a secured device to begin
with.

If you are building this into a release which user's won't have root
within, you could change the bits in the permissions field that
accompanies the name field in the attribute structure used to create
the sysfs "file" - see Documentation/filesystems/sysfs.txt

Unfortunately, this method won't let you use android-style permissions
to control access. To do that, you'd have to be able to assign the
group ID of the sysfs entry to a hard coded linux group matching an
android group that is assigned to applications with the appropriate
permission.
Message has been deleted

ajay

unread,
Jan 17, 2011, 12:35:28 PM1/17/11
to android...@googlegroups.com
thanks Chris,
getting to the point
I was trying to write a program which uses the framework library libharware_legacy.so used for
vibration.

this library tries to open a the vibrator device file -"/sys/class/
timed_output/vibrator/enable"  and write to the file when api -
vibrator_on is called.

the vibrator_on API returns 0 if sucess else returns the ERROR NUMBER.

when we try to call this API from our feedback plugin library  this
API fails and returns an error number 13 which indicates that the we
dont have the PERMISSION to open the file although we have have set
the permissions in the manifest file of the java feedback
adapter(android.permission.VIBRATE)

we solved it by changing the permission of enable
(adb shell chmod 777 /sys/class/timed_output/vibrator/enable) since
the phone was rooted

we cant do the same on a different phone which has no root
permissions.

we have already ported QTfeedback module using JNI and it works well
without any modifications.

so please help us.

Thanks and Regards,
Ajay






--
ajay

Chris Stratton

unread,
Jan 17, 2011, 10:27:30 PM1/17/11
to Android Linux Kernel Development
On Jan 17, 12:35 pm, ajay <mna...@gmail.com> wrote:
> thanks Chris,
> getting to the point
> I was trying to write a program which uses the framework library
> libharware_legacy.so used for
> vibration.

You aren't supposed to do that. Go through the public interface to
the vibrator from java

> we cant do the same on a different phone which has no root
> permissions.

You aren't supposed to be able to.

ajay

unread,
Jan 18, 2011, 2:08:50 AM1/18/11
to Android Linux Kernel Development
thanks chris,

but if i am creating a phone(that is i am the vendor) which i
make it unrooted then how should i go about????
Reply all
Reply to author
Forward
0 new messages