bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/7] procfs: implement /proc/N/mounts


From: Samuel Thibault
Subject: Re: [PATCH 3/7] procfs: implement /proc/N/mounts
Date: Mon, 29 Sep 2014 01:15:45 +0200
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)

Justus Winter, le Mon 22 Sep 2014 11:38:40 +0200, a écrit :
> * procfs/process.c (process_gc_mounts): New function.
> (process_symlink_make_node): Likewise.
> (entries): Use the new functions to provide a symlink to ../mounts.

Mmm, I wouldn't lie like this: don't we have per-process views of what / is?
(notably through remaps)

Which application needs /proc/$$/mounts?

> ---
>  procfs/process.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/procfs/process.c b/procfs/process.c
> index a9b1a59..f5da0d2 100644
> --- a/procfs/process.c
> +++ b/procfs/process.c
> @@ -202,6 +202,16 @@ process_file_gc_maps (struct proc_stat *ps, char 
> **contents)
>    return contents_len;
>  }
>  
> +static error_t
> +process_gc_mounts  (void *hook, char **contents, ssize_t *contents_len)
> +{
> +#define MOUNTSLINK   "../mounts"
> +  *contents = MOUNTSLINK;
> +  *contents_len = sizeof MOUNTSLINK - 1;
> +#undef MOUNTSLINK
> +  return 0;
> +}
> +
>  static ssize_t
>  process_file_gc_stat (struct proc_stat *ps, char **contents)
>  {
> @@ -420,6 +430,14 @@ process_stat_make_node (void *dir_hook, const void 
> *entry_hook)
>    return np;
>  }
>  
> +static struct node *
> +process_symlink_make_node (void *dir_hook, const void *entry_hook)
> +{
> +  struct node *np = procfs_make_node (entry_hook, dir_hook);
> +  if (np)
> +    procfs_node_chtype (np, S_IFLNK);
> +  return np;
> +}
>  
>  /* Implementation of the process directory per se.  */
>  
> @@ -450,6 +468,15 @@ static struct procfs_dir_entry entries[] = {
>      },
>    },
>    {
> +    .name = "mounts",
> +    .hook = & (struct procfs_node_ops) {
> +      .get_contents = process_gc_mounts,
> +    },
> +    .ops = {
> +      .make_node = process_symlink_make_node,
> +    },
> +  },
> +  {
>      .name = "stat",
>      .hook = & (struct process_file_desc) {
>        .get_contents = process_file_gc_stat,
> -- 
> 2.1.0
> 

-- 
Samuel
<c> tiens, je suis déçu
<c> quand on clique sur le bouton random de http://xkcd.com/221/ on ne tombe 
pas (toujours) sur http://xkcd.com/4/
<c> bon, j'envoie un bug-report à l'auteur



reply via email to

[Prev in Thread] Current Thread [Next in Thread]