* [PATCH] blkdev: add blkdev_get_physector_size()
@ 2011-06-21 2:58 Davidlohr Bueso
2011-06-27 14:22 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Davidlohr Bueso @ 2011-06-21 2:58 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux
From: Davidlohr Bueso <dave@gnu.org>
Date: Mon, 20 Jun 2011 22:51:47 -0400
This function uses the BLKPBSZGET ioctl to get the physical block size of the device.
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
include/blkdev.h | 3 +++
lib/blkdev.c | 14 ++++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/include/blkdev.h b/include/blkdev.h
index 6a64172..0024897 100644
--- a/include/blkdev.h
+++ b/include/blkdev.h
@@ -95,4 +95,7 @@ int blkdev_get_sector_size(int fd, int *sector_size);
/* specifies whether or not the device is misaligned */
int blkdev_is_misaligned(int fd);
+/* get physical block device size */
+int blkdev_get_physector_size(int fd);
+
#endif /* BLKDEV_H */
diff --git a/lib/blkdev.c b/lib/blkdev.c
index 5cb6554..94df803 100644
--- a/lib/blkdev.c
+++ b/lib/blkdev.c
@@ -221,6 +221,20 @@ int blkdev_is_misaligned(int fd)
#endif
}
+/* get physical block device size */
+int blkdev_get_physector_size(int fd)
+{
+#ifdef BLKPBSZGET
+ int bsz;
+
+ if (ioctl(fd, BLKPBSZGET, &bsz) < 0)
+ return 0;
+ return bsz;
+#else
+ return 0;
+#endif
+}
+
#ifdef TEST_PROGRAM
#include <stdio.h>
#include <stdlib.h>
--
1.7.5.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] blkdev: add blkdev_get_physector_size()
2011-06-21 2:58 [PATCH] blkdev: add blkdev_get_physector_size() Davidlohr Bueso
@ 2011-06-27 14:22 ` Karel Zak
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2011-06-27 14:22 UTC (permalink / raw)
To: Davidlohr Bueso; +Cc: util-linux
On Mon, Jun 20, 2011 at 10:58:24PM -0400, Davidlohr Bueso wrote:
> include/blkdev.h | 3 +++
> lib/blkdev.c | 14 ++++++++++++++
> 2 files changed, 17 insertions(+), 0 deletions(-)
Applied with minor changes, thanks.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-27 14:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-21 2:58 [PATCH] blkdev: add blkdev_get_physector_size() Davidlohr Bueso
2011-06-27 14:22 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox