* BLKRRPART bug + fix in mtd_blkdevs-24.c in mtd-snapshot-20040914.tar.bz2
@ 2004-09-16 12:36 Frantisek Rysanek
0 siblings, 0 replies; only message in thread
From: Frantisek Rysanek @ 2004-09-16 12:36 UTC (permalink / raw)
To: dwmw2; +Cc: linux-mtd
[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 1087 bytes --]
Dear Mr. Woodhouse,
I've found a bug in the functions serving the BLKRRPART
ioctl() in the 2.4 branch of MTD blkdevs. See the attached
patch, I believe it contains a fix.
My DiskOnChip was detected just fine, but when I flushed the
original partition and issued a BLKRRPART, the device would
report half its original size. If I did it again, it would
report a quarter size... etc.
Seems like the driver would re-init device size to a size
denominated in 1k blocks, rather than sectors (512B).
Attached are two simple proggies that I'm using in my
partitioning scripts.
Otherwise the driver seems to work just fine.
Actually I also had to insert
#ifndef CONFIG_MTD_CFI_GEOMETRY
#define CONFIG_MTD_MAP_BANK_WIDTH_1
#endif
at the beginning of $KERNEL/include/linux/mtd/map.h
to make it compile. Seems like a dependency mismatch between
drivers/mtd/chips/Config.in and the headers/code. I don't have
a CFI MTD, but I do need drivers/mtd/chips/chipreg.o even for
my DiskOnChip (now a generic NFTL device).
Thanks for the great job you're doing on MTD :-)
Frank Rysanek
[-- Attachment #2: Text from file 'mtd_blkdevs-24.c.patch' --]
[-- Type: text/plain, Size: 284 bytes --]
--- mtd_blkdevs-24.old.c 2004-09-16 12:51:08.000000000 +0200
+++ mtd_blkdevs-24.c 2004-09-16 12:54:38.000000000 +0200
@@ -315,7 +315,7 @@
}
grok_partitions(gd, minor, 1 << tr->part_bits,
- tr->blkcore_priv->sizes[minor]);
+ dev->size);
up(&mtd_table_mutex);
return 0;
[-- Attachment #3: Attachment information. --]
[-- Type: text/plain, Size: 476 bytes --]
The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any other MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.
---- File information -----------
File: reset_disk.c
Date: 16 Sep 2004, 13:23
Size: 989 bytes.
Type: Program-source
[-- Attachment #4: reset_disk.c --]
[-- Type: Application/Octet-stream, Size: 989 bytes --]
#include <stdio.h> // general I/O
#include <fcntl.h> // options for open()
#define O_LARGEFILE 0100000
#include <sys/ioctl.h> // provides ioctl()
#include <linux/fs.h> // BLKRRPART
int main(int argc, char** argv, char** env)
{
int fd = -1;
int err = 0;
char* filename = NULL;
if (argc > 1)
{
filename = argv[1];
}
else
{
printf("Usage example: reset_disk /dev/hda\n");
printf("Calls the BLKRRPART ioctl() to make kernel re-read and re-interpret partition table.\n");
printf("This only works if no devices (filesystems) are currently mounted off that disk.\n");
exit(1);
}
fd = open(filename, O_RDONLY|O_LARGEFILE);
if (fd <= 0)
{
printf("Unable to open %s. Exiting\n", filename);
exit(1);
}
err = ioctl(3, BLKRRPART, NULL);
if (err)
{
printf("Error re-reading partition tables using the BLKRRPART ioctl().\n");
exit(1);
}
close(fd);
return(0);
}
[-- Attachment #5: Attachment information. --]
[-- Type: text/plain, Size: 471 bytes --]
The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any other MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.
---- File information -----------
File: geom.c
Date: 16 Sep 2004, 13:23
Size: 1569 bytes.
Type: Program-source
[-- Attachment #6: geom.c --]
[-- Type: Application/Octet-stream, Size: 1569 bytes --]
#include <stdio.h> // general I/O
#include <fcntl.h> // options for open()
#define O_LARGEFILE 0100000
#include <sys/ioctl.h> // provides ioctl()
#include <linux/fs.h> // BLKGETSIZE
#include <linux/hdreg.h> // HDIO_GETGEO_BIG
int main(int argc, char** argv, char** env)
{
int fd = -1;
int err = 0;
struct hd_big_geometry big_geom; // unsigned int cyls
struct hd_geometry geom; // unsigned short cyls
unsigned int size = 0;
char* filename = NULL;
if (argc > 1)
{
filename = argv[1];
}
else
{
printf("Usage example: geom /dev/hda\n");
printf("Output: Cylinders/Heads/Sectors_per_track/Capacity (in sectors)\n");
exit(1);
}
fd = open(filename, O_RDONLY|O_LARGEFILE);
if (fd <= 0)
{
printf("Unable to open %s. Exiting\n", filename);
exit(1);
}
err = ioctl(3, BLKGETSIZE, &size);
if (err)
{
printf("Error getting capacity using BLKGETSIZE\n");
exit(1);
}
geom.cylinders = 0;
geom.heads = 0;
geom.sectors = 0;
err = ioctl(3, HDIO_GETGEO_BIG, &big_geom);
if (err)
{
err = ioctl(3, HDIO_GETGEO, &geom);
if (err)
{
printf("Error retrieving geometry - both HDIO_GETGEO_BIG and HDIO_GETGEO failed.\n");
exit(1);
}
else
{
printf("%u/%u/%u/%u\n",geom.cylinders, geom.heads, geom.sectors, size);
}
}
else
{
printf("%u/%u/%u/%u\n",big_geom.cylinders, big_geom.heads, big_geom.sectors, size);
}
close(fd);
return(0);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-09-16 12:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-16 12:36 BLKRRPART bug + fix in mtd_blkdevs-24.c in mtd-snapshot-20040914.tar.bz2 Frantisek Rysanek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox