Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8491233ybi; Thu, 6 Jun 2019 13:18:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxYYWZ4pgsbRJQR10mhcpM/KD1ccXSjmAk4XtLqj6UFQ1ZvMM0F+Nc2w5bp9QcH0H5/gzh X-Received: by 2002:a17:902:b18f:: with SMTP id s15mr53526507plr.44.1559852280529; Thu, 06 Jun 2019 13:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559852280; cv=none; d=google.com; s=arc-20160816; b=1Cy1HwoAU8Z1+8J0y1K0utanZFffuyHYENSl39HkDkVIrb9xhTYZceIl8zlEeo2fM7 jU8yW0dlxF4/5FXg3sgnnQ6drL2kvlmqKG31lDhLUUatV7rdDD2QzIKq87xbghFKfq9j 4zJeG8YjKjXaYJXZJfAGGPRgJUuikErUd+2j/5OrusUWJtLm8inO+oevS0UX4hr5k2fA 0bWUygK/7PE2BuFs14a8sUWC6go1l7jnBHJqsj0sdhQJCZWXMA+FP+F8OTB7RoE9vis3 nt3jFHjw6shKajtt4Wa4wdA9XN0uRz4f59aYeOp1tXBYtXzSQA6ZQCwEih1Gi/mhNhrg WdsQ== 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=t/geMuFLF0xyzRNyG3SOROAnJropBTLWhCtgnPMB4jM=; b=NEYjvhuAIWPbM4B960rXW9ACxzLRPyp63/9UMLEh6Rx84NCbYwWqabuZ1UyBP+UAxG yYNbh+ZGe6//pKlEGCDgb8ol8k5vca8zgqMUWszbpXu9n3TcuinMH4nk9I/cXCHyoVZf uKe7m45VRlC3YMRFvlCqujZjoN0F1Djx8RNrvInqwbLR9RCiuaDx7pTQyCyxFKdr69iY Hju2GoR3XG/tnRvl9jL33IJCmn6K5U8oDLnLRnY+4mUCZrdIi0sizptMlv94eni/frCY L9/AgofBpueHWcY5uTiQfT02MYo4bBuWD8zc2fsLdx+9HEOdOm3E6osITUmTfKn2kafA eHrw== 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 d15si2654320pfn.56.2019.06.06.13.17.39; Thu, 06 Jun 2019 13:18:00 -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 S1726373AbfFFTbw (ORCPT + 99 others); Thu, 6 Jun 2019 15:31:52 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:60352 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726077AbfFFTbw (ORCPT ); Thu, 6 Jun 2019 15:31:52 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 37662283DB8 From: Gabriel Krisman Bertazi To: tytso@mit.edu Cc: fstests@vger.kernel.org, linux-ext4@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH v2 1/2] common/casefold: Add infrastructure to test filename casefold feature Date: Thu, 6 Jun 2019 15:31:37 -0400 Message-Id: <20190606193138.25852-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 | 108 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 common/casefold diff --git a/common/casefold b/common/casefold new file mode 100644 index 000000000000..34c1d4ae1af1 --- /dev/null +++ b/common/casefold @@ -0,0 +1,108 @@ +#----------------------------------------------------------------------- +# +# Common functions for testing filename casefold feature +# +#----------------------------------------------------------------------- +# Copyright (c) 2018 Collabora, Ltd. All Rights Reserved. +# +# Author: Gabriel Krisman Bertazi +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- + +_has_casefold_feature_kernel_support() { + case $FSTYP in + ext4) + test -f '/sys/fs/ext4/features/casefold' + ;; + *) + # defaults to unsupported + false + ;; + esac +} + +_require_casefold_support() { + if ! _has_casefold_feature_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 using the encoding set by userspace" + fi + _scratch_unmount +} + +_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 +} + +_casefold_check_exact_name () { + # 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. + basedir=$1 + exact_name=$2 + find ${basedir} | grep -q ${exact_name} +} + +_try_set_casefold_attr () { + chattr +F "${1}" &>/dev/null +} + +_try_unset_casefold_attr () { + chattr -F "${1}" &>/dev/null +} + +_set_casefold_attr () { + _try_set_casefold_attr "${1}" || \ + _fail "Unable to set casefold attribute on ${1}" +} + +_unset_casefold_attr () { + _try_unset_casefold_attr "${1}" || \ + _fail "Unable to unset casefold attribute on ${1}" +} + +_is_casefolded_dir () { + lsattr -ld "${1}" | grep -q "Casefold" +} -- 2.20.1