Messages in this thread | | | Date | Mon, 03 Sep 2001 14:36:13 -0400 | From | Arjan van de Ven <> | Subject | Re: [PATCH] cleanup gendisk handling |
| |
Christoph Hellwig wrote: > diff -uNr -X../current/dontdiff ../master/linux-2.4.10-pre4/drivers/block/genhd.c linux/drivers/block/genhd.c > --- ../master/linux-2.4.10-pre4/drivers/block/genhd.c Fri Jul 20 02:48:15 2001 > +++ linux/drivers/block/genhd.c Mon Sep 3 19:38:50 2001 > @@ -17,6 +17,75 @@ > #include <linux/blk.h> > #include <linux/init.h> > > + > +struct gendisk *gendisk_head; > + > +void > +add_gendisk(struct gendisk *gp) > +{ > + gp->next = gendisk_head; > + gendisk_head = gp; > +} > + > +void > +del_gendisk(struct gendisk *gp) > +{ > + struct gendisk **gpp; > + > + for (gpp = &gendisk_head; *gpp; gpp = &((*gpp)->next)) > + if (*gpp == gp) > + break; > + if (*gpp) > + *gpp = (*gpp)->next; > +} > + > +struct gendisk * > +get_gendisk(kdev_t dev) > +{ > + struct gendisk *gp = NULL; > + int maj = MAJOR(dev); > + > + for (gp = gendisk_head; gp; gp = gp->next) > + if (gp->major == maj) > + return gp; > + return NULL; > +} > + > +#ifdef CONFIG_PROC_FS > +int > +get_partition_list(char *page, char **start, off_t offset, int count) > +{ > + struct gendisk *gp; > + char buf[64]; > + int len, n; > + > + len = sprintf(page, "major minor #blocks name\n\n"); > + for (gp = gendisk_head; gp; gp = gp->next) { > + for (n = 0; n < (gp->nr_real << gp->minor_shift); n++) { > + if (gp->part[n].nr_sects == 0) > + continue; > + > + len += snprintf(page + len, 63, > + "%4d %4d %10d %s\n", > + gp->major, n, gp->sizes[n], > + disk_name(gp, n, buf)); > + if (len < offset) > + offset -= len, len = 0; > + else if (len >= offset + count) > + goto out; > + } > + } > + > +out: > + *start = page + offset; > + len -= offset; > + if (len < 0) > + len = 0; > + return len > count ? count : len; > +} > +#endif > + > + > extern int blk_dev_init(void); > #ifdef CONFIG_BLK_DEV_DAC960 > extern void DAC960_Initialize(void);
Hi,
I had a patch similar to this one a while ago (and it got dropped); One difference is that your patch doesn't seem to lock the linked list... so the operation is SMP unsafe (it was before, but fixing that would be a good sideeffect of this patch)
Greetings, Arjan van de Ven - 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/
| |