From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 9395E38582A2 for ; Mon, 4 Jul 2022 21:45:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9395E38582A2 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-66-ycCedAaONGek-Q4QKDO46Q-1; Mon, 04 Jul 2022 17:45:35 -0400 X-MC-Unique: ycCedAaONGek-Q4QKDO46Q-1 Received: by mail-qt1-f200.google.com with SMTP id e8-20020ac84148000000b00319f55b2657so7713925qtm.15 for ; Mon, 04 Jul 2022 14:45:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:organization:in-reply-to :content-transfer-encoding; bh=6yOiWe3A4B9QsFp6uEkl1YuBrqPzimuUOzU9csHsWeY=; b=6hdgqv4p536BXm8GWIKG9IJoNs6C82H3wtC2lx4KfNikz54PlBbMqHXN+VoDk5NDXm bVbJ4/36C+9nZQ9ueaWahw9vkghIu50VbKqH+cqfEnhvNxuyOLI4SKfxTcGN12S55ash ZlMDzkTxEg2u0AXYCtnPiqv0r5hSxjJAcxfGbvRScG/vrEyaJna408dlzjnsTZhddWph uH1y0yadcssognFOBK7WihMA8kRRFkggJrZ30pZNuoJFW0Sg8j7nDw+A3rPiVwTcFAWr y9hEJbEGJk5UNFQE59ZEjoMQ3zhDJF4/JNH9CEixCOYD/iQ5L7/c89vPzr3MhTUNOOjR DJVg== X-Gm-Message-State: AJIora848CXYVt+m9VE9r0RmL7iXtGsP923B9wVCa+cXYFGPiZzcNXWo IxY+f0hwIG1xr8r6xcKiMWDTcB9VLKEhBwgRcE+9GqNcZfXclL29uNnSHk34IX82ZJlu0zF0mwn kBi02Ps+Q/bmGmIFLHrxL X-Received: by 2002:a37:a70f:0:b0:6b1:8461:c835 with SMTP id q15-20020a37a70f000000b006b18461c835mr20271220qke.560.1656971134573; Mon, 04 Jul 2022 14:45:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ta0kecwwTCeix7YtoZ1oXontHR1UFiFFYgvue0HE9brl3J1uc749jixvQJFZmliwNI4RjCtQ== X-Received: by 2002:a37:a70f:0:b0:6b1:8461:c835 with SMTP id q15-20020a37a70f000000b006b18461c835mr20271209qke.560.1656971134323; Mon, 04 Jul 2022 14:45:34 -0700 (PDT) Received: from [192.168.0.241] (135-23-175-80.cpe.pppoe.ca. [135.23.175.80]) by smtp.gmail.com with ESMTPSA id fd10-20020a05622a4d0a00b0031bf5677d96sm12619465qtb.84.2022.07.04.14.45.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Jul 2022 14:45:33 -0700 (PDT) Message-ID: <1ec93ab7-bf63-52b6-7b37-4d01e6135216@redhat.com> Date: Mon, 4 Jul 2022 17:45:32 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v7 4/5] linux: Add tst-mount to check for Linux new mount API To: Adhemerval Zanella , libc-alpha@sourceware.org References: <20220624195919.435424-1-adhemerval.zanella@linaro.org> <20220624195919.435424-5-adhemerval.zanella@linaro.org> From: Carlos O'Donell Organization: Red Hat In-Reply-To: <20220624195919.435424-5-adhemerval.zanella@linaro.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-16.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, 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 server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2022 21:45:38 -0000 On 6/24/22 15:59, Adhemerval Zanella wrote: > The new mount API was added on Linux 5.2 with six new syscalls: > fsopen, fsconfig, fsmount, move_mount, fspick, and open_tree. > > The new test verifies minimal functionality along with error paths > for specific arguments and their corner cases. > > Checked on x86_64-linux-gnu. LGTM. Exercises error paths. Reviewed-by: Carlos O'Donell > --- > sysdeps/unix/sysv/linux/Makefile | 1 + > sysdeps/unix/sysv/linux/tst-mount.c | 95 +++++++++++++++++++++++++++++ > 2 files changed, 96 insertions(+) > create mode 100644 sysdeps/unix/sysv/linux/tst-mount.c > > diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile > index 7ffcf7ed83..2ccc92b6b8 100644 > --- a/sysdeps/unix/sysv/linux/Makefile > +++ b/sysdeps/unix/sysv/linux/Makefile > @@ -130,6 +130,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \ > tst-getauxval \ > tst-pidfd \ > tst-process_mrelease \ > + tst-mount \ OK. > # tests > > # process_madvise requires CAP_SYS_ADMIN. > diff --git a/sysdeps/unix/sysv/linux/tst-mount.c b/sysdeps/unix/sysv/linux/tst-mount.c > new file mode 100644 > index 0000000000..12a665f950 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/tst-mount.c > @@ -0,0 +1,95 @@ > +/* Basic tests for the new Linux API added on Linux 5.2. > + Copyright (C) 2022 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public License as > + published by the Free Software Foundation; either version 2.1 of the > + License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; see the file COPYING.LIB. If > + not, see . */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +static void > +subprocess (void) > +{ > + int r = fsopen ("it_should_be_not_a_valid_mount", 0); > + TEST_VERIFY_EXIT (r == -1); > + if (errno == ENOSYS) > + FAIL_UNSUPPORTED ("kernel does not support new mount API, skipping test"); > + TEST_COMPARE (errno, ENODEV); OK. Invalid mount path. > + > + int fd = fsopen ("tmpfs", FSOPEN_CLOEXEC); > + TEST_VERIFY (fd != -1); > + > + TEST_COMPARE (fsconfig (-1, FSCONFIG_SET_STRING, "size", "2048", 0), -1); > + TEST_COMPARE (errno, EINVAL); > + > + { > + int r = fsconfig (fd, FSCONFIG_SET_STRING, "size", "2048", 0); > + TEST_VERIFY (r != -1); > + r = fsconfig (fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0); > + TEST_VERIFY (r != -1); > + } > + > + TEST_COMPARE (fsmount (-1, FSMOUNT_CLOEXEC, MOUNT_ATTR_NODEV), -1); > + TEST_COMPARE (errno, EBADF); OK. -1 is an invalid fd. > + > + int mfd = fsmount (fd, FSMOUNT_CLOEXEC, MOUNT_ATTR_NODEV); > + TEST_VERIFY (mfd != -1); > + > + TEST_COMPARE (move_mount (-1, "", AT_FDCWD, "/tmp", 0), -1); > + TEST_COMPARE (errno, ENOENT); > + { > + int r = move_mount (mfd, "", AT_FDCWD, "/tmp", MOVE_MOUNT_F_EMPTY_PATH); > + TEST_VERIFY (r != -1); > + } > + > + TEST_COMPARE (fspick (AT_FDCWD, "", 0), -1); > + TEST_COMPARE (errno, ENOENT); > + { > + int pfd = fspick (AT_FDCWD, "/tmp", FSPICK_CLOEXEC); > + TEST_VERIFY (pfd != -1); > + } OK. > + > + TEST_COMPARE (open_tree (AT_FDCWD, "", 0), -1); > + TEST_COMPARE (errno, ENOENT); > + { > + int fd_tree = open_tree (AT_FDCWD, "/tmp", > + OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC); > + TEST_VERIFY (fd_tree != -1); OK. > + } > + > + _exit (0); > +} > + > +static int > +do_test (void) > +{ > + support_become_root (); > + > + pid_t pid = xfork (); > + if (pid == 0) > + subprocess (); > + > + int status; > + xwaitpid (pid, &status, 0); > + TEST_VERIFY (WIFEXITED (status)); > + > + return 0; > +} > + > +#include -- Cheers, Carlos.