Re: Patch for file fs/partitions/check.c

Alex Davis (letmein@erols.com)
Wed, 21 Feb 2001 19:54:38 -0500


Andries.Brouwer@cwi.nl wrote:
>
> > Are you the person I send the patch to?
>
> Send it to aeb@cwi.nl and to linux-kernel@vger.kernel.org .
>
> Andries

Here's my patch to perform a media-change check and, if necessary,
a disk revalidate whenever /proc/partitions is accessed.

--- check.c.save Wed Feb 21 17:50:54 2001
+++ check.c Wed Feb 21 19:49:20 2001
@@ -9,6 +9,10 @@
* contained.
*
* Added needed MAJORS for new pairs, {hdi,hdj}, {hdk,hdl}
+ *
+ * Alex Davis <letmein@erols.com>
+ * Added code to keep /proc/partitions in sync with
+ * removable media.
*/

#include <linux/config.h>
@@ -242,11 +246,25 @@
int get_partition_list(char *page, char **start, off_t offset, int
count)
{
struct gendisk *dsk;
+ kdev_t dev;
int len;

len = sprintf(page, "major minor #blocks name\n\n");
for (dsk = gendisk_head; dsk; dsk = dsk->next) {
int n;
+ int i;
+
+ if ( dsk->fops->check_media_change &&
+ dsk->fops->revalidate ) {
+ for ( i = 0; i < dsk->nr_real; ++i ) {
+ dev = MKDEV(dsk->major, i << dsk->minor_shift);
+ if ( dsk->flags[i] & GENHD_FL_REMOVABLE &&
+ dsk->fops->check_media_change(dev) ) {
+//printk(KERN_INFO "revalidating drive %d:%d\n", dsk->major, i);
+ dsk->fops->revalidate(dev);
+ }
+ }
+ }

for (n = 0; n < (dsk->nr_real << dsk->minor_shift); n++)
if (dsk->part[n].nr_sects) {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/