Skip to contentSkip to conversation

mkfs.xfs: fix fd validity check in get_topology

PATCH In review Christoph Hellwig 2 participants 2 messages Jan 30, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

mkfs/xfs_mkfs.c +1 -1
Index: xfsprogs-dev/mkfs/xfs_mkfs.c
===================================================================
@@ -455,7 +455,7 @@ static void get_topology(libxfs_init_t *
 				&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);
 		}

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Christoph Hellwig

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.

and unhelpful help for any user... argh :(

Quoted 1 line
Quoted 15 lines

Index: xfsprogs-dev/mkfs/xfs_mkfs.c
===================================================================

mkfs/xfs_mkfs.c +1 -1
@@ -455,7 +455,7 @@ static void get_topology(libxfs_init_t *
 				&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);
 		}
Quoted 5 lines

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs