public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arjan van de Ven <arjanv@redhat.com>
To: Christoph Hellwig <hch@caldera.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cleanup gendisk handling
Date: Mon, 03 Sep 2001 14:36:13 -0400	[thread overview]
Message-ID: <3B93CD9D.35ED4F1C@redhat.com> (raw)
In-Reply-To: <20010903200504.A30093@caldera.de>

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

  reply	other threads:[~2001-09-03 18:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-03 18:05 [PATCH] cleanup gendisk handling Christoph Hellwig
2001-09-03 18:36 ` Arjan van de Ven [this message]
2001-09-03 18:38   ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2001-09-03 18:35 Andries.Brouwer
2001-09-03 18:45 ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3B93CD9D.35ED4F1C@redhat.com \
    --to=arjanv@redhat.com \
    --cc=hch@caldera.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox