From patchwork Wed Jun 21 13:07:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 111027 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4373206vqr; Wed, 21 Jun 2023 06:41:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ZQVeOvypN2BLdDbW1FvJBnCi1Saq1EoLLmiCbvlpg8FgxW0b6dOPMyjFieCM46Y+MP2rn X-Received: by 2002:a05:6a20:7491:b0:104:8045:c952 with SMTP id p17-20020a056a20749100b001048045c952mr26992416pzd.23.1687354898889; Wed, 21 Jun 2023 06:41:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687354898; cv=none; d=google.com; s=arc-20160816; b=m0A4bvjv26M5IfHSSa1oJjQrhc9sM0KwXSlfKVSTRqWLBxghh6J3eT3q7qNN3t5v9b Dhe0loICXAbg5otEuXyyDqyax5gBxPKUnNasc/3BuqbgL3+C2cejEafKl2PecqRRDTN3 uXB3dJs9uWzMilg+v1wHbeF2BBA6ClBR5JtR12X85UmBecUmlGjshknXMfkNgfHzKbR/ 2hLTchgD2hXF16fPjzXa6XB/Mrc8ao60oTqeftASunmIFd+GNKiM2tDAoEeAib4aapV6 cFvB14GkzSRtgZJ6RmBW0DIijY0k5qSEoe81WoUaJm0Mb1g4yAb88Q6oCfW5wC2DBcx9 vdXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=pOJJbGlJCzP6Wd8n351HcaFOyG7wb+G6hGnIEbafY0o=; b=UCYr/oFYypNpGkKlKok7Cq/9GRMJP9JcpPsWj/aHoi186RLv1T0gPqBLVPlhulO51A rF+P8ena6y8Or9+z0JQeR1ayrwPIx6FnJ3hAlf25atJx/Wb3JSPP/SyxbC54s7C5/oEE UatlLfiLp5AeygCtL08LwCgLRP06exZTlyVYMybk4ULEVTYrmUHzv9YTNMV+x7btCTsa 9OiEG8XXoEoNt9UOAlg0b1zLQT+yJ2x3C3VMOJc9rrqaIHrcbifDWP3cDA0YpgIes7bo atRSL5docKJb55G5KPpSV6XsQxqPL1Qk4HaXnBcxLmN3srCBgRPwAn5MpOaVu/Jzd/78 3gag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v10-20020a637a0a000000b005533f42dee0si183726pgc.786.2023.06.21.06.41.18; Wed, 21 Jun 2023 06:41:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232263AbjFUNId (ORCPT + 99 others); Wed, 21 Jun 2023 09:08:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229888AbjFUNIc (ORCPT ); Wed, 21 Jun 2023 09:08:32 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A55EE57; Wed, 21 Jun 2023 06:08:30 -0700 (PDT) X-QQ-mid: bizesmtp74t1687352900ty2iclwn Received: from linux-lab-host.localdomain ( [116.30.126.60]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 21 Jun 2023 21:08:19 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: vLOCICHxEeC+4y1LTp+BiY9j8PpHb9Dt4Sg+2rc6l1HNUYeypb+ihBW6wVf8X m3rnjZGltsHYRsXmYIEH4Duj+y+zjsGILWk6dG3qMZSHnTR2MZBPXV/uK+QrWjw6JKn3c6e 11uXzBQUetno3Oz5sOQOKjopaXxRuKdOJoJAZpcEi5jB2Ky11wn3+qmKmg0siaHFhdQLrwc kvsgbIYm9WAi2jb3JO6uKkXGfDl9rjnm6KDgT2rmWf15xPyiAeUoVbsdXb4Ct7CeLaD5gi9 ZgyBeXosAzEXjz0dFjGsZowL/nBGYCVTdCmp4yb9c5oINcMKSbIO7XXIdM2rgY3A1lrhQ3s uSk2mU613pLEaVHuJwCBogk6fZv8twRDHJv8MXuaYOPIKziv07HAzterzG6vA== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 16746959025053847439 From: Zhangjin Wu To: w@1wt.eu Cc: thomas@t-8ch.de, arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 11/17] selftests/nolibc: prepare tmpfs and hugetlbfs Date: Wed, 21 Jun 2023 21:07:22 +0800 Message-Id: <604d011aab4b7ec3734685ce9f1a163771a2c9d4.1687344643.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769319850412938803?= X-GMAIL-MSGID: =?utf-8?q?1769319850412938803?= Let's make the /tmp and /hugetlb directories and mount tmpfs and hugetlbfs respectively, they will be used to check the existing of tmpfs and hugetlbfs. We will also use tmpfs to let some test cases run without procfs. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 69f59a395746..8b587961e46a 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -935,6 +935,18 @@ int prepare(void) } } + /* try to mount /tmp if not mounted. Silently fail otherwise */ + if (stat("/tmp/.", &stat_buf) == 0 || mkdir("/tmp", 0755) == 0) { + if (mount("none", "/tmp", "tmpfs", 0, 0) != 0) + rmdir("/tmp"); + } + + /* try to mount /hugetlb if not mounted. Silently fail otherwise */ + if (stat("/hugetlb/.", &stat_buf) == 0 || mkdir("/hugetlb", 0755) == 0) { + if (mount("none", "/hugetlb", "hugetlbfs", 0, 0) != 0) + rmdir("/hugetlb"); + } + return 0; }