From patchwork Fri May 29 07:41:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11578041 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE3A617C7 for ; Fri, 29 May 2020 07:56:15 +0000 (UTC) Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CAF6020810 for ; Fri, 29 May 2020 07:56:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CAF6020810 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=ocfs2-devel-bounces@oss.oracle.com Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04T7qGT2072500; Fri, 29 May 2020 07:55:31 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 318xbk9073-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 29 May 2020 07:55:31 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04T7rigs183915; Fri, 29 May 2020 07:55:30 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userp3020.oracle.com with ESMTP id 31a9ktuwa2-1 (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO); Fri, 29 May 2020 07:55:30 +0000 Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1jeZrV-0000Nq-Ma; Fri, 29 May 2020 00:55:29 -0700 Received: from aserp3030.oracle.com ([141.146.126.71]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1jeZdw-0006eP-8U for ocfs2-devel@oss.oracle.com; Fri, 29 May 2020 00:41:28 -0700 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04T7d9g0051779 for ; Fri, 29 May 2020 07:41:28 GMT Received: from userp2030.oracle.com (userp2030.oracle.com [156.151.31.89]) by aserp3030.oracle.com with ESMTP id 317ddu2he1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 29 May 2020 07:41:27 +0000 Received: from pps.filterd (userp2030.oracle.com [127.0.0.1]) by userp2030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04T7ewHG007498 for ; Fri, 29 May 2020 07:41:27 GMT Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by userp2030.oracle.com with ESMTP id 31akmj1bd2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK) for ; Fri, 29 May 2020 07:41:26 +0000 Received: by mail-pl1-f194.google.com with SMTP id a13so766252pls.8 for ; Fri, 29 May 2020 00:41:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DDbHuQyYpIA+NrKXcOMmKPCGJcWzsoGwYaKrbY/Qlik=; b=BpuDCgDEdjHX3+c2mY5T2qXFi182ZybAbhZvDN3waDP9UcRm/Vgra3QckoJA6E3u9d yEpqRmmPcK5Gj8PP5eqwNfQ32A+RQ8gmeXeZ7mroLm9EYabi0rSu1B94C5M7H/xsLztO xUgjLGLX94Mjx6ZKd+oZoU35KdSIMTq9mkRTLvdVq1+qNxg7Zz01Ph6TUvR8QWJU7mYw 50L4grRk1X7rv8fP9tznlnWExgH7Zc72JGPHAZ+GaM5m6MMjT/ctp9GVcW08tMkk899N +JCjqM8vx4Ex7DbBr+WPQ7CDtMC3WFODg5P0aRBTI5jsnAt8VmMQJ8+vpFS0zJqmLHev Utlw== X-Gm-Message-State: AOAM532KBqdeQGgnExwA8AstTA6jmRE1bi8ZIo8iy5OYwD5GyjwxznD7 n6A+0wOydY/3gq1Sn4PNiu4= X-Google-Smtp-Source: ABdhPJwGzuqDcH6Vkxqbl1C5ZMUAQstwFZ+JipZBre8wnuBfBUsU2v0rs/LBQURtmvm2RkRrx2hGlQ== X-Received: by 2002:a17:90a:fe0c:: with SMTP id ck12mr973724pjb.209.1590738085315; Fri, 29 May 2020 00:41:25 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id t201sm3703652pfc.104.2020.05.29.00.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 00:41:16 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 08CEC42394; Fri, 29 May 2020 07:41:11 +0000 (UTC) From: Luis Chamberlain To: keescook@chromium.org, yzaikin@google.com, nixiaoming@huawei.com, ebiederm@xmission.com, axboe@kernel.dk, clemens@ladisch.de, arnd@arndb.de, gregkh@linuxfoundation.org, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, airlied@linux.ie, daniel@ffwll.ch, benh@kernel.crashing.org, rdna@fb.com, viro@zeniv.linux.org.uk, mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, vbabka@suse.cz, sfr@canb.auug.org.au, jack@suse.cz, amir73il@gmail.com, rafael@kernel.org, tytso@mit.edu Date: Fri, 29 May 2020 07:41:07 +0000 Message-Id: <20200529074108.16928-13-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200529074108.16928-1-mcgrof@kernel.org> References: <20200529074108.16928-1-mcgrof@kernel.org> MIME-Version: 1.0 X-PDR: PASS X-Source-IP: 209.85.214.194 X-ServerName: mail-pl1-f194.google.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 redirect=_spf.google.com X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9635 signatures=668686 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 phishscore=0 clxscore=237 bulkscore=0 priorityscore=60 adultscore=0 mlxlogscore=871 suspectscore=0 spamscore=0 malwarescore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005290059 X-Spam: Clean X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005290060 X-Mailman-Approved-At: Fri, 29 May 2020 00:55:28 -0700 Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, julia.lawall@lip6.fr, Luis Chamberlain , linuxppc-dev@lists.ozlabs.org, ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH 12/13] sysctl: add helper to register empty subdir X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9635 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005290062 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9635 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 cotscore=-2147483648 suspectscore=0 bulkscore=0 clxscore=1034 impostorscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005290062 The way to create a subdirectory from the base set of directories is a bit obscure, so provide a helper which makes this clear, and also helps remove boiler plate code required to do this work. Signed-off-by: Luis Chamberlain Reviewed-by: Kees Cook --- include/linux/sysctl.h | 7 +++++++ kernel/sysctl.c | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 33a471b56345..89c92390e6de 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -208,6 +208,8 @@ extern void register_sysctl_init(const char *path, struct ctl_table *table, extern struct ctl_table_header *register_sysctl_subdir(const char *base, const char *subdir, struct ctl_table *table); +extern void register_sysctl_empty_subdir(const char *base, const char *subdir); + void do_sysctl_args(void); extern int pwrsw_enabled; @@ -231,6 +233,11 @@ inline struct ctl_table_header *register_sysctl_subdir(const char *base, return NULL; } +static inline void register_sysctl_empty_subdir(const char *base, + const char *subdir) +{ +} + static inline struct ctl_table_header *register_sysctl_paths( const struct ctl_path *path, struct ctl_table *table) { diff --git a/kernel/sysctl.c b/kernel/sysctl.c index f9a35325d5d5..460532cd5ac8 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -3188,13 +3188,17 @@ struct ctl_table_header *register_sysctl_subdir(const char *base, { } }; - if (!table->procname) + if (table != sysctl_mount_point && !table->procname) goto out; hdr = register_sysctl_table(base_table); if (unlikely(!hdr)) { - pr_err("failed when creating subdirectory sysctl %s/%s/%s\n", - base, subdir, table->procname); + if (table != sysctl_mount_point) + pr_err("failed when creating subdirectory sysctl %s/%s/%s\n", + base, subdir, table->procname); + else + pr_err("failed when creating empty subddirectory %s/%s\n", + base, subdir); goto out; } kmemleak_not_leak(hdr); @@ -3202,6 +3206,12 @@ struct ctl_table_header *register_sysctl_subdir(const char *base, return hdr; } EXPORT_SYMBOL_GPL(register_sysctl_subdir); + +void register_sysctl_empty_subdir(const char *base, + const char *subdir) +{ + register_sysctl_subdir(base, subdir, sysctl_mount_point); +} #endif /* CONFIG_SYSCTL */ /* * No sense putting this after each symbol definition, twice,