* [Suspend2][ 01/13] [Suspend2] Storage.c header.
2006-06-27 4:40 [Suspend2][ 00/13] Storage manager Nigel Cunningham
@ 2006-06-27 4:40 ` Nigel Cunningham
2006-06-27 4:40 ` [Suspend2][ 02/13] [Suspend2] Receive storage manager message Nigel Cunningham
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Nigel Cunningham @ 2006-06-27 4:40 UTC (permalink / raw)
To: linux-kernel
Header for the storage.c file. This file provides the interface to a
userspace helper that manages access to storage (possibly network storage,
eg).
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/storage.c | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/kernel/power/storage.c b/kernel/power/storage.c
new file mode 100644
index 0000000..91b24a6
--- /dev/null
+++ b/kernel/power/storage.c
@@ -0,0 +1,36 @@
+/*
+ * kernel/power/storage.c
+ *
+ * Copyright (C) 2005-2006 Nigel Cunningham <nigel@suspend2.net>
+ *
+ * This file is released under the GPLv2.
+ *
+ * Routines for talking to a userspace program that manages storage.
+ *
+ * The kernel side:
+ * - starts the userspace program;
+ * - sends messages telling it when to open and close the connection;
+ * - tells it when to quit;
+ *
+ * The user space side:
+ * - passes messages regarding status;
+ *
+ */
+
+#include <linux/suspend.h>
+#include <linux/freezer.h>
+
+#include "proc.h"
+#include "modules.h"
+#include "netlink.h"
+#include "storage.h"
+#include "ui.h"
+
+static struct user_helper_data usm_helper_data;
+static struct suspend_module_ops usm_ops;
+static int message_received = 0;
+static int activations = 0;
+static int usm_prepare_count = 0;
+static int storage_manager_last_action = 0;
+static int storage_manager_action = 0;
+
--
Nigel Cunningham nigel at suspend2 dot net
^ permalink raw reply [flat|nested] 14+ messages in thread* [Suspend2][ 02/13] [Suspend2] Receive storage manager message
2006-06-27 4:40 [Suspend2][ 00/13] Storage manager Nigel Cunningham
2006-06-27 4:40 ` [Suspend2][ 01/13] [Suspend2] Storage.c header Nigel Cunningham
@ 2006-06-27 4:40 ` Nigel Cunningham
2006-06-27 4:40 ` [Suspend2][ 03/13] [Suspend2] Ask userspace to enable/disable access to our storage Nigel Cunningham
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Nigel Cunningham @ 2006-06-27 4:40 UTC (permalink / raw)
To: linux-kernel
Routine called when netlink messages are received.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/storage.c | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/kernel/power/storage.c b/kernel/power/storage.c
index 91b24a6..b66efe2 100644
--- a/kernel/power/storage.c
+++ b/kernel/power/storage.c
@@ -34,3 +34,41 @@ static int usm_prepare_count = 0;
static int storage_manager_last_action = 0;
static int storage_manager_action = 0;
+static int usm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
+{
+ int type;
+ int *data;
+
+ type = nlh->nlmsg_type;
+
+ /* A control message: ignore them */
+ if (type < NETLINK_MSG_BASE)
+ return 0;
+
+ /* Unknown message: reply with EINVAL */
+ if (type >= USM_MSG_MAX)
+ return -EINVAL;
+
+ /* All operations require privileges, even GET */
+ if (security_netlink_recv(skb))
+ return -EPERM;
+
+ /* Only allow one task to receive NOFREEZE privileges */
+ if (type == NETLINK_MSG_NOFREEZE_ME && usm_helper_data.pid != -1)
+ return -EBUSY;
+
+ data = (int*)NLMSG_DATA(nlh);
+
+ switch (type) {
+ case USM_MSG_SUCCESS:
+ case USM_MSG_FAILED:
+ message_received = type;
+ complete(&usm_helper_data.wait_for_process);
+ break;
+ default:
+ printk("Storage manager doesn't recognise message %d.\n", type);
+ }
+
+ return 1;
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
^ permalink raw reply [flat|nested] 14+ messages in thread* [Suspend2][ 03/13] [Suspend2] Ask userspace to enable/disable access to our storage.
2006-06-27 4:40 [Suspend2][ 00/13] Storage manager Nigel Cunningham
2006-06-27 4:40 ` [Suspend2][ 01/13] [Suspend2] Storage.c header Nigel Cunningham
2006-06-27 4:40 ` [Suspend2][ 02/13] [Suspend2] Receive storage manager message Nigel Cunningham
@ 2006-06-27 4:40 ` Nigel Cunningham
2006-06-27 4:40 ` [Suspend2][ 04/13] [Suspend2] Utility function for testing storage managers Nigel Cunningham
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Nigel Cunningham @ 2006-06-27 4:40 UTC (permalink / raw)
To: linux-kernel
Ask userspace to do whatever it needs to do to provide us with access to
the image storage, or to tear down the access.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/storage.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/kernel/power/storage.c b/kernel/power/storage.c
index b66efe2..71b8c02 100644
--- a/kernel/power/storage.c
+++ b/kernel/power/storage.c
@@ -72,3 +72,61 @@ static int usm_user_rcv_msg(struct sk_bu
return 1;
}
+int suspend_activate_storage(int force)
+{
+ int tries = 1;
+
+ if (usm_helper_data.pid == -1 || usm_ops.disabled)
+ return 0;
+
+ message_received = 0;
+ activations++;
+
+ if (activations > 1 && !force)
+ return 0;
+
+ while ((!message_received || message_received == USM_MSG_FAILED) && tries < 2) {
+ suspend_prepare_status(DONT_CLEAR_BAR, "Activate storage attempt %d.\n", tries);
+
+ init_completion(&usm_helper_data.wait_for_process);
+
+ suspend_send_netlink_message(&usm_helper_data,
+ USM_MSG_CONNECT,
+ NULL, 0);
+
+ /* Wait 2 seconds for the userspace process to make contact */
+ wait_for_completion_timeout(&usm_helper_data.wait_for_process, 2*HZ);
+
+ tries++;
+ }
+
+ return 0;
+}
+
+int suspend_deactivate_storage(int force)
+{
+ if (usm_helper_data.pid == -1 || usm_ops.disabled)
+ return 0;
+
+ message_received = 0;
+ activations--;
+
+ if (activations && !force)
+ return 0;
+
+ init_completion(&usm_helper_data.wait_for_process);
+
+ suspend_send_netlink_message(&usm_helper_data,
+ USM_MSG_DISCONNECT,
+ NULL, 0);
+
+ wait_for_completion_timeout(&usm_helper_data.wait_for_process, 2*HZ);
+
+ if (!message_received || message_received == USM_MSG_FAILED) {
+ printk("Returning failure disconnecting storage.\n");
+ return 1;
+ }
+
+ return 0;
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
^ permalink raw reply [flat|nested] 14+ messages in thread* [Suspend2][ 04/13] [Suspend2] Utility function for testing storage managers.
2006-06-27 4:40 [Suspend2][ 00/13] Storage manager Nigel Cunningham
` (2 preceding siblings ...)
2006-06-27 4:40 ` [Suspend2][ 03/13] [Suspend2] Ask userspace to enable/disable access to our storage Nigel Cunningham
@ 2006-06-27 4:40 ` Nigel Cunningham
2006-06-27 4:40 ` [Suspend2][ 05/13] [Suspend2] Get storage manager space needed in image header Nigel Cunningham
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Nigel Cunningham @ 2006-06-27 4:40 UTC (permalink / raw)
To: linux-kernel
Provide a means whereby a developer (via a proc entry) can test a storage
manager. Invoke the prepare, activate, deactivate and cleanup routines in
that order.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/storage.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/kernel/power/storage.c b/kernel/power/storage.c
index 71b8c02..c007a8e 100644
--- a/kernel/power/storage.c
+++ b/kernel/power/storage.c
@@ -130,3 +130,21 @@ int suspend_deactivate_storage(int force
return 0;
}
+#ifdef CONFIG_PM_DEBUG
+static void storage_manager_simulate(void)
+{
+ printk("--- Storage manager simulate ---\n");
+ suspend_prepare_usm();
+ schedule();
+ printk("--- Activate storage 1 ---\n");
+ suspend_activate_storage(1);
+ schedule();
+ printk("--- Deactivate storage 1 ---\n");
+ suspend_deactivate_storage(1);
+ schedule();
+ printk("--- Cleanup usm ---\n");
+ suspend_cleanup_usm();
+ schedule();
+ printk("--- Storage manager simulate ends ---\n");
+}
+#endif
--
Nigel Cunningham nigel at suspend2 dot net
^ permalink raw reply [flat|nested] 14+ messages in thread* [Suspend2][ 05/13] [Suspend2] Get storage manager space needed in image header.
2006-06-27 4:40 [Suspend2][ 00/13] Storage manager Nigel Cunningham
` (3 preceding siblings ...)
2006-06-27 4:40 ` [Suspend2][ 04/13] [Suspend2] Utility function for testing storage managers Nigel Cunningham
@ 2006-06-27 4:40 ` Nigel Cunningham
2006-06-27 4:40 ` [Suspend2][ 06/13] [Suspend2] Serialise storage manager config in an " Nigel Cunningham
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Nigel Cunningham @ 2006-06-27 4:40 UTC (permalink / raw)
To: linux-kernel
Get the amount of space in the image header needed by the storage manager.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/storage.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/kernel/power/storage.c b/kernel/power/storage.c
index c007a8e..5fdcadd 100644
--- a/kernel/power/storage.c
+++ b/kernel/power/storage.c
@@ -148,3 +148,9 @@ static void storage_manager_simulate(voi
printk("--- Storage manager simulate ends ---\n");
}
#endif
+
+static unsigned long usm_storage_needed(void)
+{
+ return strlen(usm_helper_data.program);
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
^ permalink raw reply [flat|nested] 14+ messages in thread* [Suspend2][ 06/13] [Suspend2] Serialise storage manager config in an image header.
2006-06-27 4:40 [Suspend2][ 00/13] Storage manager Nigel Cunningham
` (4 preceding siblings ...)
2006-06-27 4:40 ` [Suspend2][ 05/13] [Suspend2] Get storage manager space needed in image header Nigel Cunningham
@ 2006-06-27 4:40 ` Nigel Cunningham
2006-06-27 4:40 ` [Suspend2][ 07/13] [Suspend2] Get the amount of memory needed by the storage manager Nigel Cunningham
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Nigel Cunningham @ 2006-06-27 4:40 UTC (permalink / raw)
To: linux-kernel
Routines to read and write the storage manager configuration.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/storage.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/kernel/power/storage.c b/kernel/power/storage.c
index 5fdcadd..714e95e 100644
--- a/kernel/power/storage.c
+++ b/kernel/power/storage.c
@@ -154,3 +154,19 @@ static unsigned long usm_storage_needed(
return strlen(usm_helper_data.program);
}
+static int usm_save_config_info(char *buf)
+{
+ int len = strlen(usm_helper_data.program);
+ memcpy(buf, usm_helper_data.program, len);
+ return len;
+}
+
+static void usm_load_config_info(char *buf, int size)
+{
+ /* Don't load the saved path if one has already been set */
+ if (usm_helper_data.program[0])
+ return;
+
+ memcpy(usm_helper_data.program, buf, size);
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
^ permalink raw reply [flat|nested] 14+ messages in thread* [Suspend2][ 07/13] [Suspend2] Get the amount of memory needed by the storage manager.
2006-06-27 4:40 [Suspend2][ 00/13] Storage manager Nigel Cunningham
` (5 preceding siblings ...)
2006-06-27 4:40 ` [Suspend2][ 06/13] [Suspend2] Serialise storage manager config in an " Nigel Cunningham
@ 2006-06-27 4:40 ` Nigel Cunningham
2006-06-27 4:40 ` [Suspend2][ 08/13] [Suspend2] Prepare and cleanup " Nigel Cunningham
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Nigel Cunningham @ 2006-06-27 4:40 UTC (permalink / raw)
To: linux-kernel
Get the amount of memory needed by the storage manager. Note that this is
just the storage needed while running, not the grand total.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/storage.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/kernel/power/storage.c b/kernel/power/storage.c
index 714e95e..e31623a 100644
--- a/kernel/power/storage.c
+++ b/kernel/power/storage.c
@@ -170,3 +170,9 @@ static void usm_load_config_info(char *b
memcpy(usm_helper_data.program, buf, size);
}
+static unsigned long usm_memory_needed(void)
+{
+ /* ball park figure of 32 pages */
+ return (32 * PAGE_SIZE);
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
^ permalink raw reply [flat|nested] 14+ messages in thread* [Suspend2][ 08/13] [Suspend2] Prepare and cleanup the storage manager.
2006-06-27 4:40 [Suspend2][ 00/13] Storage manager Nigel Cunningham
` (6 preceding siblings ...)
2006-06-27 4:40 ` [Suspend2][ 07/13] [Suspend2] Get the amount of memory needed by the storage manager Nigel Cunningham
@ 2006-06-27 4:40 ` Nigel Cunningham
2006-06-27 4:40 ` [Suspend2][ 09/13] [Suspend2] Manually activate/deactivate " Nigel Cunningham
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Nigel Cunningham @ 2006-06-27 4:40 UTC (permalink / raw)
To: linux-kernel
Start the storage manager at the beginning of a suspend/resume, and clean
it up at the end of a resume or cancelled suspend.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/storage.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/kernel/power/storage.c b/kernel/power/storage.c
index e31623a..fea9276 100644
--- a/kernel/power/storage.c
+++ b/kernel/power/storage.c
@@ -176,3 +176,50 @@ static unsigned long usm_memory_needed(v
return (32 * PAGE_SIZE);
}
+/* suspend_prepare_usm
+ */
+int suspend_prepare_usm(void)
+{
+ usm_prepare_count++;
+
+ if (usm_prepare_count > 1 || usm_ops.disabled)
+ return 0;
+
+ usm_helper_data.pid = -1;
+
+ if (!*usm_helper_data.program)
+ return 0;
+
+ suspend_netlink_setup(&usm_helper_data);
+
+ if (usm_helper_data.pid == -1)
+ printk("Suspend2 Storage Manager wanted, but couldn't start it.\n");
+
+ suspend_activate_storage(0);
+
+ return (usm_helper_data.pid != -1);
+}
+
+void suspend_cleanup_usm(void)
+{
+ usm_prepare_count--;
+
+ if (usm_helper_data.pid > -1 && !usm_prepare_count) {
+ struct task_struct *t;
+
+ suspend_deactivate_storage(0);
+
+ suspend_send_netlink_message(&usm_helper_data,
+ NETLINK_MSG_CLEANUP, NULL, 0);
+
+ read_lock(&tasklist_lock);
+ if ((t = find_task_by_pid(usm_helper_data.pid)))
+ t->flags &= ~PF_NOFREEZE;
+ read_unlock(&tasklist_lock);
+
+ suspend_netlink_close(&usm_helper_data);
+
+ usm_helper_data.pid = -1;
+ }
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
^ permalink raw reply [flat|nested] 14+ messages in thread* [Suspend2][ 09/13] [Suspend2] Manually activate/deactivate the storage manager.
2006-06-27 4:40 [Suspend2][ 00/13] Storage manager Nigel Cunningham
` (7 preceding siblings ...)
2006-06-27 4:40 ` [Suspend2][ 08/13] [Suspend2] Prepare and cleanup " Nigel Cunningham
@ 2006-06-27 4:40 ` Nigel Cunningham
2006-06-27 4:41 ` [Suspend2][ 10/13] [Suspend2] Storage manager proc entries Nigel Cunningham
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Nigel Cunningham @ 2006-06-27 4:40 UTC (permalink / raw)
To: linux-kernel
Provide (via a proc entry) a means whereby the user can manually activate
and deactivate the storage manager for test and configuration purposes.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/storage.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/kernel/power/storage.c b/kernel/power/storage.c
index fea9276..aa140ea 100644
--- a/kernel/power/storage.c
+++ b/kernel/power/storage.c
@@ -223,3 +223,16 @@ void suspend_cleanup_usm(void)
}
}
+static void storage_manager_activate(void)
+{
+ if (storage_manager_action == storage_manager_last_action)
+ return;
+
+ if (storage_manager_action)
+ suspend_prepare_usm();
+ else
+ suspend_cleanup_usm();
+
+ storage_manager_last_action = storage_manager_action;
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
^ permalink raw reply [flat|nested] 14+ messages in thread* [Suspend2][ 10/13] [Suspend2] Storage manager proc entries.
2006-06-27 4:40 [Suspend2][ 00/13] Storage manager Nigel Cunningham
` (8 preceding siblings ...)
2006-06-27 4:40 ` [Suspend2][ 09/13] [Suspend2] Manually activate/deactivate " Nigel Cunningham
@ 2006-06-27 4:41 ` Nigel Cunningham
2006-06-27 4:41 ` [Suspend2][ 11/13] [Suspend2] Storage manager module ops Nigel Cunningham
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Nigel Cunningham @ 2006-06-27 4:41 UTC (permalink / raw)
To: linux-kernel
Define the proc entries for the storage manager - there are entries for
disabling the manager, setting the program, manually activating and
simulating an atomic copy.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/storage.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/kernel/power/storage.c b/kernel/power/storage.c
index aa140ea..c8f85db 100644
--- a/kernel/power/storage.c
+++ b/kernel/power/storage.c
@@ -236,3 +236,51 @@ static void storage_manager_activate(voi
storage_manager_last_action = storage_manager_action;
}
+/*
+ * User interface specific /proc/suspend entries.
+ */
+
+static struct suspend_proc_data proc_params[] = {
+ { .filename = "disable_storage_manager",
+ .permissions = PROC_RW,
+ .type = SUSPEND_PROC_DATA_INTEGER,
+ .data = {
+ .integer = {
+ .variable = &usm_ops.disabled,
+ .minimum = 0,
+ .maximum = 1,
+ }
+ }
+ },
+ { .filename = "storage_manager",
+ .permissions = PROC_RW,
+ .type = SUSPEND_PROC_DATA_STRING,
+ .data = {
+ .string = {
+ .variable = usm_helper_data.program,
+ .max_length = 254,
+ }
+ }
+ },
+ { .filename = "activate_storage",
+ .permissions = PROC_RW,
+ .type = SUSPEND_PROC_DATA_INTEGER,
+ .data = {
+ .integer = {
+ .variable = &storage_manager_action,
+ .minimum = 0,
+ .maximum = 1,
+ }
+ },
+ .write_proc = storage_manager_activate,
+ },
+
+#ifdef CONFIG_PM_DEBUG
+ { .filename = "simulate_atomic_copy",
+ .permissions = PROC_RW,
+ .type = SUSPEND_PROC_DATA_NONE,
+ .write_proc = storage_manager_simulate,
+ }
+#endif
+};
+
--
Nigel Cunningham nigel at suspend2 dot net
^ permalink raw reply [flat|nested] 14+ messages in thread* [Suspend2][ 11/13] [Suspend2] Storage manager module ops.
2006-06-27 4:40 [Suspend2][ 00/13] Storage manager Nigel Cunningham
` (9 preceding siblings ...)
2006-06-27 4:41 ` [Suspend2][ 10/13] [Suspend2] Storage manager proc entries Nigel Cunningham
@ 2006-06-27 4:41 ` Nigel Cunningham
2006-06-27 4:41 ` [Suspend2][ 12/13] [Suspend2] Initialisation of the storage manager on load Nigel Cunningham
2006-06-27 4:41 ` [Suspend2][ 13/13] [Suspend2] Storage manager header file Nigel Cunningham
12 siblings, 0 replies; 14+ messages in thread
From: Nigel Cunningham @ 2006-06-27 4:41 UTC (permalink / raw)
To: linux-kernel
Define the operations that the core can use to access storage manager
functionality and data.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/storage.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/kernel/power/storage.c b/kernel/power/storage.c
index c8f85db..885501b 100644
--- a/kernel/power/storage.c
+++ b/kernel/power/storage.c
@@ -284,3 +284,13 @@ static struct suspend_proc_data proc_par
#endif
};
+static struct suspend_module_ops usm_ops = {
+ .type = MISC_MODULE,
+ .name = "Userspace Storage Manager",
+ .module = THIS_MODULE,
+ .storage_needed = usm_storage_needed,
+ .save_config_info = usm_save_config_info,
+ .load_config_info = usm_load_config_info,
+ .memory_needed = usm_memory_needed,
+};
+
--
Nigel Cunningham nigel at suspend2 dot net
^ permalink raw reply [flat|nested] 14+ messages in thread* [Suspend2][ 12/13] [Suspend2] Initialisation of the storage manager on load.
2006-06-27 4:40 [Suspend2][ 00/13] Storage manager Nigel Cunningham
` (10 preceding siblings ...)
2006-06-27 4:41 ` [Suspend2][ 11/13] [Suspend2] Storage manager module ops Nigel Cunningham
@ 2006-06-27 4:41 ` Nigel Cunningham
2006-06-27 4:41 ` [Suspend2][ 13/13] [Suspend2] Storage manager header file Nigel Cunningham
12 siblings, 0 replies; 14+ messages in thread
From: Nigel Cunningham @ 2006-06-27 4:41 UTC (permalink / raw)
To: linux-kernel
Register the proc entries for the storage manager and set up the netlink
data structure when loaded.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/storage.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/kernel/power/storage.c b/kernel/power/storage.c
index 885501b..bdb2993 100644
--- a/kernel/power/storage.c
+++ b/kernel/power/storage.c
@@ -294,3 +294,30 @@ static struct suspend_module_ops usm_ops
.memory_needed = usm_memory_needed,
};
+/* suspend_usm_proc_init
+ * Description: Boot time initialisation for user interface.
+ */
+static __init int suspend_usm_proc_init(void)
+{
+ int result, i, numfiles = sizeof(proc_params) / sizeof(struct suspend_proc_data);
+
+ if (!(result = suspend_register_module(&usm_ops)))
+ for (i=0; i< numfiles; i++)
+ suspend_register_procfile(&proc_params[i]);
+
+ usm_helper_data.nl = NULL;
+ usm_helper_data.program[0] = '\0';
+ usm_helper_data.pid = -1;
+ usm_helper_data.skb_size = 0;
+ usm_helper_data.pool_limit = 6;
+ usm_helper_data.netlink_id = NETLINK_SUSPEND2_USM;
+ usm_helper_data.name = "userspace storage manager";
+ usm_helper_data.rcv_msg = usm_user_rcv_msg;
+ usm_helper_data.interface_version = 1;
+ usm_helper_data.must_init = 0;
+ init_completion(&usm_helper_data.wait_for_process);
+
+ return result;
+}
+
+late_initcall(suspend_usm_proc_init);
--
Nigel Cunningham nigel at suspend2 dot net
^ permalink raw reply [flat|nested] 14+ messages in thread* [Suspend2][ 13/13] [Suspend2] Storage manager header file.
2006-06-27 4:40 [Suspend2][ 00/13] Storage manager Nigel Cunningham
` (11 preceding siblings ...)
2006-06-27 4:41 ` [Suspend2][ 12/13] [Suspend2] Initialisation of the storage manager on load Nigel Cunningham
@ 2006-06-27 4:41 ` Nigel Cunningham
12 siblings, 0 replies; 14+ messages in thread
From: Nigel Cunningham @ 2006-06-27 4:41 UTC (permalink / raw)
To: linux-kernel
The header file for the storage manager, which defines the message numbers
used by it, and the functions accessible via proc entries.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/storage.h | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/kernel/power/storage.h b/kernel/power/storage.h
new file mode 100644
index 0000000..9039dcc
--- /dev/null
+++ b/kernel/power/storage.h
@@ -0,0 +1,37 @@
+/*
+ * kernel/power/storage.h
+ *
+ * Copyright (C) 2005-2006 Nigel Cunningham <nigel@suspend2.net>
+ *
+ * This file is released under the GPLv2.
+ */
+
+int suspend_prepare_usm(void);
+void suspend_cleanup_usm(void);
+
+#ifdef CONFIG_NET
+int suspend_activate_storage(int force);
+int suspend_deactivate_storage(int force);
+#else
+static inline int suspend_activate_storage(int force)
+{
+ return 0;
+}
+
+static inline int suspend_deactivate_storage(int force)
+{
+ return 0;
+}
+#endif
+
+enum {
+ USM_MSG_BASE = 0x10,
+
+ /* Kernel -> Userspace */
+ USM_MSG_CONNECT = 0x30,
+ USM_MSG_DISCONNECT = 0x31,
+ USM_MSG_SUCCESS = 0x40,
+ USM_MSG_FAILED = 0x41,
+
+ USM_MSG_MAX,
+};
--
Nigel Cunningham nigel at suspend2 dot net
^ permalink raw reply [flat|nested] 14+ messages in thread