[PATCH] block layer: Add bdev capacity helper function get_sect_count

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: John Anthony Kazos Jr. <[email protected]>

Add static inline function get_sect_count to include/linux/genhd.h to 
complement get_start_sect. Returns sector_t capacity of block device 
whether it is whole or a partition.

Signed-off-by: John Anthony Kazos Jr. <[email protected]>

---

This will be useful for fill_super functions of filesystems with online 
resizing for checks against recorded and actual device size. 
get_start_sect and get_sect_count are helper functions useful to keep 
things from breaking in case the block_device structure decides to change.

Applied against Linux v2.6.20.6.

--- linux-2.6.20.6-orig/include/linux/genhd.h	2007-04-06 16:02:48.000000000 -0400
+++ linux-2.6.20.6-mod/include/linux/genhd.h	2007-04-07 11:58:55.000000000 -0400
@@ -244,6 +244,10 @@ static inline sector_t get_start_sect(st
 {
 	return bdev->bd_contains == bdev ? 0 : bdev->bd_part->start_sect;
 }
+static inline sector_t get_sect_count(struct block_device *bdev)
+{
+	return bdev->bd_contains == bdev ? bdev->bd_disk->capacity : bdev->bd_part->nr_sects;
+}
 static inline sector_t get_capacity(struct gendisk *disk)
 {
 	return disk->capacity;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux