Blame SOURCES/0227-Add-new-proc-filesystem-framework-and-put-luks_scrip.patch

f96e0b
From f18b04893c6f40415fb577a286982a3046fcecd2 Mon Sep 17 00:00:00 2001
f96e0b
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
f96e0b
Date: Sun, 24 Mar 2013 13:05:59 +0100
f96e0b
Subject: [PATCH 227/482] 	Add new 'proc' filesystem framework and put
f96e0b
 luks_script into it.
f96e0b
f96e0b
---
f96e0b
 ChangeLog                   |   4 ++
f96e0b
 Makefile.util.def           |   1 +
f96e0b
 grub-core/Makefile.core.def |   5 ++
f96e0b
 grub-core/disk/cryptodisk.c | 113 +++++++++++++++++++++++++++++
f96e0b
 grub-core/disk/geli.c       |   2 -
f96e0b
 grub-core/disk/luks.c       |   2 -
f96e0b
 grub-core/fs/proc.c         | 172 ++++++++++++++++++++++++++++++++++++++++++++
f96e0b
 include/grub/cryptodisk.h   |   5 +-
f96e0b
 include/grub/disk.h         |   1 +
f96e0b
 include/grub/procfs.h       |  50 +++++++++++++
f96e0b
 10 files changed, 350 insertions(+), 5 deletions(-)
f96e0b
 create mode 100644 grub-core/fs/proc.c
f96e0b
 create mode 100644 include/grub/procfs.h
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index 9841659..8f3878d 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,3 +1,7 @@
f96e0b
+2013-03-24  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
+
f96e0b
+	Add new 'proc' filesystem framework and put luks_script into it.
f96e0b
+
f96e0b
 2013-03-23  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
 
f96e0b
 	* grub-core/term/at_keyboard.c: Increase robustness on coreboot
f96e0b
diff --git a/Makefile.util.def b/Makefile.util.def
f96e0b
index 1ccf390..62bcf2d 100644
f96e0b
--- a/Makefile.util.def
f96e0b
+++ b/Makefile.util.def
f96e0b
@@ -33,6 +33,7 @@ library = {
f96e0b
   common = grub-core/disk/diskfilter.c;
f96e0b
   common = grub-core/partmap/gpt.c;
f96e0b
   common = grub-core/partmap/msdos.c;
f96e0b
+  common = grub-core/fs/proc.c;
f96e0b
 };
f96e0b
 
f96e0b
 library = {
f96e0b
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
f96e0b
index a614b22..b1c1ab9 100644
f96e0b
--- a/grub-core/Makefile.core.def
f96e0b
+++ b/grub-core/Makefile.core.def
f96e0b
@@ -1068,6 +1068,11 @@ module = {
f96e0b
 };
f96e0b
 
f96e0b
 module = {
f96e0b
+  name = procfs;
f96e0b
+  common = fs/proc.c;
f96e0b
+};
f96e0b
+
f96e0b
+module = {
f96e0b
   name = affs;
f96e0b
   common = fs/affs.c;
f96e0b
 };
f96e0b
diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c
f96e0b
index f39c1ab..374edd1 100644
f96e0b
--- a/grub-core/disk/cryptodisk.c
f96e0b
+++ b/grub-core/disk/cryptodisk.c
f96e0b
@@ -22,6 +22,9 @@
f96e0b
 #include <grub/dl.h>
f96e0b
 #include <grub/extcmd.h>
f96e0b
 #include <grub/i18n.h>
f96e0b
+#include <grub/fs.h>
f96e0b
+#include <grub/file.h>
f96e0b
+#include <grub/procfs.h>
f96e0b
 
f96e0b
 #ifdef GRUB_UTIL
f96e0b
 #include <errno.h>
f96e0b
@@ -403,6 +406,8 @@ grub_cryptodisk_setkey (grub_cryptodisk_t dev, grub_uint8_t *key, grub_size_t ke
f96e0b
   err = grub_crypto_cipher_set_key (dev->cipher, key, real_keysize);
f96e0b
   if (err)
f96e0b
     return err;
f96e0b
+  grub_memcpy (dev->key, key, keysize);
f96e0b
+  dev->keysize = keysize;
f96e0b
 
f96e0b
   /* Configure ESSIV if necessary.  */
f96e0b
   if (dev->mode_iv == GRUB_CRYPTODISK_MODE_IV_ESSIV)
f96e0b
@@ -979,6 +984,112 @@ static struct grub_disk_dev grub_cryptodisk_dev = {
f96e0b
   .next = 0
f96e0b
 };
f96e0b
 
f96e0b
+static char
f96e0b
+hex (grub_uint8_t val)
f96e0b
+{
f96e0b
+  if (val < 10)
f96e0b
+    return '0' + val;
f96e0b
+  return 'a' + val - 10;
f96e0b
+}
f96e0b
+
f96e0b
+/* Open a file named NAME and initialize FILE.  */
f96e0b
+static char *
f96e0b
+luks_script_get (void)
f96e0b
+{
f96e0b
+  grub_cryptodisk_t i;
f96e0b
+  grub_size_t size = 0;
f96e0b
+  char *ptr, *ret;
f96e0b
+
f96e0b
+  for (i = cryptodisk_list; i != NULL; i = i->next)
f96e0b
+    if (grub_strcmp (i->modname, "luks") == 0)
f96e0b
+      {
f96e0b
+	size += sizeof ("luks_mount ");
f96e0b
+	size += grub_strlen (i->uuid);
f96e0b
+	size += grub_strlen (i->cipher->cipher->name);
f96e0b
+	size += 54;
f96e0b
+	if (i->essiv_hash)
f96e0b
+	  size += grub_strlen (i->essiv_hash->name);
f96e0b
+	size += i->keysize * 2;
f96e0b
+      }
f96e0b
+
f96e0b
+  ret = grub_malloc (size + 1);
f96e0b
+  if (!ret)
f96e0b
+    return 0;
f96e0b
+
f96e0b
+  ptr = ret;
f96e0b
+
f96e0b
+  for (i = cryptodisk_list; i != NULL; i = i->next)
f96e0b
+    if (grub_strcmp (i->modname, "luks") == 0)
f96e0b
+      {
f96e0b
+	unsigned j;
f96e0b
+	const char *iptr;
f96e0b
+	ptr = grub_stpcpy (ptr, "luks_mount ");
f96e0b
+	ptr = grub_stpcpy (ptr, i->uuid);
f96e0b
+	*ptr++ = ' ';
f96e0b
+	grub_snprintf (ptr, 21, "%" PRIuGRUB_UINT64_T " ", i->offset);
f96e0b
+	while (*ptr)
f96e0b
+	  ptr++;
f96e0b
+	for (iptr = i->cipher->cipher->name; *iptr; iptr++)
f96e0b
+	  *ptr++ = grub_tolower (*iptr);
f96e0b
+	switch (i->mode)
f96e0b
+	  {
f96e0b
+	  case GRUB_CRYPTODISK_MODE_ECB:
f96e0b
+	    ptr = grub_stpcpy (ptr, "-ecb"); 
f96e0b
+	    break;
f96e0b
+	  case GRUB_CRYPTODISK_MODE_CBC:
f96e0b
+	    ptr = grub_stpcpy (ptr, "-cbc");
f96e0b
+	    break;
f96e0b
+	  case GRUB_CRYPTODISK_MODE_PCBC:
f96e0b
+	    ptr = grub_stpcpy (ptr, "-pcbc");
f96e0b
+	    break;
f96e0b
+	  case GRUB_CRYPTODISK_MODE_XTS:
f96e0b
+	    ptr = grub_stpcpy (ptr, "-xts");
f96e0b
+	    break;
f96e0b
+	  case GRUB_CRYPTODISK_MODE_LRW:
f96e0b
+	    ptr = grub_stpcpy (ptr, "-lrw");
f96e0b
+	    break;
f96e0b
+	  }
f96e0b
+
f96e0b
+	switch (i->mode_iv)
f96e0b
+	  {
f96e0b
+	  case GRUB_CRYPTODISK_MODE_IV_NULL:
f96e0b
+	    ptr = grub_stpcpy (ptr, "-null"); 
f96e0b
+	    break;
f96e0b
+	  case GRUB_CRYPTODISK_MODE_IV_PLAIN:
f96e0b
+	    ptr = grub_stpcpy (ptr, "-plain"); 
f96e0b
+	    break;
f96e0b
+	  case GRUB_CRYPTODISK_MODE_IV_PLAIN64:
f96e0b
+	    ptr = grub_stpcpy (ptr, "-plain64"); 
f96e0b
+	    break;
f96e0b
+	  case GRUB_CRYPTODISK_MODE_IV_BENBI:
f96e0b
+	    ptr = grub_stpcpy (ptr, "-benbi"); 
f96e0b
+	    break;
f96e0b
+	  case GRUB_CRYPTODISK_MODE_IV_ESSIV:
f96e0b
+	    ptr = grub_stpcpy (ptr, "-essiv:"); 
f96e0b
+	    ptr = grub_stpcpy (ptr, i->essiv_hash->name);
f96e0b
+	    break;
f96e0b
+	  case GRUB_CRYPTODISK_MODE_IV_BYTECOUNT64:
f96e0b
+	  case GRUB_CRYPTODISK_MODE_IV_BYTECOUNT64_HASH:
f96e0b
+	    break;
f96e0b
+	  }
f96e0b
+	*ptr++ = ' ';
f96e0b
+	for (j = 0; j < i->keysize; j++)
f96e0b
+	  {
f96e0b
+	    *ptr++ = hex (i->key[j] >> 4);
f96e0b
+	    *ptr++ = hex (i->key[j] & 0xf);
f96e0b
+	  }
f96e0b
+	*ptr++ = '\n';
f96e0b
+      }
f96e0b
+  *ptr = '\0';
f96e0b
+  return ret;
f96e0b
+}
f96e0b
+
f96e0b
+struct grub_procfs_entry luks_script =
f96e0b
+{
f96e0b
+  .name = "luks_script",
f96e0b
+  .get_contents = luks_script_get
f96e0b
+};
f96e0b
+
f96e0b
 static grub_extcmd_t cmd;
f96e0b
 
f96e0b
 GRUB_MOD_INIT (cryptodisk)
f96e0b
@@ -987,10 +1098,12 @@ GRUB_MOD_INIT (cryptodisk)
f96e0b
   cmd = grub_register_extcmd ("cryptomount", grub_cmd_cryptomount, 0,
f96e0b
 			      N_("SOURCE|-u UUID|-a|-b"),
f96e0b
 			      N_("Mount a crypto device."), options);
f96e0b
+  grub_procfs_register ("luks_script", &luks_script);
f96e0b
 }
f96e0b
 
f96e0b
 GRUB_MOD_FINI (cryptodisk)
f96e0b
 {
f96e0b
   grub_disk_dev_unregister (&grub_cryptodisk_dev);
f96e0b
   cryptodisk_cleanup ();
f96e0b
+  grub_procfs_unregister (&luks_script);
f96e0b
 }
f96e0b
diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c
f96e0b
index f9315df..0b94414 100644
f96e0b
--- a/grub-core/disk/geli.c
f96e0b
+++ b/grub-core/disk/geli.c
f96e0b
@@ -381,9 +381,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
f96e0b
       newdev->rekey_shift = 20;
f96e0b
     }
