linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: [patch] udevd - switch socket path to abstract namespace
Date: Thu, 05 Feb 2004 01:07:48 +0000	[thread overview]
Message-ID: <20040205010748.GA1247@vrfy.org> (raw)

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


As Chris Friesen <chris_friesen@sympatico.ca> suggested, here we switch
the unix domains socket path to abstract namespace and get rid of the
socket file in the filesystem.

Hey, this was new to me today. So here a few words:
  Linux supports a abstract namespace for sockets. We don't need a
  physical file on the filesystem but only a unique string magically
  starting with the '\0' character.

  strace with real file:
    connect(3, {sa_family=AF_UNIX, path="/udev/.udevd.sock"}, 110)

  strace with abstract namespace:
    connect(3, {sa_family=AF_UNIX, path=@udevd}, 110)


thanks,
Kay

[-- Attachment #2: 02-abstract-namespace-socket.patch --]
[-- Type: text/plain, Size: 2032 bytes --]

===== Makefile 1.102 vs edited =====
--- 1.102/Makefile	Wed Feb  4 01:56:10 2004
+++ edited/Makefile	Thu Feb  5 01:41:19 2004
@@ -241,7 +241,6 @@
 	@echo \#define UDEV_PERMISSION_FILE	\"$(configdir)\udev.permissions\" >> $@
 	@echo \#define UDEV_BIN		\"$(DESTDIR)$(sbindir)/udev\" >> $@
 	@echo \#define UDEVD_BIN	\"$(DESTDIR)$(sbindir)/udevd\" >> $@
-	@echo \#define UDEVD_SOCK	\"$(udevdir)/\.udevd.sock\" >> $@
 	@echo \#define UDEVD_LOCK	\"$(udevdir)/\.udevd.lock\" >> $@
 
 # config files automatically generated
===== udevd.c 1.11 vs edited =====
--- 1.11/udevd.c	Thu Feb  5 01:40:44 2004
+++ edited/udevd.c	Thu Feb  5 01:42:59 2004
@@ -325,7 +325,6 @@
 		case SIGINT:
 		case SIGTERM:
 			unlink(UDEVD_LOCK);
-			unlink(UDEVD_SOCK);
 			exit(20 + signum);
 			break;
 		default:
@@ -378,9 +377,9 @@
 
 	memset(&saddr, 0x00, sizeof(saddr));
 	saddr.sun_family = AF_LOCAL;
-	strcpy(saddr.sun_path, UDEVD_SOCK);
+	/* use abstract namespace for socket path */
+	strcpy(&saddr.sun_path[1], UDEVD_SOCK_PATH);
 
-	unlink(UDEVD_SOCK);
 	ssock = socket(AF_LOCAL, SOCK_STREAM, 0);
 	if (ssock == -1) {
 		dbg("error getting socket");
@@ -426,6 +425,5 @@
 	}
 exit:
 	close(ssock);
-	unlink(UDEVD_SOCK);
 	exit(1);
 }
===== udevd.h 1.6 vs edited =====
--- 1.6/udevd.h	Mon Feb  2 03:40:48 2004
+++ edited/udevd.h	Thu Feb  5 01:41:33 2004
@@ -27,6 +27,7 @@
 #define UDEV_MAGIC			"udevd_" UDEV_VERSION
 #define EVENT_TIMEOUT_SEC		5
 #define UDEVSEND_CONNECT_RETRY		20 /* x 100 millisec */
+#define UDEVD_SOCK_PATH			"udevd"
 
 struct hotplug_msg {
 	char magic[20];
===== udevsend.c 1.15 vs edited =====
--- 1.15/udevsend.c	Thu Feb  5 01:40:44 2004
+++ edited/udevsend.c	Thu Feb  5 01:41:47 2004
@@ -161,7 +161,8 @@
 
 	memset(&saddr, 0x00, sizeof(saddr));
 	saddr.sun_family = AF_LOCAL;
-	strcpy(saddr.sun_path, UDEVD_SOCK);
+	/* use abstract namespace for socket path */
+	strcpy(&saddr.sun_path[1], UDEVD_SOCK_PATH);
 
 	/* try to connect, if it fails start daemon */
 	retval = connect(sock, (struct sockaddr *) &saddr, sizeof(saddr));

             reply	other threads:[~2004-02-05  1:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-05  1:07 Kay Sievers [this message]
2004-02-05  1:37 ` [patch] udevd - switch socket path to abstract namespace Greg KH
2004-02-05  9:19 ` Kay Sievers
2004-02-06  0:11 ` Greg KH

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=20040205010748.GA1247@vrfy.org \
    --to=kay.sievers@vrfy.org \
    --cc=linux-hotplug@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).