From patchwork Thu Oct 21 15:15:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenz Bauer X-Patchwork-Id: 12575473 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D161AC433F5 for ; Thu, 21 Oct 2021 15:16:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC41361052 for ; Thu, 21 Oct 2021 15:16:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231861AbhJUPSW (ORCPT ); Thu, 21 Oct 2021 11:18:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231828AbhJUPSQ (ORCPT ); Thu, 21 Oct 2021 11:18:16 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76867C06122E for ; Thu, 21 Oct 2021 08:16:00 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id p21so47569wmq.1 for ; Thu, 21 Oct 2021 08:16:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k+el4LssRR48MXi9zHjZky4nWABgnOCsHjGg/d8oAg4=; b=FsnxtymjLqZS2VFG04DvIpLqgieKtVBHjHP93zwTtnR5kU0AQ0H7Txhivy0MI6r3F+ 4ti4PHUooqoxlBofAnmjSThJWtmu00KP3f4qIow3SpAzH8sOiz2MUHysGzF0AqYS8isQ X/khq1aIqEF1IRXsINLNgw93KFmokB2bYNY5I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k+el4LssRR48MXi9zHjZky4nWABgnOCsHjGg/d8oAg4=; b=kJoMY0REFTazfLJVO9mzzOIW6ULGXySXwleCO2SAwbywPFpp9Jkaf4bPJDCZhHcu0L vb9PcI8Fc+wZQ/mzChQpkHIm2QyRpETOM+3shYvSh74/uARG8w5PvlFyn5v/owg2KVoJ sXzzuB1xe9yjWqfUj8VZAYKS97zrmuSrlT7/G4CXc3yxdHYxsiQVlH+WNyNhxDzjQ0dA PHNlLsjHRMHzZ09dihMDjeLKvtJQUYrSSLAFibUSMBhuWulmSeIV7uAXcSKkO1wBpIvJ F+tw+saceNQ9cleVXoC73cWmHDFdpiOKMrYJxjhP/RodKddu804rFWWUO8aT84yBcdPh XaGA== X-Gm-Message-State: AOAM530/TN3czJJV5FdvXZSO+iJXhO8NE5wz5Lsj4fsynL6vYWHvPZ1+ /fDud+CzZxLq9sSeqjDMFQXpfg== X-Google-Smtp-Source: ABdhPJy2h51ESbpe/ACQzNHuZP5xG4x2CZXy7D5ddfeiaaqbvULX+oBLkAEKf1/ueSmOhDE9tPdDhg== X-Received: by 2002:a7b:c183:: with SMTP id y3mr21815596wmi.2.1634829359046; Thu, 21 Oct 2021 08:15:59 -0700 (PDT) Received: from altair.lan (7.2.6.0.8.8.2.4.4.c.c.f.b.1.5.4.f.f.6.2.a.5.a.7.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:7a5a:26ff:451b:fcc4:4288:627]) by smtp.googlemail.com with ESMTPSA id z1sm5098562wrt.94.2021.10.21.08.15.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 08:15:58 -0700 (PDT) From: Lorenz Bauer To: Alexander Viro , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: kernel-team@cloudflare.com, Lorenz Bauer , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH bpf-next v2 1/3] libfs: support RENAME_EXCHANGE in simple_rename() Date: Thu, 21 Oct 2021 16:15:26 +0100 Message-Id: <20211021151528.116818-2-lmb@cloudflare.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211021151528.116818-1-lmb@cloudflare.com> References: <20211021151528.116818-1-lmb@cloudflare.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Allow atomic exchange via RENAME_EXCHANGE when using simple_rename. This affects binderfs, ramfs, hubetlbfs and bpffs. There isn't much to do except update the various *time fields. Signed-off-by: Lorenz Bauer --- fs/libfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/libfs.c b/fs/libfs.c index 51b4de3b3447..93c03d593749 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -455,9 +455,12 @@ int simple_rename(struct user_namespace *mnt_userns, struct inode *old_dir, struct inode *inode = d_inode(old_dentry); int they_are_dirs = d_is_dir(old_dentry); - if (flags & ~RENAME_NOREPLACE) + if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE)) return -EINVAL; + if (flags & RENAME_EXCHANGE) + goto done; + if (!simple_empty(new_dentry)) return -ENOTEMPTY; @@ -472,6 +475,7 @@ int simple_rename(struct user_namespace *mnt_userns, struct inode *old_dir, inc_nlink(new_dir); } +done: old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime = new_dir->i_mtime = inode->i_ctime = current_time(old_dir); From patchwork Thu Oct 21 15:15:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenz Bauer X-Patchwork-Id: 12575475 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD5C9C433F5 for ; Thu, 21 Oct 2021 15:16:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6B0460F46 for ; Thu, 21 Oct 2021 15:16:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231618AbhJUPSe (ORCPT ); Thu, 21 Oct 2021 11:18:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231931AbhJUPSS (ORCPT ); Thu, 21 Oct 2021 11:18:18 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DAA8C061226 for ; Thu, 21 Oct 2021 08:16:02 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id r18so47774wrg.6 for ; Thu, 21 Oct 2021 08:16:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r3QcDl+qrCs7DfRcj3nDkgEldBtCcz4guF3zRxr4yw0=; b=og8TLQCkdYW+NTgs03kMNvaz85gbJZg01RThVaPc9dwl+VDpWo6GQ80zhvw97gozGW /ThwmKTl7rcmU4ax2Ak+CNU8sdByHuVjxOOD6MeUCDsw44kWshPNXlvzS1uO4s4lZcGb 9Zp4gZ9IO2XlC3e9KEMticcIkxx81rUt0Cn2w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r3QcDl+qrCs7DfRcj3nDkgEldBtCcz4guF3zRxr4yw0=; b=8NI+dCAqvm5pe1yn2jfYn3NwU+EuGpPSZmGJrAO61h1bHIcd0VGTdJ76yq1xMvpORa aFa1rKOwGgJ3ylgxzAGUe9ojIWclJqfG7SLu/C2kOUCJJevBMbIauzqsDtvHBOKTMHca Fo1dTi1NGfeAO7Tqh8YqzpVQled9Ur6ZXxCv/gJ7bozeSOKoxAsgNq+Kp26tIN4I/BcJ SyKF4yPTS5k4i8miDFHojnCFQKjFfOq4r/s5UjLDAS5Pd1NhlWpnzHiR/AICKAhz5Kv3 Ma4EMux01jgw7oM4/27Y7OZoXVFOfNMBTLaNev0OfRE3KkJ35VIyNfKwNhL8lasAiA9d sd5Q== X-Gm-Message-State: AOAM533c1VtJydJubFRUedzQa4qUV9Wm7YjQPV8T3sBgeiz0szzIjS67 oYzz8FeOVJtdgHmFqS/Ny9Tpiw== X-Google-Smtp-Source: ABdhPJyBjBioVdWACxdF2OFHo6mJ7WSHI3iwB7rn3GgXXX+lutNDfML5XgLhY7C35UZMHI5B2m7H+w== X-Received: by 2002:a5d:524b:: with SMTP id k11mr2472685wrc.259.1634829360154; Thu, 21 Oct 2021 08:16:00 -0700 (PDT) Received: from altair.lan (7.2.6.0.8.8.2.4.4.c.c.f.b.1.5.4.f.f.6.2.a.5.a.7.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:7a5a:26ff:451b:fcc4:4288:627]) by smtp.googlemail.com with ESMTPSA id z1sm5098562wrt.94.2021.10.21.08.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 08:15:59 -0700 (PDT) From: Lorenz Bauer To: Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: kernel-team@cloudflare.com, Lorenz Bauer , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v2 2/3] selftests: bpf: convert test_bpffs to ASSERT macros Date: Thu, 21 Oct 2021 16:15:27 +0100 Message-Id: <20211021151528.116818-3-lmb@cloudflare.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211021151528.116818-1-lmb@cloudflare.com> References: <20211021151528.116818-1-lmb@cloudflare.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Remove usage of deprecated CHECK macros. Signed-off-by: Lorenz Bauer --- .../selftests/bpf/prog_tests/test_bpffs.c | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/test_bpffs.c b/tools/testing/selftests/bpf/prog_tests/test_bpffs.c index 172c999e523c..533e3f3a459a 100644 --- a/tools/testing/selftests/bpf/prog_tests/test_bpffs.c +++ b/tools/testing/selftests/bpf/prog_tests/test_bpffs.c @@ -29,43 +29,43 @@ static int read_iter(char *file) static int fn(void) { - int err, duration = 0; + int err; err = unshare(CLONE_NEWNS); - if (CHECK(err, "unshare", "failed: %d\n", errno)) + if (!ASSERT_OK(err, "unshare")) goto out; err = mount("", "/", "", MS_REC | MS_PRIVATE, NULL); - if (CHECK(err, "mount /", "failed: %d\n", errno)) + if (!ASSERT_OK(err, "mount /")) goto out; err = umount(TDIR); - if (CHECK(err, "umount " TDIR, "failed: %d\n", errno)) + if (!ASSERT_OK(err, "umount " TDIR)) goto out; err = mount("none", TDIR, "tmpfs", 0, NULL); - if (CHECK(err, "mount", "mount root failed: %d\n", errno)) + if (!ASSERT_OK(err, "mount tmpfs")) goto out; err = mkdir(TDIR "/fs1", 0777); - if (CHECK(err, "mkdir "TDIR"/fs1", "failed: %d\n", errno)) + if (!ASSERT_OK(err, "mkdir " TDIR "/fs1")) goto out; err = mkdir(TDIR "/fs2", 0777); - if (CHECK(err, "mkdir "TDIR"/fs2", "failed: %d\n", errno)) + if (!ASSERT_OK(err, "mkdir " TDIR "/fs2")) goto out; err = mount("bpf", TDIR "/fs1", "bpf", 0, NULL); - if (CHECK(err, "mount bpffs "TDIR"/fs1", "failed: %d\n", errno)) + if (!ASSERT_OK(err, "mount bpffs " TDIR "/fs1")) goto out; err = mount("bpf", TDIR "/fs2", "bpf", 0, NULL); - if (CHECK(err, "mount bpffs " TDIR "/fs2", "failed: %d\n", errno)) + if (!ASSERT_OK(err, "mount bpffs " TDIR "/fs2")) goto out; err = read_iter(TDIR "/fs1/maps.debug"); - if (CHECK(err, "reading " TDIR "/fs1/maps.debug", "failed\n")) + if (!ASSERT_OK(err, "reading " TDIR "/fs1/maps.debug")) goto out; err = read_iter(TDIR "/fs2/progs.debug"); - if (CHECK(err, "reading " TDIR "/fs2/progs.debug", "failed\n")) + if (!ASSERT_OK(err, "reading " TDIR "/fs2/progs.debug")) goto out; out: umount(TDIR "/fs1"); From patchwork Thu Oct 21 15:15:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenz Bauer X-Patchwork-Id: 12575477 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6832C4332F for ; Thu, 21 Oct 2021 15:16:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF99561052 for ; Thu, 21 Oct 2021 15:16:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231702AbhJUPSf (ORCPT ); Thu, 21 Oct 2021 11:18:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232059AbhJUPST (ORCPT ); Thu, 21 Oct 2021 11:18:19 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA9E2C06122A for ; Thu, 21 Oct 2021 08:16:03 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 67-20020a1c1946000000b0030d4c90fa87so37529wmz.2 for ; Thu, 21 Oct 2021 08:16:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wPEEI/42En9uKSJ0rR6svxJibQPpLgl3/xd+Q1CAzs4=; b=ArwVTh3EaIjsFaD/Zbzk2v9QkwA3pWqH34r8L0lMMOpk5RFI4xI5zowgC5WNu3NqO5 1kyrUBKSFJi7H2zK6/4d5xiODpuHqkWpcmN4WOp0LS6RRGmtvOpZ9JCaxt8m2Cz714ai QDV0et2cSifjt23YweKmZ8SMST9HKxMXkJCDk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wPEEI/42En9uKSJ0rR6svxJibQPpLgl3/xd+Q1CAzs4=; b=GYICugr1bLJJtM1+w5XKDXJbYgpsWrttxVwX3ibSoIS0QBGw1OTY1lIMjiihgjkEi5 SpZ+DnG0uyDzEXaTJKMXzr7eWDfKv9G2kGeeY9RGNRGDwSa76WYN4MgGDg0q3GNuFg5t VeRuO+pzTsZieAJQPjM1DFm9lw4RtJnKh+23fomG9bWXiETTkEyk8jsx3YRxuWHlMc0f YVNuJtMgzYC5jmEVTn4u9km8k5y+WVjqaag2eX1C0blOU83JO7UpJWnRJg7Spc58ChTt qLi1GQb1alYz4pm9n1kWzYjhmwmF1bm000jdwBOiKjkPm+Gas2qFkFjP4Hv9tLxbClSw n8oA== X-Gm-Message-State: AOAM533VlkIHyzMFm/WMWtheZ8spT4nClEh0DbEsCCQmtRIVwsOwid32 LU5myqQ+u+Izv8lHZjTKm2nd5Q== X-Google-Smtp-Source: ABdhPJydPjkzgQW2iWvviw52oqi+ooJKj874Q5kNQJaDXzYi3gfB4tnn05PuwBzIoPhuvzR9ZiHLVQ== X-Received: by 2002:a7b:c30c:: with SMTP id k12mr22015678wmj.38.1634829362115; Thu, 21 Oct 2021 08:16:02 -0700 (PDT) Received: from altair.lan (7.2.6.0.8.8.2.4.4.c.c.f.b.1.5.4.f.f.6.2.a.5.a.7.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:7a5a:26ff:451b:fcc4:4288:627]) by smtp.googlemail.com with ESMTPSA id z1sm5098562wrt.94.2021.10.21.08.16.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 08:16:01 -0700 (PDT) From: Lorenz Bauer To: Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: kernel-team@cloudflare.com, Lorenz Bauer , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v2 3/3] selftests: bpf: test RENAME_EXCHANGE and RENAME_NOREPLACE on bpffs Date: Thu, 21 Oct 2021 16:15:28 +0100 Message-Id: <20211021151528.116818-4-lmb@cloudflare.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211021151528.116818-1-lmb@cloudflare.com> References: <20211021151528.116818-1-lmb@cloudflare.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Add tests to exercise the behaviour of RENAME_EXCHANGE and RENAME_NOREPLACE on bpffs. The former checks that after an exchange the inode of two directories has changed. The latter checks that the source still exists after a failed rename. Signed-off-by: Lorenz Bauer --- .../selftests/bpf/prog_tests/test_bpffs.c | 65 ++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/prog_tests/test_bpffs.c b/tools/testing/selftests/bpf/prog_tests/test_bpffs.c index 533e3f3a459a..d29ebfeef9c5 100644 --- a/tools/testing/selftests/bpf/prog_tests/test_bpffs.c +++ b/tools/testing/selftests/bpf/prog_tests/test_bpffs.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2020 Facebook */ #define _GNU_SOURCE +#include #include #include #include @@ -29,7 +30,8 @@ static int read_iter(char *file) static int fn(void) { - int err; + struct stat a, b, c; + int err, map; err = unshare(CLONE_NEWNS); if (!ASSERT_OK(err, "unshare")) @@ -67,6 +69,67 @@ static int fn(void) err = read_iter(TDIR "/fs2/progs.debug"); if (!ASSERT_OK(err, "reading " TDIR "/fs2/progs.debug")) goto out; + + err = mkdir(TDIR "/fs1/a", 0777); + if (!ASSERT_OK(err, "creating " TDIR "/fs1/a")) + goto out; + err = mkdir(TDIR "/fs1/a/1", 0777); + if (!ASSERT_OK(err, "creating " TDIR "/fs1/a/1")) + goto out; + err = mkdir(TDIR "/fs1/b", 0777); + if (!ASSERT_OK(err, "creating " TDIR "/fs1/b")) + goto out; + + map = bpf_create_map(BPF_MAP_TYPE_ARRAY, 4, 4, 1, 0); + if (!ASSERT_GT(map, 0, "create_map(ARRAY)")) + goto out; + err = bpf_obj_pin(map, TDIR "/fs1/c"); + if (!ASSERT_OK(err, "pin map")) + goto out; + close(map); + + /* Check that RENAME_EXCHANGE works for directories. */ + err = stat(TDIR "/fs1/a", &a); + if (!ASSERT_OK(err, "stat(" TDIR "/fs1/a)")) + goto out; + err = renameat2(0, TDIR "/fs1/a", 0, TDIR "/fs1/b", RENAME_EXCHANGE); + if (!ASSERT_OK(err, "renameat2(/fs1/a, /fs1/b, RENAME_EXCHANGE)")) + goto out; + err = stat(TDIR "/fs1/b", &b); + if (!ASSERT_OK(err, "stat(" TDIR "/fs1/b)")) + goto out; + if (!ASSERT_EQ(a.st_ino, b.st_ino, "b should have a's inode")) + goto out; + err = access(TDIR "/fs1/b/1", F_OK); + if (!ASSERT_OK(err, "access(" TDIR "/fs1/b/1)")) + goto out; + + /* Check that RENAME_EXCHANGE works for mixed file types. */ + err = stat(TDIR "/fs1/c", &c); + if (!ASSERT_OK(err, "stat(" TDIR "/fs1/map)")) + goto out; + err = renameat2(0, TDIR "/fs1/c", 0, TDIR "/fs1/b", RENAME_EXCHANGE); + if (!ASSERT_OK(err, "renameat2(/fs1/c, /fs1/b, RENAME_EXCHANGE)")) + goto out; + err = stat(TDIR "/fs1/b", &b); + if (!ASSERT_OK(err, "stat(" TDIR "/fs1/b)")) + goto out; + if (!ASSERT_EQ(c.st_ino, b.st_ino, "b should have c's inode")) + goto out; + err = access(TDIR "/fs1/c/1", F_OK); + if (!ASSERT_OK(err, "access(" TDIR "/fs1/c/1)")) + goto out; + + /* Check that RENAME_NOREPLACE works. */ + err = renameat2(0, TDIR "/fs1/b", 0, TDIR "/fs1/a", RENAME_NOREPLACE); + if (!ASSERT_ERR(err, "renameat2(RENAME_NOREPLACE)")) { + err = -EINVAL; + goto out; + } + err = access(TDIR "/fs1/b", F_OK); + if (!ASSERT_OK(err, "access(" TDIR "/fs1/b)")) + goto out; + out: umount(TDIR "/fs1"); umount(TDIR "/fs2");