From: Hannes Reinecke <hare@suse.de>
To: Christophe Varoqui <christophe.varoqui@gmail.com>
Cc: dm-devel@redhat.com
Subject: [PATCH 07/11] multipathd: switch to abstract sockets for CLI commands
Date: Thu, 17 Jan 2013 15:59:29 +0100 [thread overview]
Message-ID: <1358434773-2002-8-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1358434773-2002-1-git-send-email-hare@suse.de>
Instead of using file-based sockets we should be switching to
abstract sockets. Otherwise multipathd won't be able to start
if the directory is not available.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
libmultipath/defaults.h | 2 +-
libmultipath/uxsock.c | 27 ++++++++++++++-------------
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h
index 32948d8..b83d9fb 100644
--- a/libmultipath/defaults.h
+++ b/libmultipath/defaults.h
@@ -24,7 +24,7 @@
#define MAX_DEV_LOSS_TMO 0x7FFFFFFF
#define DEFAULT_PIDFILE "/var/run/multipathd.pid"
-#define DEFAULT_SOCKET "/var/run/multipathd.sock"
+#define DEFAULT_SOCKET "/org/kernel/linux/storage/multipathd"
#define DEFAULT_CONFIGFILE "/etc/multipath.conf"
#define DEFAULT_BINDINGS_FILE "/etc/multipath/bindings"
#define DEFAULT_WWIDS_FILE "/etc/multipath/wwids"
diff --git a/libmultipath/uxsock.c b/libmultipath/uxsock.c
index e786899..f3e8dec 100644
--- a/libmultipath/uxsock.c
+++ b/libmultipath/uxsock.c
@@ -25,19 +25,21 @@
*/
int ux_socket_connect(const char *name)
{
- int fd;
+ int fd, len;
struct sockaddr_un addr;
memset(&addr, 0, sizeof(addr));
- addr.sun_family = AF_UNIX;
- strncpy(addr.sun_path, name, sizeof(addr.sun_path));
+ addr.sun_family = AF_LOCAL;
+ addr.sun_path[0] = '\0';
+ len = strlen(name) + 1;
+ strncpy(&addr.sun_path[1], name, len);
- fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (fd == -1) {
return -1;
}
- if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
+ if (connect(fd, (struct sockaddr *)&addr, len) == -1) {
close(fd);
return -1;
}
@@ -51,20 +53,19 @@ int ux_socket_connect(const char *name)
*/
int ux_socket_listen(const char *name)
{
- int fd;
+ int fd, len;
struct sockaddr_un addr;
- /* get rid of any old socket */
- unlink(name);
-
- fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (fd == -1) return -1;
memset(&addr, 0, sizeof(addr));
- addr.sun_family = AF_UNIX;
- strncpy(addr.sun_path, name, sizeof(addr.sun_path));
+ addr.sun_family = AF_LOCAL;
+ addr.sun_path[0] = '\0';
+ len = strlen(name) + 1;
+ strncpy(&addr.sun_path[1], name, len);
- if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
+ if (bind(fd, (struct sockaddr *)&addr, len) == -1) {
close(fd);
return -1;
}
--
1.7.10.4
next prev parent reply other threads:[~2013-01-17 14:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-17 14:59 [PATCH 00/11] Final round of SLES resync patches Hannes Reinecke
2013-01-17 14:59 ` [PATCH 01/11] Cleanup whitespaces Hannes Reinecke
2013-01-17 14:59 ` [PATCH 02/11] Provide correct persistent symlinks for user_friendly_names Hannes Reinecke
2013-01-17 14:59 ` [PATCH 03/11] kpartx_id: Generate persistent symlinks for 'wwn' Hannes Reinecke
2013-01-17 14:59 ` [PATCH 04/11] Fix inconsistent entries after merging hwtable with user's config Hannes Reinecke
2013-01-17 14:59 ` [PATCH 05/11] kpartx: Fix DASD name in kpartx_id Hannes Reinecke
2013-01-17 14:59 ` [PATCH 06/11] Break out loop in factorize_hwtable() Hannes Reinecke
2013-01-17 14:59 ` Hannes Reinecke [this message]
2013-01-17 14:59 ` [PATCH 08/11] multipathd: log message when check interval has changed Hannes Reinecke
2013-01-17 14:59 ` [PATCH 09/11] multipathd: call 'reconfigure' during startup Hannes Reinecke
2013-01-17 14:59 ` [PATCH 10/11] multipath: do not install rules file Hannes Reinecke
2013-01-17 14:59 ` [PATCH 11/11] kpartx: Deinstall kpartx_id Hannes Reinecke
2013-01-18 16:58 ` [PATCH 00/11] Final round of SLES resync patches Xose Vazquez Perez
2013-01-21 7:15 ` Hannes Reinecke
2013-01-21 18:48 ` Christophe Varoqui
2013-01-18 19:20 ` Christophe Varoqui
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=1358434773-2002-8-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=christophe.varoqui@gmail.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.