Received: by 2002:a17:90a:37a3:0:0:0:0 with SMTP id v32csp4111560pjb; Mon, 10 Jun 2019 10:36:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqy79idqJHV0y7PR1PD9NNlUaH3kBZAO2EAlLjbljSkC0veNDLRslaDjjopGBGIKFiMP7ecP X-Received: by 2002:aa7:9087:: with SMTP id i7mr18234713pfa.40.1560188198138; Mon, 10 Jun 2019 10:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560188198; cv=none; d=google.com; s=arc-20160816; b=Xjah+WnfC+zR3+xYh+S6umkNlQzUDSdSNdB37l7A9ZQSmdHJdwpM32JD3iDi52g5rU /mq14nx89BZcj5xUV2pqdLDHncWtU/mHQAnwtXIRjWwrNOBkQQ6C+ilzuzm+qiuvsJlU RgtgJxrexN2UFsQfAHQW0coP+eAitmaZY5159i6fUxG1v6wFA/o5vQCxACSV9EKoOnyx MUEFJLYuDsIP02XgAw2QpITwtATWHIh/DfZsvA8k2cZbsl9SGqa9e8aLNz4zDK10R6yo 4+KWCiEE5eorngBRzRPzGKGWVdWnI94BtYdgk6mgm/GaPNkPx9so0WcRFQRDUhhNx2OE AzYQ== 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=buAsohwpVmD3OdGiTU5B8RgcPdFBNHhQuftDbHIHIUE=; b=ivewgN8bPC5quemtkD2wE4R9ne1PNyZua3AlAiad/XfneZAPkcWa342db3GRmtAyy5 Eg2+iuwfckNqwWCPKX3u95M5vgq0JNj73gMvFmX6FOgowQJ9loFKBbJHRY5Pq75cy190 5s3FC/kTEtow9v6cGkSrL7eA6fH54mOIm2nh90uzsFt3zjI4gFGVrD1eDt7xtvANhqXS ggipP1v7bPWcyydE85nxFDNmo900iX5DdGknSAdDvIehXRIU88zT9Bt60RymEuHAt9/D erytXhb8hYcD/cNbj22zjdLht6P1sdOS6K/MwNRwobk11lvVIPOpNpHukI1fFOCUK/he nO2Q== 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 64si11140979pfd.278.2019.06.10.10.36.19; Mon, 10 Jun 2019 10:36:38 -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 S2388107AbfFJRft (ORCPT + 99 others); Mon, 10 Jun 2019 13:35:49 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:58558 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387750AbfFJRft (ORCPT ); Mon, 10 Jun 2019 13:35:49 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 759AF260195 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: Mon, 10 Jun 2019 13:35:40 -0400 Message-Id: <20190610173541.20511-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..43f2d77d706c --- /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}" +} -- 2.20.1