[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/7] procfs: implement /proc/filesystems
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 2/7] procfs: implement /proc/filesystems |
Date: |
Mon, 29 Sep 2014 01:09:16 +0200 |
User-agent: |
Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) |
Justus Winter, le Mon 22 Sep 2014 11:38:39 +0200, a écrit :
> * procfs/rootdir.c (rootdir_gc_filesystems): New function.
> (rootdir_entries): Use the new function to implement /proc/filesystems.
Ack.
> ---
> procfs/rootdir.c | 61
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 60 insertions(+), 1 deletion(-)
>
> diff --git a/procfs/rootdir.c b/procfs/rootdir.c
> index 9541059..f92e73d 100644
> --- a/procfs/rootdir.c
> +++ b/procfs/rootdir.c
> @@ -1,5 +1,5 @@
> /* Hurd /proc filesystem, permanent files of the root directory.
> - Copyright (C) 2010,13 Free Software Foundation, Inc.
> + Copyright (C) 2010,13,14 Free Software Foundation, Inc.
>
> This file is part of the GNU Hurd.
>
> @@ -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"
> @@ -532,6 +533,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 */
>
> @@ -632,6 +684,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
>
--
Samuel
<k> faut en profiter, aujourd'hui, les blagues bidon sont à 100 dollars
-+- #sos-bourse -+-
- [PATCH 2/6] hurd: add symbolic name for the mtab translator, (continued)
- [PATCH 4/6] procfs: generalize the translator linkage code, Justus Winter, 2014/09/21
- Re: [PATCH 4/6] procfs: generalize the translator linkage code, Justus Winter, 2014/09/21
- [PATCH 1/7] procfs: implement /proc/N/maps, Justus Winter, 2014/09/22
- [PATCH 3/7] procfs: implement /proc/N/mounts, Justus Winter, 2014/09/22
- Re: [PATCH 3/7] procfs: implement /proc/N/mounts, Samuel Thibault, 2014/09/28
- [PATCH 4/7] procfs: do not test whether /hurd/mtab exists, Justus Winter, 2014/09/22
- Re: [PATCH 4/7] procfs: do not test whether /hurd/mtab exists, Samuel Thibault, 2014/09/28
- [PATCH 2/7] procfs: implement /proc/filesystems, Justus Winter, 2014/09/22
- Re: [PATCH 2/7] procfs: implement /proc/filesystems,
Samuel Thibault <=
- [PATCH 5/7] procfs: generalize the translator linkage code, Justus Winter, 2014/09/22
- Re: [PATCH 5/7] procfs: generalize the translator linkage code, Samuel Thibault, 2014/09/28
- [PATCH 6/7] procfs: reorganize rootdir.c, Justus Winter, 2014/09/22
- Re: [PATCH 6/7] procfs: reorganize rootdir.c, Samuel Thibault, 2014/09/28
- [PATCH 7/7] procfs: provide magic retry response for /proc/self, Justus Winter, 2014/09/22
- Re: [PATCH 7/7] procfs: provide magic retry response for /proc/self, Samuel Thibault, 2014/09/30
- And the libc patch, Justus Winter, 2014/09/22
- [PATCH] hurd: Handle `proc/self' magical lookup retry, Justus Winter, 2014/09/22
- Re: [PATCH 1/7] procfs: implement /proc/N/maps, Samuel Thibault, 2014/09/28
- [PATCH 5/6] procfs: reorganize rootdir.c, Justus Winter, 2014/09/21