From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FFB0C4743C for ; Mon, 21 Jun 2021 14:46:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50EF06109F for ; Mon, 21 Jun 2021 14:46:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230006AbhFUOs4 (ORCPT ); Mon, 21 Jun 2021 10:48:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229747AbhFUOsy (ORCPT ); Mon, 21 Jun 2021 10:48:54 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41B2CC061574; Mon, 21 Jun 2021 07:46:40 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvLC9-00ArRc-HB; Mon, 21 Jun 2021 14:46:37 +0000 Date: Mon, 21 Jun 2021 14:46:37 +0000 From: Al Viro To: Christoph Hellwig Cc: Vivek Goyal , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, virtio-fs@redhat.com Subject: Re: [PATCH 1/2] init: split get_fs_names Message-ID: References: <20210621062657.3641879-1-hch@lst.de> <20210621062657.3641879-2-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210621062657.3641879-2-hch@lst.de> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 21, 2021 at 08:26:56AM +0200, Christoph Hellwig wrote: > Split get_fs_names into one function that splits up the command line > argument, and one that gets the list of all registered file systems. > +static void __init get_all_fs_names(char *page) > +{ > + int len = get_filesystem_list(page); > + char *s = page, *p, *next; > + > + page[len] = '\0'; > + for (p = page - 1; p; p = next) { > + next = strchr(++p, '\n'); > + if (*p++ != '\t') > + continue; > + while ((*s++ = *p++) != '\n') > + ; > + s[-1] = '\0'; > } > + > *s = '\0'; > } TBH, I would rather take that one into fs/filesystems.c. Rationale: get_filesystem_list(), for all its resemblance to /proc/filesystems contents, is used only by init/*.c and it's not a big deal to make it int __init get_filesystem_list(char *buf, bool is_dev) { int f = is_dev ? FS_REQUIRES_DEV : 0; int left = PAGE_SIZE, count = 0; struct file_system_type *p; read_lock(&file_systems_lock); for (p = file_systems; p; p = p->next) { if ((p->fs_flags & FS_REQUIRES_DEV) == f) { size_t len = strlen(p->name) + 1; if (len > left) break; memcpy(buf, p->name, len); buf += len; left -= len; count++; } } read_unlock(&file_systems_lock); return count; } Generates NUL-separated list, returns the number of list elements, the second argument is "what kind do you want"...