Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2504632rdb; Thu, 21 Sep 2023 23:51:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGnPMq8KFqVSpvKjp5QW8afRMF3ZL3GUKXSXR1qeZQCyyRqguHx4ej6ZUi9yf9u1OSTzcyd X-Received: by 2002:a05:6a21:9988:b0:131:c760:2a0b with SMTP id ve8-20020a056a21998800b00131c7602a0bmr8991449pzb.52.1695365465795; Thu, 21 Sep 2023 23:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695365465; cv=none; d=google.com; s=arc-20160816; b=yLBearbHtPovjrz9oq6L2whB3porcbBpUIyLUj2bzIdWJEjDjZf0/w6JgRsMQ4X1q7 nkE776H2PyNPMwnrJuinknQ0Di5MZPuFDo1F2khcxEZU23LcTKNr9poCzKHdj89MnHmG j8HF7PhqCZaUR1vr5EKiZ6JM0iXNQ20aqBZG9JLDWeiwrsapROnwTWo9b9peD2okW2SK mvRC7S/A7LORMWn9IZ6dbKa4L+wi5FYVrChHCGK9TgfdyUuVfgTtl025SiKK31DSzIjy nHUJwc/Im9TkZSMUG7Pq/X0O/usIpsbvmTR/0guwcLcStZSp9rx67YdwL/+Dg3N8EOy0 QgtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=F3KK0azHrvJ3S4DAAH+Vjr5j2tc3bC5JP4rnLJ/SSuQ=; fh=tOzwWtfY/Ihw0ZG9uDufqX7N1fYPvJMmg28cxm4BgX4=; b=AhUprIF152Pnai72DuPo6Z8scXX+lrGQWX2L+BflOKY5ZAYgUqDIrk6m4EWUEWxDEy 4rw+JyExu8r4M4Ergtg54OQmTFeRBhDbkPiiqwia08/1v/rMLc4aBxjlZXMnR75QMB1M AtQYeCJsgLaK53M4a1rjOaQhJnsKaRkZdxhtnH9mtnjZm+IKyVzw0/np1cbf9regqklb 4ndwnO0Mmd010JEOlQuYv32Pi3w3eS6tQgdSlrf7+VPdn/jymp7BwCBrpM0bY5ya2UBK H6SEroJEs13EB4+TWHS2HHs5WedEUBIKQm5fc7V5eICj8pvqhKuXND67LpeAexyE6mUN cT5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=H81IOwlm; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=QB6lMBWA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id nk6-20020a17090b194600b00256d7cc5b67si3283154pjb.133.2023.09.21.23.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 23:51:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@themaw.net header.s=fm1 header.b=H81IOwlm; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=QB6lMBWA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id CFC708382189; Thu, 21 Sep 2023 21:13:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230526AbjIVENc (ORCPT + 99 others); Fri, 22 Sep 2023 00:13:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230330AbjIVENG (ORCPT ); Fri, 22 Sep 2023 00:13:06 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47CA2100; Thu, 21 Sep 2023 21:12:54 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 979565C0232; Fri, 22 Sep 2023 00:12:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 22 Sep 2023 00:12:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1695355973; x= 1695442373; bh=F3KK0azHrvJ3S4DAAH+Vjr5j2tc3bC5JP4rnLJ/SSuQ=; b=H 81IOwlmkYtrJv8vDJiJPq3FUWLzvvHTxbiNPTDq0W7MLhClHzD0FDTF97QQ/hEa6 t6oMaretIz/pM5ahS1WPK6VzGXSnDaAd5qWKzvbxAUDqMGo9/abhpfkk8DGha1Vn zxQOY9wjBTWqt0ADZ2aXskleKXZkFaHHKRQb/zMvSstd1GFpskOjHQA786wCw3VE 4p0B+0tYXcYZF69lni/XJgfRMAFnSYkMpXAu69uxz3Do1G0jZp2AjV8hDfWKQ7fn D/DYYA06n/kasIUl/tkaY/xgdqWs5RuVEiNbs6/Sgz9V/gdAhq42UV17PZ5eGcZ2 WIdgwLiX5eW8NmkWlyG+g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1695355973; x= 1695442373; bh=F3KK0azHrvJ3S4DAAH+Vjr5j2tc3bC5JP4rnLJ/SSuQ=; b=Q B6lMBWAVWbjSzSoaiiNPaalZYj62ulHn2Gxy2ayy0kW2PC1HKCEWiEXSYpl14UwQ hi+UChcd8IwnANXXsdUzYjnwyQv9iO/iAsgg2jDnxbLTzzja+n34VqPK3MNw1z5w 5mhkiAhiwL/UneFstCgPUH9hs86mh8F55ycx1ZAi2IEr8cAy1o0k2GugWSEOFO5I QmjRXGazQifIWXCGvu9S+S35PoFi1uStX8ATCEsX0DYcOnj0k+BS7xXcI0thN3LG avN1oowNGbdzTEuKGUnX9xXbJaztzBkwT2XLBoFboUfSjiejLgxKOzyMa5t5j4AV hDH0vhsA85vakhjTEzX3Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudekjedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepkfgrnhcu mfgvnhhtuceorhgrvhgvnhesthhhvghmrgifrdhnvghtqeenucggtffrrghtthgvrhhnpe duleegueffgfehudeufedtffeiudfghfejgeehvdffgefgjeetvdfffeeihfdvveenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrrghvvghnse hthhgvmhgrfidrnhgvth X-ME-Proxy: Feedback-ID: i31e841b0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 22 Sep 2023 00:12:49 -0400 (EDT) From: Ian Kent To: Al Viro , Christian Brauner Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Bill O'Donnell , Miklos Szeredi , David Howells , Ian Kent Subject: [PATCH 5/8] autofs: refactor parse_options() Date: Fri, 22 Sep 2023 12:12:12 +0800 Message-ID: <20230922041215.13675-6-raven@themaw.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230922041215.13675-1-raven@themaw.net> References: <20230922041215.13675-1-raven@themaw.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 21 Sep 2023 21:13:38 -0700 (PDT) Seperate out parts of parse_options() that will match better the individual option processing used in the mount API to further simplify the upcoming conversion. Signed-off-by: Ian Kent --- fs/autofs/inode.c | 136 ++++++++++++++++++++++++---------------------- 1 file changed, 72 insertions(+), 64 deletions(-) diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index d2b333c0682a..5e061ce3ab8d 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -167,18 +167,84 @@ static int autofs_parse_fd(struct autofs_sb_info *sbi, int fd) return 0; } -static int parse_options(char *options, - struct inode *root, int *pgrp, bool *pgrp_set, - struct autofs_sb_info *sbi) +static int autofs_parse_param(char *optstr, struct inode *root, + int *pgrp, bool *pgrp_set, + struct autofs_sb_info *sbi) { - char *p; substring_t args[MAX_OPT_ARGS]; int option; int pipefd = -1; kuid_t uid; kgid_t gid; + int token; int ret; + token = match_token(optstr, tokens, args); + switch (token) { + case Opt_fd: + if (match_int(args, &pipefd)) + return 1; + ret = autofs_parse_fd(sbi, pipefd); + if (ret) + return 1; + break; + case Opt_uid: + if (match_int(args, &option)) + return 1; + uid = make_kuid(current_user_ns(), option); + if (!uid_valid(uid)) + return 1; + root->i_uid = uid; + break; + case Opt_gid: + if (match_int(args, &option)) + return 1; + gid = make_kgid(current_user_ns(), option); + if (!gid_valid(gid)) + return 1; + root->i_gid = gid; + break; + case Opt_pgrp: + if (match_int(args, &option)) + return 1; + *pgrp = option; + *pgrp_set = true; + break; + case Opt_minproto: + if (match_int(args, &option)) + return 1; + sbi->min_proto = option; + break; + case Opt_maxproto: + if (match_int(args, &option)) + return 1; + sbi->max_proto = option; + break; + case Opt_indirect: + set_autofs_type_indirect(&sbi->type); + break; + case Opt_direct: + set_autofs_type_direct(&sbi->type); + break; + case Opt_offset: + set_autofs_type_offset(&sbi->type); + break; + case Opt_strictexpire: + sbi->flags |= AUTOFS_SBI_STRICTEXPIRE; + break; + case Opt_ignore: + sbi->flags |= AUTOFS_SBI_IGNORE; + } + + return 0; +} + +static int parse_options(char *options, + struct inode *root, int *pgrp, bool *pgrp_set, + struct autofs_sb_info *sbi) +{ + char *p; + root->i_uid = current_uid(); root->i_gid = current_gid(); @@ -186,71 +252,13 @@ static int parse_options(char *options, return 1; while ((p = strsep(&options, ",")) != NULL) { - int token; - if (!*p) continue; - token = match_token(p, tokens, args); - switch (token) { - case Opt_fd: - if (match_int(args, &pipefd)) - return 1; - ret = autofs_parse_fd(sbi, pipefd); - if (ret) - return 1; - break; - case Opt_uid: - if (match_int(args, &option)) - return 1; - uid = make_kuid(current_user_ns(), option); - if (!uid_valid(uid)) - return 1; - root->i_uid = uid; - break; - case Opt_gid: - if (match_int(args, &option)) - return 1; - gid = make_kgid(current_user_ns(), option); - if (!gid_valid(gid)) - return 1; - root->i_gid = gid; - break; - case Opt_pgrp: - if (match_int(args, &option)) - return 1; - *pgrp = option; - *pgrp_set = true; - break; - case Opt_minproto: - if (match_int(args, &option)) - return 1; - sbi->min_proto = option; - break; - case Opt_maxproto: - if (match_int(args, &option)) - return 1; - sbi->max_proto = option; - break; - case Opt_indirect: - set_autofs_type_indirect(&sbi->type); - break; - case Opt_direct: - set_autofs_type_direct(&sbi->type); - break; - case Opt_offset: - set_autofs_type_offset(&sbi->type); - break; - case Opt_strictexpire: - sbi->flags |= AUTOFS_SBI_STRICTEXPIRE; - break; - case Opt_ignore: - sbi->flags |= AUTOFS_SBI_IGNORE; - break; - default: + if (autofs_parse_param(p, root, pgrp, pgrp_set, sbi)) return 1; - } } + return (sbi->pipefd < 0); } -- 2.41.0