From 85112c3a23927f299f04c193f5924249d7dd80bf Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 31 Jan 2010 09:57:46 +0100 Subject: [PATCH] mkfs.xfs: fix fd validity check in get_topology Only negatie return values from open mean we failed to open the device. Without this check we do not print the usage message when no device is specified. This leads to a weird failure in xfstests 122. Reviewed-by: Eric Sandeen Signed-off-by: Christoph Hellwig --- mkfs/xfs_mkfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index b672b7a4d..9baf11666 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -455,7 +455,7 @@ static void get_topology(libxfs_init_t *xi, struct fs_topology *ft) &ft->dsunit, &ft->dswidth, &ft->sectoralign); fd = open(dfile, O_RDONLY); /* If this fails we just fall back to BBSIZE */ - if (fd) { + if (fd >= 0) { platform_findsizes(dfile, fd, &dummy, &bsz); close(fd); } -- 2.47.2