mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andries.Brouwer@cwi.nl
To: aia21@cam.ac.uk
Cc: linux-kernel@vger.kernel.org
Subject: Re: Getting the number of 512-byte sectors?
Date: Mon, 22 Jan 2001 02:31:04 +0100 (MET)	[thread overview]
Message-ID: <UTC200101220131.CAA176461.aeb@vlet.cwi.nl> (raw)

    From: Anton Altaparmakov <aia21@cam.ac.uk>
    Subject: Getting the number of 512-byte sectors?

    My question is how to get the _real_ number of sectors of a partition from 
    within a file system. I.e. we are starting only with the knowledge of the 
    struct super_block for the partition.

As you conjectured already, you find this info in the gendisk->part[] array,
in the start_sect and nr_sects fields.

    Locate the correct gendisk structure by performing a walk of gendisk_head 
    as done in drivers/block/blkpg.c::get_gendisk(kdev_t), (Could we make this 
    function to not be private to blkpg.c?), then get the hd_struct for the 
    partition and obtain the values from that. In code:

    struct gendisk *g = get_gendisk(my_super_block->s_dev)
    struct hd_struct *hd = &g->part[MINOR(my_super_block->s_dev)];

    wanted "subtracted" values:
             hd->start_sect
             hd->nr_sects

    Am I missing something?

No, I agree completely.

    Note: I know I can normally get the number of sectors from the boot sector 
    of the partition

Not necessarily. The partition table need not be of DOS type.
Or, even if it is, the kernel's tables may be set up dynamically.

> Could we make this function to not be private to blkpg.c?

I think this area will change rather drastically in 2.5.*.

Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

             reply	other threads:[~2001-01-22  1:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-22  1:31 Andries.Brouwer [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-01-21 17:05 Anton Altaparmakov
     [not found] <20001002032923.B17146@veritas.com>
     [not found] ` <00100202491203.00767@gimli>
     [not found]   ` <news2mail-39D7A4E9.26E4DA3C@innominate.de>
     [not found]     ` <00100201582602.00767@gimli>
     [not found]       ` <20001002022728.A17106@veritas.com>
2001-01-21 16:16         ` Anton Altaparmakov

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=UTC200101220131.CAA176461.aeb@vlet.cwi.nl \
    --to=andries.brouwer@cwi.nl \
    --cc=aia21@cam.ac.uk \
    --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

Powered by JetHome