[BUG] raidtools-1.00.3 - BLKGETSIZE ioctl call wrong

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

there is a bug in raidtools 1.00.3:
when issueing the BLKGETSIZE ioctl, the raidtools expect the return value
in a __u32 bit variable called nr_blocks. Since the BLKGETSIZE ioctl writes
the result into an unsigned long, this doesn't fit on 64 bit architectures and
therefore has some strange effects (at least on big endian machines). Please
apply the attached patch.

Thanks,
Heiko
--- raidtools-1.00.3/raid_io.c	2003-01-15 09:58:25.000000000 +0100
+++ raidtools-1.00.3-fix/raid_io.c	2004-01-08 14:34:20.136485704 +0100
@@ -363,7 +363,7 @@
 	md_raid_info_t *array;
 	mdu_disk_info_t *disk;
 	struct stat stat_buf;
-	__u32 nr_blocks;
+	unsigned long nr_blocks;
 
 	if (!cfg)
 		return 1;
@@ -454,14 +454,14 @@
 			}
 			nr_blocks >>= 1;
 			if (nr_blocks < MD_RESERVED_BLOCKS * 2) {
-				fprintf(stderr, "%s: device too small (%dkB)\n", cfg->device_name[i], nr_blocks);
+				fprintf(stderr, "%s: device too small (%ldkB)\n", cfg->device_name[i], nr_blocks);
 				close(fd);
 				return 1;
 			}
 
                 	cfg->sb_block_offset[i] = MD_NEW_SIZE_BLOCKS(nr_blocks);
 			if (!cfg->array.param.not_persistent) {
-                		printf("disk %d: %s, %ukB, raid superblock at %dkB\n", i, cfg->device_name[i], nr_blocks, cfg->sb_block_offset[i]);
+                		printf("disk %d: %s, %lukB, raid superblock at %dkB\n", i, cfg->device_name[i], nr_blocks, cfg->sb_block_offset[i]);
 	                	if (sanity_checks(cfg->device_name[i], fd,
 					 	cfg->sb_block_offset[i], forceSanity,
 					 	upgradeArray, cfg, 0)) {
@@ -495,7 +495,7 @@
 			}
 			nr_blocks >>= 1;
 			if (nr_blocks < MD_RESERVED_BLOCKS * 2) {
-				fprintf(stderr, "%s: device too small (%dkB)\n", cfg->device_name[i], nr_blocks);
+				fprintf(stderr, "%s: device too small (%ldkB)\n", cfg->device_name[i], nr_blocks);
 				close(fd);
 				return 1;
 			}

[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux