hal + udev + gnome-volume-manager

Arvind Ayyangar arvind.ayyangar at gmail.com
Mon Aug 7 04:30:14 PDT 2006


hi ppl,
  i am new to this topic, and could not find much details of what i was
searching for, so that this would be the right place to mail Iin case it
aint, please guide me )...

i wanted to know who does the mounting of hotpluged devices? i know that
halddaemon broacasts the message on Dbus wen a new device is added and the
callouts for the device is completed and the /proc/mount tree is changed.
but who reads the messages from Dbus, is it gnome-volume-manager or
gnome-mount? if it is the manager, i could not find that part of the code in
the sources which does the mounting...


also, i tried reading messages from udev by killing the systems hald and
reading the mesages by creating a local socket.. code is as under, but it
doesnt seem to work..

static gboolean hald_udev_data(GIOChannel *source, GIOCondition condition,
gpointer user_data)
{
      int fd;
      int retval;
      struct msghdr smsg;
      struct cmsghdr *cmsg;
      struct iovec iov;
      struct ucred *cred;
      char cred_msg[CMSG_SPACE(sizeof(struct ucred))];

      char buf[4096];
      size_t bufpos = 0;
      const char *action = NULL;
      memset(buf, 0x00, sizeof (buf));

      fd = g_io_channel_unix_get_fd (source);

      iov.iov_base = &buf;
      iov.iov_len = sizeof (buf);

      memset(&smsg, 0x00, sizeof (struct msghdr));
      smsg.msg_iov = &iov;
      smsg.msg_iovlen = 1;
      smsg.msg_control = cred_msg;
      smsg.msg_controllen = sizeof (cred_msg);
      retval = recvmsg (fd, &smsg, 0);
      if(retval==-1){
              syslog("\nError recieving mesage from udev--my hald");
      }
      syslog("Recieved message is: %s --my hald",(char
*)smsg.msg_iov->iov_base);

      return TRUE;


}

void osspec_init()
{
        int udev_socket,on=1;
        struct sockaddr_un saddr;
        GIOChannel *udev_channel;
        socklen_t addrlen;
        memset(&saddr,0x00,sizeof(saddr));

        saddr.sun_family=AF_LOCAL;
        strcpy(&saddr.sun_path[1],"/org/freedesktop/hal/udev_event");
        addrlen=offsetof(struct sockaddr_un,sun_path) + strlen(
saddr.sun_path + 1);

        udev_socket=socket(AF_LOCAL,SOCK_DGRAM,0);
        if(udev_socket<0){
                printf("Error creating socket");
                exit(0);
        }
        printf("\nSocket created..");
        if((bind(udev_socket,(struct sockaddr *) &saddr,addrlen))<0){
                printf("\nError binding socket..");
                exit(1);
        }
        /* enable receiving of the sender credentials */
        setsockopt(udev_socket, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
        udev_channel = g_io_channel_unix_new (udev_socket);
        g_io_add_watch (udev_channel, G_IO_IN, hald_udev_data, NULL);
        g_io_channel_unref (udev_channel);

}

int main()
{
        pid_t child_pid;
        GMainLoop *loop=g_main_loop_new(NULL,FALSE);
        child_pid=fork();
        if(child_pid<0){
                printf("\Fork error..");
                return 0;
        }
        else if (child_pid>0){//parent
                exit(0);
        }
        setsid();
        umask(0);
        chdir("/");
        printf("\nProcess demonized");
        /*process demonized*/

        osspec_init();
        g_main_loop_run(loop);
}

132,1         Bot





thank u in advance..

-- 
Regards
 ARviND AyyangaR
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/hal/attachments/20060807/6e2cc47d/attachment.html


More information about the hal mailing list