From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f193.google.com ([209.85.215.193]:46567 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727050AbfHYNmH (ORCPT ); Sun, 25 Aug 2019 09:42:07 -0400 Date: Sun, 25 Aug 2019 21:41:54 +0800 From: Eryu Guan Subject: Re: [PATCH] t_stripealign: Fix fibmap error handling Message-ID: <20190825134154.GB2622@desktop> References: <20190823092530.11797-1-cmaiolino@redhat.com> <20190823143650.GI1037350@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190823143650.GI1037350@magnolia> Sender: fstests-owner@vger.kernel.org To: "Darrick J. Wong" Cc: Carlos Maiolino , fstests@vger.kernel.org, linux-xfs@vger.kernel.org List-ID: On Fri, Aug 23, 2019 at 07:36:50AM -0700, Darrick J. Wong wrote: > On Fri, Aug 23, 2019 at 11:25:30AM +0200, Carlos Maiolino wrote: > > 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"); > > "fibmap returned no result"? Fixed on commit. Thanks! Eryu