1 From 6e979154c9c51dedd54c91e46106e495a65ced43 Mon Sep 17 00:00:00 2001
2 From: Chris Leech <cleech@redhat.com>
3 Date: Wed, 2 Jan 2013 14:45:05 -0800
4 Subject: [PATCH 58/58] iscsiuio IPC newroot command
7 usr/mgmt_ipc.c | 11 +++++++++++
10 usr/uip_mgmt_ipc.c | 14 ++++++++++++++
11 usr/uip_mgmt_ipc.h | 5 +++++
12 5 files changed, 32 insertions(+)
14 diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c
15 index 5cb7143..a8f8473 100644
20 #include "iscsi_ipc.h"
21 #include "iscsi_err.h"
22 +#include "iscsi_sysfs.h"
24 #define PEERUSER_MAX 64
25 #define EXTMSG_MAX (64 * 1024)
26 @@ -229,8 +230,18 @@ static int
27 mgmt_ipc_newroot(queue_task_t *qtask)
29 char *newroot = qtask->req.u.newroot.path;
30 + struct iscsi_transport *t;
32 if (chdir(newroot) || chroot(".") || chdir("/"))
35 + /* if a registered transport has a separate userspace process,
36 + * notify it of the root change as well */
37 + list_for_each_entry(t, &transports, list) {
38 + if (t->template->newroot)
39 + t->template->newroot(t, newroot);
42 mgmt_ipc_write_rsp(qtask, ISCSI_SUCCESS);
45 diff --git a/usr/transport.c b/usr/transport.c
46 index 4d030a8..e0488ad 100644
49 @@ -83,6 +83,7 @@ struct iscsi_transport_template bnx2i = {
50 .ep_poll = ktransport_ep_poll,
51 .ep_disconnect = ktransport_ep_disconnect,
52 .set_net_config = uip_broadcast_params,
53 + .newroot = uip_broadcast_newroot,
56 struct iscsi_transport_template be2iscsi = {
57 diff --git a/usr/transport.h b/usr/transport.h
58 index 388e4b1..d4d9ec7 100644
61 @@ -39,6 +39,7 @@ struct iscsi_transport_template {
62 int (*set_net_config) (struct iscsi_transport *t,
63 struct iface_rec *iface,
64 struct iscsi_session *session);
65 + void (*newroot) (struct iscsi_transport *t, char *path);
68 /* represents data path provider */
69 diff --git a/usr/uip_mgmt_ipc.c b/usr/uip_mgmt_ipc.c
70 index f3074ee..d5d496a 100644
71 --- a/usr/uip_mgmt_ipc.c
72 +++ b/usr/uip_mgmt_ipc.c
73 @@ -39,3 +39,17 @@ int uip_broadcast_params(struct iscsi_transport *t,
74 sizeof(iscsid_uip_broadcast_header_t) +
78 +int uip_broadcast_newroot(struct iscsi_transport *t, char *newroot)
80 + struct iscsid_uip_broadcast broadcast;
82 + memset(&broadcast, 0, sizeof(broadcast));
84 + broadcast.header.command = ISCSID_UIP_NEWROOT;
85 + strncpy(broadcast.u.newroot.path, newroot, PATH_MAX);
87 + return uip_broadcast(&broadcast,
88 + sizeof(iscsid_uip_broadcast_header_t) +
91 diff --git a/usr/uip_mgmt_ipc.h b/usr/uip_mgmt_ipc.h
92 index 29a4769..3ca4fb1 100644
93 --- a/usr/uip_mgmt_ipc.h
94 +++ b/usr/uip_mgmt_ipc.h
96 typedef enum iscsid_uip_cmd {
97 ISCSID_UIP_IPC_UNKNOWN = 0,
98 ISCSID_UIP_IPC_GET_IFACE = 1,
99 + ISCSID_UIP_NEWROOT = 2,
101 __ISCSID_UIP_IPC_MAX_COMMAND
103 @@ -47,6 +48,9 @@ typedef struct iscsid_uip_broadcast {
104 struct ipc_broadcast_iface_rec {
105 struct iface_rec rec;
107 + struct ipc_broadcast_newroot {
108 + char path[PATH_MAX + 1];
111 } iscsid_uip_broadcast_t;
113 @@ -69,5 +73,6 @@ extern int uip_broadcast_params(struct iscsi_transport *t,
114 struct iface_rec *iface,
115 struct iscsi_session *session);
117 +extern int uip_broadcast_newroot(struct iscsi_transport *t, char *path);
119 #endif /* UIP_MGMT_IPC_H */