[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 5/8] trans/mtab: do not include non-filesystem translators by
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 5/8] trans/mtab: do not include non-filesystem translators by default |
Date: |
Sun, 12 Jan 2014 20:50:27 +0100 |
User-agent: |
Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) |
Justus Winter, le Sun 12 Jan 2014 20:08:42 +0100, a écrit :
> Traditionally, /proc/mounts includes only filesystem mount points.
> Previously though, the mtab translator included any kind of
> translator, like all /hurd/storeio translators. This causes problems
> with umount --all as this would remove the passive translator records
> from nodes in /dev.
>
> Fix this by only listing filesystem-like translators by default.
> Filesystem-like translators are identified by their response to
> dir_readdir messages sent to their root node.
Ack.
> * trans/mtab.c (all_translators): New variable.
> (options): Add flag to preserve the old behavior.
> (parse_opt): Handle the new flag.
> (is_filesystem_translator): New function.
> (mtab_populate): Skip non-filesystem translators by default.
> ---
> trans/mtab.c | 40 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
>
> diff --git a/trans/mtab.c b/trans/mtab.c
> index adfb345..75ef1d3 100644
> --- a/trans/mtab.c
> +++ b/trans/mtab.c
> @@ -40,6 +40,7 @@
>
> static char *target_path = NULL;
> static int insecure = 0;
> +static int all_translators = 0;
>
> /* Our control port. */
> struct trivfs_control *control;
> @@ -60,6 +61,9 @@ static const struct argp_option options[] =
> {
> {"insecure", 'I', 0, 0,
> "Follow translators not bound to nodes owned by you or root"},
> + {"all-translators", 'A', 0, 0,
> + "List all translators, even those that are probably not "
> + "filesystem translators"},
> {}
> };
>
> @@ -72,6 +76,10 @@ error_t parse_opt (int key, char *arg, struct argp_state
> *state)
> insecure = 1;
> break;
>
> + case 'A':
> + all_translators = 1;
> + break;
> +
> case ARGP_KEY_ARG:
> target_path = realpath (arg, NULL);
> if (! target_path)
> @@ -277,6 +285,32 @@ mtab_add_entry (struct mtab *mtab, const char *entry,
> size_t length)
> return 0;
> }
>
> +/* Check whether the given NODE is a directory on a filesystem
> + translator. */
> +static boolean_t
> +is_filesystem_translator (file_t node)
> +{
> + error_t err;
> + char *data = NULL;
> + size_t datacnt = 0;
> + int amount;
> + err = dir_readdir (node, &data, &datacnt, 0, 1, 0, &amount);
> + if (data != NULL && datacnt > 0)
> + vm_deallocate (mach_task_self (), (vm_address_t) data, datacnt);
> +
> + /* Filesystem translators return either no error, or, if NODE has
> + not been looked up with O_READ, EBADF to dir_readdir
> + requests. */
> + switch (err)
> + {
> + case 0:
> + case EBADF:
> + return TRUE;
> + default:
> + return FALSE;
> + }
> +}
> +
> /* Populates the given MTAB object with the information for PATH. If
> INSECURE is given, also follow translators bound to nodes not owned
> by root or the current user. */
> @@ -333,6 +367,12 @@ mtab_populate (struct mtab *mtab, const char *path, int
> insecure)
> goto errout;
> }
>
> + if (! (all_translators || is_filesystem_translator (node)))
> + {
> + err = 0;
> + goto errout;
> + }
> +
> /* Query its options. */
> err = file_get_fs_options (node, &argz, &argz_len);
> if (err)
> --
> 1.8.5.2
>
--
Samuel
> Il [e2fsck] a bien démarré, mais il m'a rendu la main aussitot en me
> disant "houlala, c'est pas beau à voir votre truc, je préfèrerai que
> vous teniez vous même la tronçonneuse" (traduction libre)
NC in Guide du linuxien pervers : "Bien configurer sa tronçonneuse."
- [PATCH 1/8] trans/mtab: populate mtab objects on demand, Justus Winter, 2014/01/12
- [PATCH 2/8] trans/mtab: remove the loop detection logic, Justus Winter, 2014/01/12
- [PATCH 4/8] trans/mtab: make the translator multithreaded, Justus Winter, 2014/01/12
- [PATCH 3/8] trans/mtab: properly lock mtab objects, Justus Winter, 2014/01/12
- [PATCH 5/8] trans/mtab: do not include non-filesystem translators by default, Justus Winter, 2014/01/12
- Re: [PATCH 5/8] trans/mtab: do not include non-filesystem translators by default,
Samuel Thibault <=
- [PATCH 6/8] libfshelp: fix the api of fshelp_set_active_translator, Justus Winter, 2014/01/12
- [PATCH 7/8] libdiskfs: register passive translator startups, Justus Winter, 2014/01/12
- [PATCH 8/8] libnetfs: register passive translator startups, Justus Winter, 2014/01/12
- Re: [PATCH 1/8] trans/mtab: populate mtab objects on demand, Samuel Thibault, 2014/01/12