lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.0.83.0704071209070.15343@sigma.j-a-k-j.com>
Date:	Sat, 7 Apr 2007 12:23:49 -0400 (EDT)
From:	"John Anthony Kazos Jr." <jakj@...-k-j.com>
To:	axboe@...nel.dk
cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] block layer: Add bdev capacity helper function
 get_sect_count

From: John Anthony Kazos Jr. <jakj@...-k-j.com>

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. <jakj@...-k-j.com>

---

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 majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