[functional-tests] Move get-dev-size to C code
Saves forking blockdev
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
#include <linux/dm-ioctl.h>
|
||||
#include <linux/kdev_t.h>
|
||||
#include <linux/fs.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
@ -596,4 +597,18 @@ int dm_message(struct dm_interface *dmi, const char *name, uint64_t sector,
|
||||
return r;
|
||||
}
|
||||
|
||||
int get_dev_size(const char *path, uint64_t *sectors)
|
||||
{
|
||||
int r, fd;
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return -EINVAL;
|
||||
|
||||
r = ioctl(fd, BLKGETSIZE64, sectors);
|
||||
(*sectors) /= 512;
|
||||
close(fd);
|
||||
return r;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user