--- kerneld.h.org	Sat Nov 29 19:33:21 1997
+++ kerneld.h	Tue Feb 17 17:31:11 1998
@@ -9,6 +9,8 @@
 #define KERNELD_REQUEST_ROUTE 6 /* from net/ipv4/route.c */
 #define KERNELD_BLANKER 7 /* from drivers/char/console.c */
 #define KERNELD_PNP 8 /* from drivers/pnp/kerneld.c */
+#define KERNELD_GET_PERSIST 200 /* persistent module storage */
+#define KERNELD_SET_PERSIST 201 /* persistent module storage */
 #define KERNELD_ARP 256 /* from net/ipv4/arp.c */
 
 /*
@@ -47,7 +49,16 @@
 #endif /* __KERNEL__ */
 };
 
+struct __persist {
+       int keylen;
+       int arglen;
+       char arr[0];
+};
+
 #ifdef __KERNEL__
+#include <linux/malloc.h>
+
 extern int kerneld_send(int msgtype, int ret_size, int msgsz,
 		const char *text, const char *ret_val);
 
@@ -126,6 +137,49 @@
 	return kerneld_send(KERNELD_BLANKER,
 			0 | (on_off?KERNELD_NOWAIT:KERNELD_WAIT),
 			strlen(on_off?"on":"off"), on_off?"on":"off", NULL);
+}
+
+/*
+ * Persistent storage for modules
+ *
+ * Usage:
+ *     int get_persist("a key", &value, sizeof(value));
+ *             Returns > 0 on success (return value == returned size)
+ *
+ *     int set_persist("a key", &value, sizeof(value));
+ *             Returns < 0 on failure
+ *
+ * To remove an entry, use: "set_persist("a key", NULL, 0);"
+ */
+
+static inline int set_persist(char *key, void *value, size_t length)
+{
+       struct __persist *p;
+       int keylen = strlen(key) + 1;
+       int structsize = keylen + length + sizeof(struct __persist);
+       int status;
+
+       if ((p = (struct __persist *)kmalloc(structsize, GFP_ATOMIC)) == NULL)
+               return -ENOMEM;
+       strcpy(p->arr, key);
+       p->keylen = keylen;
+       p->arglen = length;
+       if (length)
+               memcpy(p->arr + keylen, value, length);
+
+       status = kerneld_send(KERNELD_SET_PERSIST,
+                       0 | KERNELD_NOWAIT,
+                       structsize, (char *)p, NULL);
+
+       kfree(p);
+       return status;
+}
+
+static inline int get_persist(char *key, void *value, size_t length)
+{
+       return kerneld_send(KERNELD_GET_PERSIST,
+                       length | KERNELD_WAIT,
+                       strlen(key), key, value);
 }
 
 #endif /* __KERNEL__ */
