[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YNGhERcnLuzjn8j9@stefanha-x1.localdomain>
Date: Tue, 22 Jun 2021 09:36:33 +0100
From: Stefan Hajnoczi <stefanha@...hat.com>
To: Christoph Hellwig <hch@....de>
Cc: viro@...iv.linux.org.uk, linux-fsdevel@...r.kernel.org,
virtio-fs@...hat.com, linux-kernel@...r.kernel.org,
Vivek Goyal <vgoyal@...hat.com>
Subject: Re: [Virtio-fs] [PATCH 3/2] fs: simplify get_filesystem_list /
get_all_fs_names
On Tue, Jun 22, 2021 at 10:12:17AM +0200, Christoph Hellwig wrote:
> Just output the '\0' separate list of supported file systems for block
> devices directly rather than going through a pointless round of string
> manipulation.
>
> Based on an earlier patch from Al Viro <viro@...iv.linux.org.uk>.
>
> Signed-off-by: Christoph Hellwig <hch@....de>
> ---
> fs/filesystems.c | 24 ++++++++++++++----------
> include/linux/fs.h | 2 +-
> init/do_mounts.c | 20 +-------------------
> 3 files changed, 16 insertions(+), 30 deletions(-)
>
> diff --git a/fs/filesystems.c b/fs/filesystems.c
> index 90b8d879fbaf..7c136251607a 100644
> --- a/fs/filesystems.c
> +++ b/fs/filesystems.c
> @@ -209,21 +209,25 @@ SYSCALL_DEFINE3(sysfs, int, option, unsigned long, arg1, unsigned long, arg2)
> }
> #endif
>
> -int __init get_filesystem_list(char *buf)
> +void __init list_bdev_fs_names(char *buf, size_t size)
> {
> - int len = 0;
> - struct file_system_type * tmp;
> + struct file_system_type *p;
> + size_t len;
>
> read_lock(&file_systems_lock);
> - tmp = file_systems;
> - while (tmp && len < PAGE_SIZE - 80) {
> - len += sprintf(buf+len, "%s\t%s\n",
> - (tmp->fs_flags & FS_REQUIRES_DEV) ? "" : "nodev",
> - tmp->name);
> - tmp = tmp->next;
> + for (p = file_systems; p; p = p->next) {
> + if (!(p->fs_flags & FS_REQUIRES_DEV))
> + continue;
> + len = strlen(p->name) + 1;
> + if (len > size) {
> + pr_warn("%s: truncating file system list\n", __func__);
> + break;
> + }
> + memcpy(buf, p->name, len);
> + buf += len;
> + size -= len;
> }
> read_unlock(&file_systems_lock);
> - return len;
> }
I don't see the extra NUL terminator byte being added that's required by
the loop in mount_block_root()?
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists