]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs.xfs: fix fd validity check in get_topology
authorChristoph Hellwig <hch@lst.de>
Sun, 31 Jan 2010 08:57:46 +0000 (09:57 +0100)
committerChristoph Hellwig <hch@lst.de>
Sun, 31 Jan 2010 08:57:46 +0000 (09:57 +0100)
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 <sandeen@sandeen.ent>
Signed-off-by: Christoph Hellwig <hch@lst.de>
mkfs/xfs_mkfs.c

index b672b7a4d8f9bb6f3e27d50b074553926a37bff7..9baf116664d6d298b0d24dfbdaaa6cb23ea8e289 100644 (file)
@@ -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);
                }