socket: Actually use the console-socket definitions

Since the console_socket variables aren't declared with 'extern' in
console-server.h, we ended up with default definitions for these. This
happened to work, but with a zero-length socket path.

This change uses the console-socket.c object as intended, to provide
proper socket paths.

Now that the char[] is an extern, we'll need to get the address of it to
get the pointer value.

Also, fix the sizeof() to take account of the trailing nul.

Found by Joel Stanley <joel@jms.id.au>.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
diff --git a/Makefile.am b/Makefile.am
index 1da5d35..5f0a1bb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,11 +33,13 @@
 	 util.c \
 	 config.c \
 	 log-handler.c \
-	 socket-handler.c
+	 socket-handler.c \
+	 console-socket.c
 
 obmc_console_client_SOURCES = \
 	 console-client.c \
 	 console-server.h \
+	 console-socket.c \
 	 util.c
 
 config_test_CPPFLAGS = -DCONFIG_TEST -DSYSCONFDIR=\"\"
diff --git a/console-client.c b/console-client.c
index b70fc95..63c4e70 100644
--- a/console-client.c
+++ b/console-client.c
@@ -170,7 +170,7 @@
 
 	memset(&addr, 0, sizeof(addr));
 	addr.sun_family = AF_UNIX;
-	memcpy(addr.sun_path, console_socket_path, console_socket_path_len);
+	memcpy(&addr.sun_path, &console_socket_path, console_socket_path_len);
 
 	rc = connect(client->console_sd, (struct sockaddr *)&addr,
 			sizeof(addr));
diff --git a/console-server.h b/console-server.h
index 0ce9e6c..1a9e813 100644
--- a/console-server.h
+++ b/console-server.h
@@ -72,9 +72,9 @@
 void config_fini(struct config *config);
 
 /* socket paths */
-const char *console_socket_path;
-const size_t console_socket_path_len;
-const char *console_socket_path_readable;
+extern const char *console_socket_path;
+extern const size_t console_socket_path_len;
+extern const char *console_socket_path_readable;
 
 /* utils */
 int write_buf_to_fd(int fd, const uint8_t *buf, size_t len);
diff --git a/console-socket.c b/console-socket.c
index 45095a3..9e1cf30 100644
--- a/console-socket.c
+++ b/console-socket.c
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 
-const char console_socket_path[] = "\0obmc-uart-console";
-const size_t console_socket_len = sizeof(console_socket_path);
+#include <sys/types.h>
+
+const char console_socket_path[] = "\0obmc-console";
+const size_t console_socket_path_len = sizeof(console_socket_path) - 1;
 const char *console_socket_path_readable = console_socket_path + 1;
 
diff --git a/socket-handler.c b/socket-handler.c
index 68a340f..7be9c71 100644
--- a/socket-handler.c
+++ b/socket-handler.c
@@ -143,7 +143,7 @@
 
 	memset(&addr, 0, sizeof(addr));
 	addr.sun_family = AF_UNIX;
-	memcpy(addr.sun_path, console_socket_path, console_socket_path_len);
+	memcpy(&addr.sun_path, &console_socket_path, console_socket_path_len);
 
 	rc = bind(sh->sd, (struct sockaddr *)&addr, sizeof(addr));
 	if (rc) {