2 * kernel/power/tuxonice_cluster.c
4 * Copyright (C) 2006-2007 Nigel Cunningham (nigel at suspend2 net)
6 * This file is released under the GPLv2.
8 * This file contains routines for cluster hibernation support.
12 #include <linux/suspend.h>
13 #include <linux/module.h>
16 #include "tuxonice_modules.h"
17 #include "tuxonice_sysfs.h"
18 #include "tuxonice_io.h"
20 static char toi_cluster_master
[63] = CONFIG_TOI_DEFAULT_CLUSTER_MASTER
;
22 static struct toi_module_ops toi_cluster_ops
;
24 /* toi_cluster_print_debug_stats
26 * Description: Print information to be recorded for debugging purposes into a
28 * Arguments: buffer: Pointer to a buffer into which the debug info will be
30 * size: Size of the buffer.
31 * Returns: Number of characters written to the buffer.
33 static int toi_cluster_print_debug_stats(char *buffer
, int size
)
37 if (strlen(toi_cluster_master
))
38 len
= snprintf_used(buffer
, size
, "- Cluster master is '%s'.\n",
41 len
= snprintf_used(buffer
, size
, "- Cluster support is disabled.\n");
45 /* cluster_memory_needed
47 * Description: Tell the caller how much memory we need to operate during
49 * Returns: Unsigned long. Maximum number of bytes of memory required for
52 static int toi_cluster_memory_needed(void)
57 static int toi_cluster_storage_needed(void)
59 return 1 + strlen(toi_cluster_master
);
62 /* toi_cluster_save_config_info
64 * Description: Save informaton needed when reloading the image at resume time.
65 * Arguments: Buffer: Pointer to a buffer of size PAGE_SIZE.
66 * Returns: Number of bytes used for saving our data.
68 static int toi_cluster_save_config_info(char *buffer
)
70 strcpy(buffer
, toi_cluster_master
);
71 return strlen(toi_cluster_master
+ 1);
74 /* toi_cluster_load_config_info
76 * Description: Reload information needed for declustering the image at
78 * Arguments: Buffer: Pointer to the start of the data.
79 * Size: Number of bytes that were saved.
81 static void toi_cluster_load_config_info(char *buffer
, int size
)
83 strncpy(toi_cluster_master
, buffer
, size
);
88 * data for our sysfs entries.
90 static struct toi_sysfs_data sysfs_params
[] = {
92 TOI_ATTR("master", SYSFS_RW
),
93 SYSFS_STRING(toi_cluster_master
, 63, SYSFS_SM_NOT_NEEDED
)
97 TOI_ATTR("enabled", SYSFS_RW
),
98 SYSFS_INT(&toi_cluster_ops
.enabled
, 0, 1)
106 static struct toi_module_ops toi_cluster_ops
= {
107 .type
= FILTER_MODULE
,
109 .directory
= "cluster",
110 .module
= THIS_MODULE
,
111 .memory_needed
= toi_cluster_memory_needed
,
112 .print_debug_info
= toi_cluster_print_debug_stats
,
113 .save_config_info
= toi_cluster_save_config_info
,
114 .load_config_info
= toi_cluster_load_config_info
,
115 .storage_needed
= toi_cluster_storage_needed
,
117 .sysfs_data
= sysfs_params
,
118 .num_sysfs_entries
= sizeof(sysfs_params
) / sizeof(struct toi_sysfs_data
),
121 /* ---- Registration ---- */
125 #define INIT static __init
126 #define EXIT static __exit
132 INIT
int toi_cluster_init(void)
134 int temp
= toi_register_module(&toi_cluster_ops
);
136 if (!strlen(toi_cluster_master
))
137 toi_cluster_ops
.enabled
= 0;
141 EXIT
void toi_cluster_exit(void)
143 toi_unregister_module(&toi_cluster_ops
);
147 MODULE_LICENSE("GPL");
148 module_init(toi_cluster_init
);
149 module_exit(toi_cluster_exit
);
150 MODULE_AUTHOR("Nigel Cunningham");
151 MODULE_DESCRIPTION("Cluster Support for TuxOnIce");