c2d5d2
From 6e979154c9c51dedd54c91e46106e495a65ced43 Mon Sep 17 00:00:00 2001
6bbb92
From: Chris Leech <cleech@redhat.com>
6bbb92
Date: Wed, 2 Jan 2013 14:45:05 -0800
c2d5d2
Subject: [PATCH 58/58] iscsiuio IPC newroot command
6bbb92
6bbb92
---
6bbb92
 usr/mgmt_ipc.c     | 11 +++++++++++
6bbb92
 usr/transport.c    |  1 +
6bbb92
 usr/transport.h    |  1 +
6bbb92
 usr/uip_mgmt_ipc.c | 14 ++++++++++++++
6bbb92
 usr/uip_mgmt_ipc.h |  5 +++++
6bbb92
 5 files changed, 32 insertions(+)
6bbb92
6bbb92
diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c
6bbb92
index 5cb7143..a8f8473 100644
6bbb92
--- a/usr/mgmt_ipc.c
6bbb92
+++ b/usr/mgmt_ipc.c
6bbb92
@@ -36,6 +36,7 @@
6bbb92
 #include "sysdeps.h"
6bbb92
 #include "iscsi_ipc.h"
6bbb92
 #include "iscsi_err.h"
6bbb92
+#include "iscsi_sysfs.h"
6bbb92
 
6bbb92
 #define PEERUSER_MAX	64
6bbb92
 #define EXTMSG_MAX	(64 * 1024)
6bbb92
@@ -229,8 +230,18 @@ static int
6bbb92
 mgmt_ipc_newroot(queue_task_t *qtask)
6bbb92
 {
6bbb92
 	char *newroot = qtask->req.u.newroot.path;
6bbb92
+	struct iscsi_transport *t;
6bbb92
+
6bbb92
 	if (chdir(newroot) || chroot(".") || chdir("/"))
6bbb92
 		return ISCSI_ERR;
6bbb92
+
6bbb92
+	/* if a registered transport has a separate userspace process,
6bbb92
+	 * notify it of the root change as well */
6bbb92
+	list_for_each_entry(t, &transports, list) {
6bbb92
+		if (t->template->newroot)
6bbb92
+			t->template->newroot(t, newroot);
6bbb92
+	}
6bbb92
+
6bbb92
 	mgmt_ipc_write_rsp(qtask, ISCSI_SUCCESS);
6bbb92
 	return ISCSI_SUCCESS;
6bbb92
 }
6bbb92
diff --git a/usr/transport.c b/usr/transport.c
c2d5d2
index 4d030a8..e0488ad 100644
6bbb92
--- a/usr/transport.c
6bbb92
+++ b/usr/transport.c
c2d5d2
@@ -83,6 +83,7 @@ struct iscsi_transport_template bnx2i = {
6bbb92
 	.ep_poll	= ktransport_ep_poll,
6bbb92
 	.ep_disconnect	= ktransport_ep_disconnect,
6bbb92
 	.set_net_config = uip_broadcast_params,
6bbb92
+	.newroot	= uip_broadcast_newroot,
6bbb92
 };
6bbb92
 
6bbb92
 struct iscsi_transport_template be2iscsi = {
6bbb92
diff --git a/usr/transport.h b/usr/transport.h
c2d5d2
index 388e4b1..d4d9ec7 100644
6bbb92
--- a/usr/transport.h
6bbb92
+++ b/usr/transport.h
c2d5d2
@@ -39,6 +39,7 @@ struct iscsi_transport_template {
6bbb92
 	int (*set_net_config) (struct iscsi_transport *t,
6bbb92
 			       struct iface_rec *iface,
6bbb92
 			       struct iscsi_session *session);
6bbb92
+	void (*newroot) (struct iscsi_transport *t, char *path);
6bbb92
 };
6bbb92
 
6bbb92
 /* represents data path provider */
6bbb92
diff --git a/usr/uip_mgmt_ipc.c b/usr/uip_mgmt_ipc.c
c2d5d2
index f3074ee..d5d496a 100644
6bbb92
--- a/usr/uip_mgmt_ipc.c
6bbb92
+++ b/usr/uip_mgmt_ipc.c
6bbb92
@@ -39,3 +39,17 @@ int uip_broadcast_params(struct iscsi_transport *t,
6bbb92
 			     sizeof(iscsid_uip_broadcast_header_t) +
6bbb92
 			     sizeof(*iface));
6bbb92
 }
6bbb92
+
6bbb92
+int uip_broadcast_newroot(struct iscsi_transport *t, char *newroot)
6bbb92
+{
6bbb92
+	struct iscsid_uip_broadcast broadcast;
6bbb92
+
6bbb92
+	memset(&broadcast, 0, sizeof(broadcast));
6bbb92
+
6bbb92
+	broadcast.header.command = ISCSID_UIP_NEWROOT;
6bbb92
+	strncpy(broadcast.u.newroot.path, newroot, PATH_MAX);
6bbb92
+
6bbb92
+	return uip_broadcast(&broadcast,
6bbb92
+			     sizeof(iscsid_uip_broadcast_header_t) +
6bbb92
+			     PATH_MAX + 1);
6bbb92
+}
6bbb92
diff --git a/usr/uip_mgmt_ipc.h b/usr/uip_mgmt_ipc.h
c2d5d2
index 29a4769..3ca4fb1 100644
6bbb92
--- a/usr/uip_mgmt_ipc.h
6bbb92
+++ b/usr/uip_mgmt_ipc.h
6bbb92
@@ -29,6 +29,7 @@
6bbb92
 typedef enum iscsid_uip_cmd {
6bbb92
 	ISCSID_UIP_IPC_UNKNOWN			= 0,
6bbb92
 	ISCSID_UIP_IPC_GET_IFACE		= 1,
6bbb92
+	ISCSID_UIP_NEWROOT			= 2,
6bbb92
 
c2d5d2
 	__ISCSID_UIP_IPC_MAX_COMMAND
6bbb92
 } iscsid_uip_cmd_e;
6bbb92
@@ -47,6 +48,9 @@ typedef struct iscsid_uip_broadcast {
6bbb92
 		struct ipc_broadcast_iface_rec {
6bbb92
 			struct iface_rec rec;
6bbb92
 		} iface_rec;
6bbb92
+		struct ipc_broadcast_newroot {
6bbb92
+			char path[PATH_MAX + 1];
6bbb92
+		} newroot;
6bbb92
 	} u;
6bbb92
 } iscsid_uip_broadcast_t;
6bbb92
 
6bbb92
@@ -69,5 +73,6 @@ extern int uip_broadcast_params(struct iscsi_transport *t,
6bbb92
 				struct iface_rec *iface,
6bbb92
 				struct iscsi_session *session);
6bbb92
 
6bbb92
+extern int uip_broadcast_newroot(struct iscsi_transport *t, char *path);
6bbb92
 
6bbb92
 #endif /* UIP_MGMT_IPC_H */
6bbb92
-- 
c2d5d2
1.8.1.4
6bbb92