Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5975343ybi; Wed, 12 Jun 2019 11:42:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTrNZNkTiz1sSIZD5iMX7niG5UzbixHbC6+pjPO/H+rpx5EXWsmMeVVW9yLOrZgUopDnfM X-Received: by 2002:a17:902:76c3:: with SMTP id j3mr56600992plt.116.1560364935014; Wed, 12 Jun 2019 11:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560364935; cv=none; d=google.com; s=arc-20160816; b=NfWWKtT8aWOalSmDq8d5aF2sNzaZmPrBrIqhpRLOnKMrfrFZiDAqIfdYeduqfrvLe3 FOTMEomFd6sls292pFp3WC63pvsPiilMn5AgAsxeZd7XqfEmKxSS640Lvypy0G0UKxNW Lc+v5a0y2ed5R6VC2Y5z9gVlTaL2EiUpqexebPRghaZEZQU54Tm9VXUwszLvcX167Ld9 WsjYBqUmyTXkZVTtzyXmtbqyClL7bCu96iWGVc95RyUmJPcUZgfhMRZz92aCdc7nXhgs 2VF2r77QGxh9nP/ZhBkgDfegpbRhbeFH7Xzg5X5h06ibD6hGnVzFncLs4hvjjq3B8HHG g5qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=e22J4sJUTZos6LCN7pREXRGkssiblrDUUZx4KE3uYcM=; b=g8U6M0zzVhoh8ogwA7+geApiXLJCMEUofSY9Ud8BVQ3KLtLSQxeh0FMULPdQe2rnej iZ2dEzyIn6uPFkd1gCp7/6Ta2fgLwzoEM+WyAUwYOKdmeQP1HWJHbX1MeseARVi2rcTU LJ24aw5oFt/n89/vnCR7I0ENP9/aNpJ5DQRtId/yfmGLD74OKx7Xhh9NMgdwoerWxgrd nPes4242YGaNweJiSe6Mo/RCFraYdFMLiJTMEhSoLMhB4zLmOZLE8fiW58m4sUT0h4PL l67bQUPtuCuOap6yiiRicB/w+IuduGU9Vn4JLD5SDyi3MdI1MNzcmhYArIkCSJaM2jNL SEpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cj16si397194plb.239.2019.06.12.11.42.01; Wed, 12 Jun 2019 11:42:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728503AbfFLSkm (ORCPT + 99 others); Wed, 12 Jun 2019 14:40:42 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:47570 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726724AbfFLSkm (ORCPT ); Wed, 12 Jun 2019 14:40:42 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id D20092610C6 From: Gabriel Krisman Bertazi To: tytso@mit.edu Cc: fstests@vger.kernel.org, linux-ext4@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH v3 1/2] common/casefold: Add infrastructure to test filename casefold feature Date: Wed, 12 Jun 2019 14:40:32 -0400 Message-Id: <20190612184033.21845-1-krisman@collabora.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Add a set of basic helper functions to simplify the testing of casefolding capable filesystems. Signed-off-by: Gabriel Krisman Bertazi --- common/casefold | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 common/casefold diff --git a/common/casefold b/common/casefold new file mode 100644 index 000000000000..df01029a3d44 --- /dev/null +++ b/common/casefold @@ -0,0 +1,92 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2019 Collabora, Ltd. All Rights Reserved. +# +# Common functions for testing filename casefold feature + +_has_casefold_kernel_support() +{ + case $FSTYP in + ext4) + test -f '/sys/fs/ext4/features/casefold' + ;; + *) + # defaults to unsupported + false + ;; + esac +} + +_require_scratch_casefold() +{ + if ! _has_casefold_kernel_support ; then + _notrun "$FSTYP does not support casefold feature" + fi + + if ! _scratch_mkfs_casefold &>>seqres.full; then + _notrun "$FSTYP userspace tools do not support casefold" + fi + + # Make sure the kernel can mount a filesystem with the encoding + # defined by the userspace tools. This will fail if + # the userspace tool used a more recent encoding than the one + # supported in kernel space. + if ! _try_scratch_mount &>>seqres.full; then + _notrun \ + "kernel can't mount filesystem with the encoding set by userspace" + fi + _scratch_unmount + + # utilities used by casefold + _require_command "$CHATTR_PROG" chattr + _require_command "$LSATTR_PROG" lsattr +} + +_scratch_mkfs_casefold() +{ + case $FSTYP in + ext4) + _scratch_mkfs -O casefold $* + ;; + *) + _notrun "Don't know how to mkfs with casefold support on $FSTYP" + ;; + esac +} + +_scratch_mkfs_casefold_strict() +{ + case $FSTYP in + ext4) + _scratch_mkfs -O casefold -E encoding_flags=strict + ;; + *) + _notrun \ + "Don't know how to mkfs with casefold-strict support on $FSTYP" + ;; + esac +} + +# To get the exact disk name, we need some method that does a +# getdents() on the parent directory, such that we don't get +# normalized/casefolded results. 'Find' works ok. +_casefold_check_exact_name() +{ + local basedir=$1 + local exact_name=$2 + find ${basedir} | grep -q ${exact_name} +} + +_casefold_set_attr() +{ + $CHATTR_PROG +F "${1}" +} + +_casefold_unset_attr() +{ + $CHATTR_PROG -F "${1}" +} + +_casefold_lsattr_dir() +{ + $LSATTR_PROG -ld "${1}" | _filter_spaces +} -- 2.20.1