linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
	virtio-fs@redhat.com, linux-kernel@vger.kernel.org,
	Vivek Goyal <vgoyal@redhat.com>
Subject: Re: [Virtio-fs] [PATCH 3/2] fs: simplify get_filesystem_list / get_all_fs_names
Date: Tue, 22 Jun 2021 09:36:33 +0100	[thread overview]
Message-ID: <YNGhERcnLuzjn8j9@stefanha-x1.localdomain> (raw)
In-Reply-To: <20210622081217.GA2975@lst.de>

[-- Attachment #1: Type: text/plain, Size: 1791 bytes --]

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@zeniv.linux.org.uk>.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.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()?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2021-06-22  8:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-21  6:26 support booting of arbitrary non-blockdevice file systems v2 Christoph Hellwig
2021-06-21  6:26 ` [PATCH 1/2] init: split get_fs_names Christoph Hellwig
2021-06-21 14:46   ` Al Viro
2021-06-21 14:51     ` Al Viro
2021-06-21 14:53     ` Christoph Hellwig
2021-06-21 14:59       ` Al Viro
2021-06-21 15:09   ` Matthew Wilcox
2021-06-21 15:22     ` Christoph Hellwig
2021-06-21  6:26 ` [PATCH 2/2] init: allow mounting arbitrary non-blockdevice filesystems as root Christoph Hellwig
2021-06-21 13:31 ` [Virtio-fs] support booting of arbitrary non-blockdevice file systems v2 Stefan Hajnoczi
2021-06-21 14:35 ` Vivek Goyal
2021-06-22  8:12 ` [PATCH 3/2] fs: simplify get_filesystem_list / get_all_fs_names Christoph Hellwig
2021-06-22  8:36   ` Stefan Hajnoczi [this message]
2021-06-29 20:50     ` [Virtio-fs] " Vivek Goyal
2021-06-30  5:36       ` Christoph Hellwig
2021-06-30 17:33         ` Vivek Goyal
2021-07-07 21:04         ` Vivek Goyal
2021-07-07 21:06           ` Vivek Goyal
2021-07-08 12:59             ` Vivek Goyal
2021-07-12 18:21               ` Vivek Goyal
2021-07-13  5:40                 ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YNGhERcnLuzjn8j9@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vgoyal@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=virtio-fs@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).