f96e0b
 
f96e0b
-#ifdef GRUB_UTIL
f96e0b
   newdev->modname = "geli";
f96e0b
-#endif
f96e0b
 
f96e0b
   newdev->total_length = grub_disk_get_size (disk) - 1;
f96e0b
   grub_memcpy (newdev->uuid, uuid, sizeof (newdev->uuid));
f96e0b
diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c
f96e0b
index 44f3cac..afcb7e4 100644
f96e0b
--- a/grub-core/disk/luks.c
f96e0b
+++ b/grub-core/disk/luks.c
f96e0b
@@ -290,9 +290,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
f96e0b
   newdev->log_sector_size = 9;
f96e0b
   newdev->total_length = grub_disk_get_size (disk) - newdev->offset;
f96e0b
   grub_memcpy (newdev->uuid, uuid, sizeof (newdev->uuid));
f96e0b
-#ifdef GRUB_UTIL
f96e0b
   newdev->modname = "luks";
f96e0b
-#endif
f96e0b
   COMPILE_TIME_ASSERT (sizeof (newdev->uuid) >= sizeof (uuid));
f96e0b
   return newdev;
f96e0b
 }
f96e0b
diff --git a/grub-core/fs/proc.c b/grub-core/fs/proc.c
f96e0b
new file mode 100644
f96e0b
index 0000000..8f27682
f96e0b
--- /dev/null
f96e0b
+++ b/grub-core/fs/proc.c
f96e0b
@@ -0,0 +1,172 @@
f96e0b
+/*
f96e0b
+ *  GRUB  --  GRand Unified Bootloader
f96e0b
+ *  Copyright (C) 2013  Free Software Foundation, Inc.
f96e0b
+ *
f96e0b
+ *  GRUB is free software: you can redistribute it and/or modify
f96e0b
+ *  it under the terms of the GNU General Public License as published by
f96e0b
+ *  the Free Software Foundation, either version 3 of the License, or
f96e0b
+ *  (at your option) any later version.
f96e0b
+ *
f96e0b
+ *  GRUB is distributed in the hope that it will be useful,
f96e0b
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
f96e0b
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f96e0b
+ *  GNU General Public License for more details.
f96e0b
+ *
f96e0b
+ *  You should have received a copy of the GNU General Public License
f96e0b
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
f96e0b
+ */
f96e0b
+
f96e0b
+#include <grub/procfs.h>
f96e0b
+#include <grub/disk.h>
f96e0b
+#include <grub/fs.h>
f96e0b
+#include <grub/file.h>
f96e0b
+#include <grub/mm.h>
f96e0b
+#include <grub/dl.h>
f96e0b
+
f96e0b
+GRUB_MOD_LICENSE ("GPLv3+");
f96e0b
+
f96e0b
+struct grub_procfs_entry *grub_procfs_entries;
f96e0b
+
f96e0b
+static int
f96e0b
+grub_procdev_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
f96e0b
+			 grub_disk_pull_t pull)
f96e0b
+{
f96e0b
+  if (pull != GRUB_DISK_PULL_NONE)
f96e0b
+    return 0;
f96e0b
+
f96e0b
+  return hook ("proc", hook_data);
f96e0b
+}
f96e0b
+
f96e0b
+static grub_err_t
f96e0b
+grub_procdev_open (const char *name, grub_disk_t disk)
f96e0b
+{
f96e0b
+  if (grub_strcmp (name, "proc"))
f96e0b
+      return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a procfs disk");
f96e0b
+
f96e0b
+  disk->total_sectors = 0;
f96e0b
+  disk->id = (unsigned long) "proc";
f96e0b
+
f96e0b
+  disk->data = 0;
f96e0b
+
f96e0b
+  return GRUB_ERR_NONE;
f96e0b
+}
f96e0b
+
f96e0b
+static void
f96e0b
+grub_procdev_close (grub_disk_t disk __attribute((unused)))
f96e0b
+{
f96e0b
+}
f96e0b
+
f96e0b
+static grub_err_t
f96e0b
+grub_procdev_read (grub_disk_t disk __attribute((unused)),
f96e0b
+		grub_disk_addr_t sector __attribute((unused)),
f96e0b
+		grub_size_t size __attribute((unused)),
f96e0b
+		char *buf __attribute((unused)))
f96e0b
+{
f96e0b
+  return GRUB_ERR_OUT_OF_RANGE;
f96e0b
+}
f96e0b
+
f96e0b
+static grub_err_t
f96e0b
+grub_procdev_write (grub_disk_t disk __attribute ((unused)),
f96e0b
+		       grub_disk_addr_t sector __attribute ((unused)),
f96e0b
+		       grub_size_t size __attribute ((unused)),
f96e0b
+		       const char *buf __attribute ((unused)))
f96e0b
+{
f96e0b
+  return GRUB_ERR_OUT_OF_RANGE;
f96e0b
+}
f96e0b
+
f96e0b
+static grub_ssize_t
f96e0b
+grub_procfs_read (grub_file_t file, char *buf, grub_size_t len)
f96e0b
+{
f96e0b
+  char *data = file->data;
f96e0b
+
f96e0b
+  grub_memcpy (buf, data + file->offset, len);
f96e0b
+
f96e0b
+  return len;
f96e0b
+}
f96e0b
+
f96e0b
+static grub_err_t
f96e0b
+grub_procfs_close (grub_file_t file)
f96e0b
+{
f96e0b
+  char *data;
f96e0b
+
f96e0b
+  data = file->data;
f96e0b
+  grub_free (data);
f96e0b
+
f96e0b
+  return GRUB_ERR_NONE;
f96e0b
+}
f96e0b
+
f96e0b
+static grub_err_t
f96e0b
+grub_procfs_dir (grub_device_t device, const char *path,
f96e0b
+		 grub_fs_dir_hook_t hook, void *hook_data)
f96e0b
+{
f96e0b
+  const char *ptr;
f96e0b
+  struct grub_dirhook_info info;
f96e0b
+  struct grub_procfs_entry *entry;
f96e0b
+
f96e0b
+  grub_memset (&info, 0, sizeof (info));
f96e0b
+
f96e0b
+  /* Check if the disk is our dummy disk.  */
f96e0b
+  if (grub_strcmp (device->disk->name, "proc"))
f96e0b
+    return grub_error (GRUB_ERR_BAD_FS, "not a procfs");
f96e0b
+  for (ptr = path; *ptr == '/'; ptr++);
f96e0b
+  if (*ptr)
f96e0b
+    return 0;
f96e0b
+  FOR_LIST_ELEMENTS((entry), (grub_procfs_entries))
f96e0b
+    if (hook (entry->name, &info, hook_data))
f96e0b
+      return 0;
f96e0b
+  return 0;
f96e0b
+}
f96e0b
+
f96e0b
+static grub_err_t
f96e0b
+grub_procfs_open (struct grub_file *file, const char *path)
f96e0b
+{
f96e0b
+  const char *pathptr;
f96e0b
+  struct grub_procfs_entry *entry;
f96e0b
+
f96e0b
+  for (pathptr = path; *pathptr == '/'; pathptr++);
f96e0b
+
f96e0b
+  FOR_LIST_ELEMENTS((entry), (grub_procfs_entries))
f96e0b
+    if (grub_strcmp (pathptr, entry->name) == 0)
f96e0b
+    {
f96e0b
+      file->data = entry->get_contents ();
f96e0b
+      if (!file->data)
f96e0b
+	return grub_errno;
f96e0b
+      file->size = grub_strlen (file->data);
f96e0b
+      return GRUB_ERR_NONE;
f96e0b
+    }
f96e0b
+
f96e0b
+  return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path);
f96e0b
+}
f96e0b
+
f96e0b
+static struct grub_disk_dev grub_procfs_dev = {
f96e0b
+  .name = "proc",
f96e0b
+  .id = GRUB_DISK_DEVICE_PROCFS_ID,
f96e0b
+  .iterate = grub_procdev_iterate,
f96e0b
+  .open = grub_procdev_open,
f96e0b
+  .close = grub_procdev_close,
f96e0b
+  .read = grub_procdev_read,
f96e0b
+  .write = grub_procdev_write,
f96e0b
+  .next = 0
f96e0b
+};
f96e0b
+
f96e0b
+static struct grub_fs grub_procfs_fs =
f96e0b
+  {
f96e0b
+    .name = "procfs",
f96e0b
+    .dir = grub_procfs_dir,
f96e0b
+    .open = grub_procfs_open,
f96e0b
+    .read = grub_procfs_read,
f96e0b
+    .close = grub_procfs_close,
f96e0b
+    .next = 0
f96e0b
+  };
f96e0b
+
f96e0b
+GRUB_MOD_INIT (procfs)
f96e0b
+{
f96e0b
+  grub_disk_dev_register (&grub_procfs_dev);
f96e0b
+  grub_fs_register (&grub_procfs_fs);
f96e0b
+}
f96e0b
+
f96e0b
+GRUB_MOD_FINI (procfs)
f96e0b
+{
f96e0b
+  grub_disk_dev_unregister (&grub_procfs_dev);
f96e0b
+  grub_fs_unregister (&grub_procfs_fs);
f96e0b
+}
f96e0b
diff --git a/include/grub/cryptodisk.h b/include/grub/cryptodisk.h
f96e0b
index 0bb5d44..c3ee820 100644
f96e0b
--- a/include/grub/cryptodisk.h
f96e0b
+++ b/include/grub/cryptodisk.h
f96e0b
@@ -49,6 +49,7 @@ typedef enum
f96e0b
 #define GRUB_CRYPTODISK_GF_SIZE (1U << GRUB_CRYPTODISK_GF_LOG_SIZE)
