mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
Add a dev_get_sectsize call.
This commit is contained in:
parent
b74c8033a2
commit
52864eda2e
@ -13,8 +13,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mount.h>
|
#include <linux/fs.h> // UGH!!! for BLKSSZGET
|
||||||
|
|
||||||
|
|
||||||
int dev_get_size(struct device *dev, uint64_t *size)
|
int dev_get_size(struct device *dev, uint64_t *size)
|
||||||
{
|
{
|
||||||
@ -40,6 +39,29 @@ int dev_get_size(struct device *dev, uint64_t *size)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dev_get_sectsize(struct device *dev, uint32_t *size)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
int s;
|
||||||
|
const char *name = dev_name(dev);
|
||||||
|
|
||||||
|
log_very_verbose("Getting size of %s", name);
|
||||||
|
if ((fd = open(name, O_RDONLY)) < 0) {
|
||||||
|
log_sys_error("open", name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ioctl(fd, BLKSSZGET, &s) < 0) {
|
||||||
|
log_sys_error("ioctl BLKSSZGET", name);
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
*size = (uint32_t) s;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int dev_open(struct device *dev, int flags)
|
int dev_open(struct device *dev, int flags)
|
||||||
{
|
{
|
||||||
const char *name = dev_name(dev);
|
const char *name = dev_name(dev);
|
||||||
|
@ -26,6 +26,7 @@ struct device {
|
|||||||
* All io should use these routines.
|
* All io should use these routines.
|
||||||
*/
|
*/
|
||||||
int dev_get_size(struct device *dev, uint64_t *size);
|
int dev_get_size(struct device *dev, uint64_t *size);
|
||||||
|
int dev_get_sectsize(struct device *dev, uint32_t *size);
|
||||||
|
|
||||||
int dev_open(struct device *dev, int flags);
|
int dev_open(struct device *dev, int flags);
|
||||||
int dev_close(struct device *dev);
|
int dev_close(struct device *dev);
|
||||||
|
Loading…
Reference in New Issue
Block a user