All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek <konrad@virtualiron.com>
To: device-mapper development <dm-devel@redhat.com>
Subject: Re: simple question... to tough to answer?
Date: Thu, 15 May 2008 13:54:11 -0400	[thread overview]
Message-ID: <20080515175411.GA12985@mars.virtualiron.com> (raw)
In-Reply-To: <7BC3A7DB53028743B733D298244A8C626E3A0D@sjcpexch02.citrite.net>

[-- Attachment #1: Type: text/plain, Size: 736 bytes --]

On Thu, May 15, 2008 at 10:09:35AM -0700, Wim Colgate wrote:
> Hi,
> 
>  
> 
> I'm not quite sure why no one in the community hasn't been able to
> answer my questions. 

Probably b/c folks are too busy..

> 
>  
> 
> Simply (re)stated:
> 
>  
> 
> 1) Are there hooks for dm/multipath events to notify software?

You can also listen to the NETLINK_DM socket and parse the data.

But that complicated by the fact that there is only one
socket that the kernel uses and it cannot be shared.

> 
> 2) does path down/up fire up udev rules?

Yes. I am attaching a simple program you can use to listen to the kobject uevents
that get fired.

You can also modify it to use NETLINK_DM instead of NETLINK_KOBJECT_UEVENT  and see
what comes out.


[-- Attachment #2: listen.c --]
[-- Type: text/plain, Size: 1061 bytes --]

#include <sys/socket.h>
#include <linux/netlink.h>
#include <stdio.h>
#include <string.h>
#define MAX_PAYLOAD 1024        /* maximum payload size */
struct sockaddr_nl src_addr;
int sock_fd;
static char buff[MAX_PAYLOAD];
ssize_t buflen;

int
main ()
{
  sock_fd = socket (PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);

  memset (&src_addr, 0, sizeof (src_addr));
  src_addr.nl_family = AF_NETLINK;
  src_addr.nl_pid = getpid ();  /* self pid */
  src_addr.nl_groups = 0xffffffff;

  printf ("Listen..\n");
  bind (sock_fd, (struct sockaddr *) &src_addr, sizeof (src_addr));
  printf ("Receiving..\n");
  while (1)
    {
      buflen = recv (sock_fd, &buff, sizeof (buff), 0);
      printf ("Got data: %d\n", buflen);
      int i, bufpos;
      char *key;
      for (i = 0, bufpos = 0; (bufpos < buflen) && i < MAX_PAYLOAD; i++)
        {
          key = &buff[bufpos];
          printf ("[%s]\n", key);
          bufpos += strlen (key) + 1;
        }
      memset (&buff, 0, MAX_PAYLOAD);
    }
  /* Close Netlink Socket */
  close (sock_fd);
  return 0;
}

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



  parent reply	other threads:[~2008-05-15 17:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15 17:09 simple question... to tough to answer? Wim Colgate
2008-05-15 17:46 ` malahal
2008-05-15 17:54 ` Konrad Rzeszutek [this message]
2008-05-16 11:19 ` Hannes Reinecke
2008-05-16 15:27   ` Mike Anderson
2008-06-05 19:06     ` Craig Simpson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080515175411.GA12985@mars.virtualiron.com \
    --to=konrad@virtualiron.com \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.