f96e0b
 #define GRUB_CRYPTODISK_GF_LOG_BYTES (GRUB_CRYPTODISK_GF_LOG_SIZE - 3)
f96e0b
 #define GRUB_CRYPTODISK_GF_BYTES (1U << GRUB_CRYPTODISK_GF_LOG_BYTES)
f96e0b
+#define GRUB_CRYPTODISK_MAX_KEYLEN 128
f96e0b
 
f96e0b
 struct grub_cryptodisk;
f96e0b
 
f96e0b
@@ -80,11 +81,13 @@ struct grub_cryptodisk
f96e0b
   grub_uint8_t *lrw_precalc;
f96e0b
   grub_uint8_t iv_prefix[64];
f96e0b
   grub_size_t iv_prefix_len;
f96e0b
+  grub_uint8_t key[GRUB_CRYPTODISK_MAX_KEYLEN];
f96e0b
+  grub_size_t keysize;
f96e0b
 #ifdef GRUB_UTIL
f96e0b
   char *cheat;
f96e0b
-  const char *modname;
f96e0b
   int cheat_fd;
f96e0b
 #endif
f96e0b
+  const char *modname;
f96e0b
   int log_sector_size;
f96e0b
   grub_cryptodisk_rekey_func_t rekey;
f96e0b
   int rekey_shift;
f96e0b
diff --git a/include/grub/disk.h b/include/grub/disk.h
f96e0b
index f0e3df3..d19b1ac 100644
f96e0b
--- a/include/grub/disk.h
f96e0b
+++ b/include/grub/disk.h
f96e0b
@@ -43,6 +43,7 @@ enum grub_disk_dev_id
f96e0b
     GRUB_DISK_DEVICE_CRYPTODISK_ID,
f96e0b
     GRUB_DISK_DEVICE_ARCDISK_ID,
f96e0b
     GRUB_DISK_DEVICE_HOSTDISK_ID,
f96e0b
+    GRUB_DISK_DEVICE_PROCFS_ID,
f96e0b
   };
f96e0b
 
f96e0b
 struct grub_disk;
f96e0b
diff --git a/include/grub/procfs.h b/include/grub/procfs.h
f96e0b
new file mode 100644
f96e0b
index 0000000..55cbb21
f96e0b
--- /dev/null
f96e0b
+++ b/include/grub/procfs.h
f96e0b
@@ -0,0 +1,50 @@
f96e0b
+/*
f96e0b
+ *  GRUB  --  GRand Unified Bootloader
f96e0b
+ *  Copyright (C) 2013  Free Software Foundation, Inc.
f96e0b
+ *
f96e0b
+ *  GRUB is free software: you can redistribute it and/or modify
f96e0b
+ *  it under the terms of the GNU General Public License as published by
f96e0b
+ *  the Free Software Foundation, either version 3 of the License, or
f96e0b
+ *  (at your option) any later version.
f96e0b
+ *
f96e0b
+ *  GRUB is distributed in the hope that it will be useful,
f96e0b
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
f96e0b
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f96e0b
+ *  GNU General Public License for more details.
f96e0b
+ *
f96e0b
+ *  You should have received a copy of the GNU General Public License
f96e0b
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
f96e0b
+ */
f96e0b
+
f96e0b
+#ifndef GRUB_PROCFS_HEADER
f96e0b
+#define GRUB_PROCFS_HEADER	1
f96e0b
+
f96e0b
+#include <grub/list.h>
f96e0b
+
f96e0b
+struct grub_procfs_entry
f96e0b
+{
f96e0b
+  struct grub_procfs_entry *next;
f96e0b
+  struct grub_procfs_entry **prev;
f96e0b
+
f96e0b
+  const char *name;
f96e0b
+  char * (*get_contents) (void);
f96e0b
+};
f96e0b
+
f96e0b
+extern struct grub_procfs_entry *grub_procfs_entries;
f96e0b
+
f96e0b
+static inline void
f96e0b
+grub_procfs_register (const char *name __attribute__ ((unused)),
f96e0b
+		      struct grub_procfs_entry *entry)
f96e0b
+{
f96e0b
+  grub_list_push (GRUB_AS_LIST_P (&grub_procfs_entries),
f96e0b
+		  GRUB_AS_LIST (entry));
f96e0b
+}
f96e0b
+
f96e0b
+static inline void
f96e0b
+grub_procfs_unregister (struct grub_procfs_entry *entry)
f96e0b
+{
f96e0b
+  grub_list_remove (GRUB_AS_LIST (entry));
f96e0b
+}
f96e0b
+
f96e0b
+
f96e0b
+#endif
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b