I have a C program:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/select.h>
#include <sys/stat.h>
#include <sys/mount.h>
int main(void)
{
if (fork() == 0)
{
int i, sret, ret = -1;
unsigned char usb_dev[10];
struct stat st;
sprintf(usb_dev, "/dev/sda1");
printf("USB STORAGE automount ");
while(1)
{
if ((stat(usb_dev, &st) == 0))
{
if (ret == -1)
{
ret = mount(usb_dev, "/usbdrive",
"vfat", MS_NOATIME, "");
if (ret == 0)
{
printf("usb storage mounted\n");
}
else
{
printf("trying to mount usb
storage..\n");
}
}
}
else
{
if (ret == 0)
{
if (umount("/usbdrive") == 0)
printf("usb storage
unmounted\n");
ret = -1;
}
}
sleep(2);
}
}
printf(": started\n");
return 0;
}
I compiled it to an executable: usb_automount.
I did push it to a folder inside android linux kernel: /system/bin/
I added this in init.rc and then compile the ramdisk image. And it
doesn't work instead "init: untracked pid 2194 exited" is displayed in
the terminal. When the program is executed manually, it works well.
service usbmount /system/bin/usb_automount
user automount
group automount
socket automount stream 666
----
I have also tried below and it doesn't work.
on boot
exec /system/bin/usb_automount
----
Then I tried this, not working again.
service usbmount /system/bin/usb_automount
user usbmount
disabled
oneshot
----
Finally I tried this, (usb_automount program not used anymore) but it
has no positive result either.
on device-added-/dev/sda1
mount -t vfat /dev/sda1 /usbdrive
on device-removed-/dev/sda1
umount /usbdrive
My init.rc is really useless it does not do anything except the things
already written to it and "mkdir /usbdrive" which is the only thing I
added that worked. Hours of recompiling really waste my time just for
editing init.rc.
Can someone help me out here? What am I missing? Any help is greatly
appreciated. You can send me a private reply if preferred.
Thanks.
--
unsubscribe: [email protected]
website: http://groups.google.com/group/android-kernel