From patchwork Fri Aug 19 17:51:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zorro Lang X-Patchwork-Id: 9290733 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 730A76077B for ; Fri, 19 Aug 2016 17:52:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6800E29534 for ; Fri, 19 Aug 2016 17:52:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C30629536; Fri, 19 Aug 2016 17:52:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from oss.sgi.com (oss.sgi.com [192.48.182.195]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B28CF29534 for ; Fri, 19 Aug 2016 17:52:00 +0000 (UTC) Received: from oss.sgi.com (localhost [IPv6:::1]) by oss.sgi.com (Postfix) with ESMTP id 8524C7CA3; Fri, 19 Aug 2016 12:51:56 -0500 (CDT) X-Original-To: xfs@oss.sgi.com Delivered-To: xfs@oss.sgi.com Received: from relay.sgi.com (relay3.corp.sgi.com [198.149.34.15]) by oss.sgi.com (Postfix) with ESMTP id CA3137CA2 for ; Fri, 19 Aug 2016 12:51:54 -0500 (CDT) Received: from cuda.sgi.com (cuda3.sgi.com [192.48.176.15]) by relay3.corp.sgi.com (Postfix) with ESMTP id 3F857AC004 for ; Fri, 19 Aug 2016 10:51:51 -0700 (PDT) X-ASG-Debug-ID: 1471629109-0bf57c55b268b50001-NocioJ Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by cuda.sgi.com with ESMTP id uAogkGNEgfuFrEAy (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Fri, 19 Aug 2016 10:51:50 -0700 (PDT) X-Barracuda-Envelope-From: zlang@redhat.com X-Barracuda-Effective-Source-IP: mx1.redhat.com[209.132.183.28] X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-ASG-Whitelist: Client Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E78F43A39; Fri, 19 Aug 2016 17:51:49 +0000 (UTC) Received: from localhost (vpn1-4-252.pek2.redhat.com [10.72.4.252]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7JHpll6002927; Fri, 19 Aug 2016 13:51:48 -0400 From: Zorro Lang To: fstests@vger.kernel.org Subject: [PATCH 1/2] common/rc: add functions to check or write objects under /sys/fs/$FSTYP Date: Sat, 20 Aug 2016 01:51:44 +0800 X-ASG-Orig-Subj: [PATCH 1/2] common/rc: add functions to check or write objects under /sys/fs/$FSTYP Message-Id: <1471629105-13359-1-git-send-email-zlang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 19 Aug 2016 17:51:49 +0000 (UTC) X-Barracuda-Connect: mx1.redhat.com[209.132.183.28] X-Barracuda-Start-Time: 1471629110 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://192.48.176.15:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 1800 X-Virus-Scanned: by bsmtpd at sgi.com X-Barracuda-BRTS-Status: 1 Cc: Zorro Lang , xfs@oss.sgi.com X-BeenThere: xfs@oss.sgi.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com X-Virus-Scanned: ClamAV using ClamSMTP XFS add more configurations in /sys/fs/xfs recently. For use them, this patch add some common functions for: 1. "require" a file/dir in /sys/fs/${FSTYP}. 2. write a file in /sys/fs/${FSTYP}. For common use, these functions can be used by other filesystems. Signed-off-by: Zorro Lang --- common/rc | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/common/rc b/common/rc index 51092a0..d5edfef 100644 --- a/common/rc +++ b/common/rc @@ -3556,6 +3556,48 @@ run_fsx() fi } +# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/$DEV/$ENTRY +_require_fs_sysfs() +{ + local dev=$1 + local entry=$2 + local tmp_mnt=`mktemp -d` + + if [ ! -b "$dev" -o -z "$entry" ];then + _fail "Usage: _require_fs_sysfs " + fi + + local dname=$(_short_dev $dev) + _mount -t $FSTYP `_common_dev_mount_options` $dev $tmp_mnt + if [ $? -ne 0 ];then + rm -f $tmp_mnt + _fail "_require_fs_sysfs: could not mount, mkfs first in your test?" + elif [ ! -e /sys/fs/${FSTYP}/${dname}/${entry} ];then + $UMOUNT_PROG $tmp_mnt + rm -f $tmp_mnt + _notrun "/sys/fs/${FSTYP}/${dname}/${entry}: No such file or directory" + fi + $UMOUNT_PROG $tmp_mnt + rm -rf $tmp_mnt +} + +# Write "content" into /sys/fs/$FSTYP/$DEV/$ENTRY +_set_fs_sysfs_param() +{ + local dev=$1 + shift + local entry=$1 + shift + local content="$*" + + if [ ! -b "$dev" -o -z "$entry" -o -z "$content" ];then + _fail "Usage: _set_sys_fs_param " + fi + + local dname=$(_short_dev $dev) + echo "$content" > /sys/fs/${FSTYP}/${dname}/${entry} +} + init_rc ################################################################################