[stgt] [PATCH 09/14] tgt: BSD support - bind() is picky about names

Boaz Harrosh bharrosh at panasas.com
Mon Feb 23 19:05:28 CET 2009


The BSD's bind does not like the Linux IPC names with zero
as first char and zeros padding at end. #ifdef a different
implementation for BSD.

Note: On BSD, after exit a file is left in current directory
      with the pipe's name. The "up" script was modified to
      delete this file before and after the tgtd load.
      (File name is: TGT_IPC_ABSTRACT_NAMESPACE)

Signed-off-by: Boaz Harrosh <bharrosh at panasas.com>
---
 usr/mgmt.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/usr/mgmt.c b/usr/mgmt.c
index 03560c8..d93ff5c 100644
--- a/usr/mgmt.c
+++ b/usr/mgmt.c
@@ -563,6 +563,7 @@ int ipc_init(void)
 
 	memset(&addr, 0, sizeof(addr));
 	addr.sun_family = AF_LOCAL;
+#ifndef __MAKE_TGT_ON_BSD__
 	memcpy((char *) &addr.sun_path + 1, TGT_IPC_NAMESPACE,
 	       strlen(TGT_IPC_NAMESPACE));
 
@@ -571,6 +572,16 @@ int ipc_init(void)
 		eprintf("can't bind a socket, %m\n");
 		goto out;
 	}
+#else
+	sprintf(addr.sun_path , TGT_IPC_NAMESPACE);
+	addr.sun_len = SUN_LEN(&addr) + 1;
+
+	err = bind(fd, (struct sockaddr *) &addr, addr.sun_len);
+	if (err) {
+		eprintf("can't bind a socket, %d, %s\n", err, strerror(errno));
+		goto out;
+	}
+#endif
 
 	err = listen(fd, 32);
 	if (err) {
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list