lkml.org 
[lkml]   [2001]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Getting the number of 512-byte sectors?
    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/

\
 
 \ /
  Last update: 2005-03-22 13:13    [W:0.024 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site