summaryrefslogtreecommitdiff
path: root/debian/patches/procfs-filesystems.patch
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-09-18 19:42:48 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-09-18 19:42:48 +0200
commitb7113d9415adac4af81dfd4b95c8ac8a0eef0e17 (patch)
treecefb8abd4b14d6c48eaf89e84a01d9a5f0b4a9b4 /debian/patches/procfs-filesystems.patch
parentbb117ef9f4cda28758f68b6464fd8aa19a5bacf5 (diff)
add procfs-filesystems.patch
Diffstat (limited to 'debian/patches/procfs-filesystems.patch')
-rw-r--r--debian/patches/procfs-filesystems.patch98
1 files changed, 98 insertions, 0 deletions
diff --git a/debian/patches/procfs-filesystems.patch b/debian/patches/procfs-filesystems.patch
new file mode 100644
index 00000000..7205c7f1
--- /dev/null
+++ b/debian/patches/procfs-filesystems.patch
@@ -0,0 +1,98 @@
+From 4b2ab4810ef918cbc4c8bdb9a6f1476e70accace Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Thu, 18 Sep 2014 19:38:04 +0200
+Subject: [PATCH] procfs: implement /proc/filesystems
+
+* procfs/rootdir.c (rootdir_gc_filesystems): New function.
+(rootdir_entries): Use the new function to implement /proc/filesystems.
+---
+ procfs/rootdir.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 59 insertions(+)
+
+diff --git a/procfs/rootdir.c b/procfs/rootdir.c
+index 0b13119..50ed0d3 100644
+--- a/procfs/rootdir.c
++++ b/procfs/rootdir.c
+@@ -32,6 +32,7 @@
+ #include <sys/stat.h>
+ #include <argz.h>
+ #include <ps.h>
++#include <glob.h>
+ #include "procfs.h"
+ #include "procfs_dir.h"
+ #include "main.h"
+@@ -535,6 +536,57 @@ rootdir_gc_slabinfo (void *hook, char **contents, ssize_t *contents_len)
+ cache_info, cache_info_count * sizeof *cache_info);
+ return err;
+ }
++
++static error_t
++rootdir_gc_filesystems (void *hook, char **contents, ssize_t *contents_len)
++{
++ error_t err = 0;
++ size_t i;
++ int glob_ret;
++ glob_t matches;
++ FILE *m;
++
++ m = open_memstream (contents, contents_len);
++ if (m == NULL)
++ return errno;
++
++ glob_ret = glob (_HURD "*fs", 0, NULL, &matches);
++ switch (glob_ret)
++ {
++ case 0:
++ for (i = 0; i < matches.gl_pathc; i++)
++ {
++ /* Get ith entry, shave off the prefix. */
++ char *name = &matches.gl_pathv[i][sizeof _HURD - 1];
++
++ /* Linux naming convention is a bit inconsistent. */
++ if (strncmp (name, "ext", 3) == 0
++ || strcmp (name, "procfs") == 0)
++ /* Drop the fs suffix. */
++ name[strlen (name) - 2] = 0;
++
++ fprintf (m, "\t%s\n", name);
++ }
++
++ globfree (&matches);
++ break;
++
++ case GLOB_NOMATCH:
++ /* Poor fellow. */
++ break;
++
++ case GLOB_NOSPACE:
++ err = ENOMEM;
++ break;
++
++ default:
++ /* This should not happen. */
++ err = EGRATUITOUS;
++ }
++
++ fclose (m);
++ return err;
++}
+
+ /* Glue logic and entries table */
+
+@@ -635,6 +687,13 @@ static const struct procfs_dir_entry rootdir_entries[] = {
+ .cleanup_contents = procfs_cleanup_contents_with_free,
+ },
+ },
++ {
++ .name = "filesystems",
++ .hook = & (struct procfs_node_ops) {
++ .get_contents = rootdir_gc_filesystems,
++ .cleanup_contents = procfs_cleanup_contents_with_free,
++ },
++ },
+ #ifdef PROFILE
+ /* In order to get a usable gmon.out file, we must apparently use exit(). */
+ {
+--
+2.1.0
+