From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Waychison Date: Wed, 04 Feb 2004 21:06:20 +0000 Subject: Re: [PATCH] convert udevsend/udevd to using datagram sockets Message-Id: <40215ECC.2070804@sun.com> List-Id: References: <40209893.8080109@sympatico.ca> In-Reply-To: <40209893.8080109@sympatico.ca> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org Chris Friesen wrote: > This patch does a couple of things to udevsend/udevd. It doesn't touch > udev itself at all. > > 1) It switches to using the abstract namespace. This simplifies things > since you don't have to go around unlinking. When the socket goes away, > the address is gone. > > > > > memset(&saddr, 0x00, sizeof(saddr)); > saddr.sun_family = AF_LOCAL; >- strcpy(saddr.sun_path, UDEVD_SOCK); >+ saddr.sun_path[0] = 0; >+ strcpy(saddr.sun_path+1, UDEV_SOCK_NAME); >+ >+ /* The size of the address is the offset of the start of the filename, >+ * plus its length, plus one for the beginning null byte. >+ */ >+ addrlen = offsetof(struct sockaddr_un, sun_path) + strlen (saddr.sun_path+1) + 1; > >- unlink(UDEVD_SOCK); >- ssock = socket(AF_LOCAL, SOCK_STREAM, 0); >+ ssock = socket(AF_LOCAL, SOCK_DGRAM, 0); > if (ssock = -1) { > dbg("error getting socket"); > exit(1); > } > >- retval = bind(ssock, &saddr, sizeof(saddr)); >+ retval = bind(ssock, &saddr, addrlen); > > The addrlen parameter should still be sizeof(saddr), regarless of the contents of the abstract namespace address. The same would go for the sendto command. -- Mike Waychison Sun Microsystems, Inc. 1 (650) 352-5299 voice 1 (416) 202-8336 voice mailto: Michael.Waychison@Sun.COM http://www.sun.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NOTICE: The opinions expressed in this email are held by me, and may not represent the views of Sun Microsystems, Inc. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ------------------------------------------------------- The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. http://www.eclipsecon.org/osdn _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel