From patchwork Fri Aug 23 09:25:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 11111129 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9BF2813B1 for ; Fri, 23 Aug 2019 09:25:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B7C221726 for ; Fri, 23 Aug 2019 09:25:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727142AbfHWJZn (ORCPT ); Fri, 23 Aug 2019 05:25:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47896 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725857AbfHWJZn (ORCPT ); Fri, 23 Aug 2019 05:25:43 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 08F4210F23E9; Fri, 23 Aug 2019 09:25:43 +0000 (UTC) Received: from pegasus.maiolino.com (unknown [10.40.205.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E03D60933; Fri, 23 Aug 2019 09:25:42 +0000 (UTC) From: Carlos Maiolino To: fstests@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH] t_stripealign: Fix fibmap error handling Date: Fri, 23 Aug 2019 11:25:30 +0200 Message-Id: <20190823092530.11797-1-cmaiolino@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Fri, 23 Aug 2019 09:25:43 +0000 (UTC) Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org FIBMAP only returns a negative value when the underlying filesystem does not support FIBMAP or on permission error. For the remaining errors, i.e. those usually returned from the filesystem itself, zero will be returned. We can not trust a zero return from the FIBMAP, and such behavior made generic/223 succeed when it should not. Also, we can't use perror() only to print errors when FIBMAP failed, or it will simply print 'success' when a zero is returned. Signed-off-by: Carlos Maiolino --- src/t_stripealign.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/t_stripealign.c b/src/t_stripealign.c index 5cdadaae..164831f8 100644 --- a/src/t_stripealign.c +++ b/src/t_stripealign.c @@ -76,8 +76,11 @@ int main(int argc, char ** argv) unsigned int bmap = 0; ret = ioctl(fd, FIBMAP, &bmap); - if (ret < 0) { - perror("fibmap"); + if (ret <= 0) { + if (ret < 0) + perror("fibmap"); + else + fprintf(stderr, "fibmap error\n"); free(fie); close(fd); return 1;