From patchwork Fri Aug 10 02:53:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Yang X-Patchwork-Id: 955308 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cn.fujitsu.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41mDNv0NnHz9ryt for ; Thu, 9 Aug 2018 13:33:17 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id C0B7A3E77C2 for ; Thu, 9 Aug 2018 05:33:14 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id 9D8AF3E772B for ; Thu, 9 Aug 2018 05:33:12 +0200 (CEST) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by in-2.smtp.seeweb.it (Postfix) with ESMTP id AD785600C01 for ; Thu, 9 Aug 2018 05:33:11 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="43266863" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Aug 2018 11:33:07 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 4B00C4B69E17 for ; Thu, 9 Aug 2018 11:33:04 +0800 (CST) Received: from RHEL7U5Alpha_SERVER.g08.fujitsu.local (10.167.220.156) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.399.0; Thu, 9 Aug 2018 11:33:15 +0800 From: Xiao Yang To: Date: Fri, 10 Aug 2018 10:53:42 +0800 Message-ID: <1533869622-23362-1-git-send-email-yangx.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.167.220.156] X-yoursite-MailScanner-ID: 4B00C4B69E17.A8908 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: yangx.jy@cn.fujitsu.com X-Spam-Status: No, score=2.5 required=7.0 tests=DATE_IN_FUTURE_12_24 autolearn=disabled version=3.4.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH] syscalls/fgetxattr02.c: Fix errno EPERM on older kernels X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" According to commit 3d2ae5e in LTP, fgetxattr()/getxattr() will set errno to 'EPERM' when fd/file is not a regular file and directory before kernel 3.0.0. This errno is changed to ENODATA by commit 55b23bd in kernel, so we accept EPERM in older kernels. Signed-off-by: Xiao Yang --- testcases/kernel/syscalls/fgetxattr/fgetxattr02.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/testcases/kernel/syscalls/fgetxattr/fgetxattr02.c b/testcases/kernel/syscalls/fgetxattr/fgetxattr02.c index 98a141b..888e29a 100644 --- a/testcases/kernel/syscalls/fgetxattr/fgetxattr02.c +++ b/testcases/kernel/syscalls/fgetxattr/fgetxattr02.c @@ -185,6 +185,14 @@ static void verify_fgetxattr(unsigned int i) tc[i].fname + OFFSET); } + /* + * Before kernel 3.0.0, fgetxattr(2) will set errno with 'EPERM' + * when the file is not a regular file and directory, refer to + * commitid 55b23bd + */ + if (tc[i].exp_err == ENODATA && tst_kvercmp(3, 0, 0) < 0) + tc[i].exp_err = EPERM; + if (tc[i].exp_err == TST_ERR) { tst_res(TPASS | TTERRNO, "fgetxattr(2) on %s passed", tc[i].fname + OFFSET);