Signed-off-by: Sage Weil <sage@redhat.com>
#include "include/uuid.h"
#include "blkdev.h"
+int get_device_by_path(const char *path, char* partition, char* device,
+ size_t max)
+{
+ int fd = ::open(path, O_RDONLY|O_DIRECTORY);
+ if (fd < 0) {
+ return -errno;
+ }
+ int r = get_device_by_fd(fd, partition, device, max);
+ ::close(fd);
+ return r;
+}
+
+
#ifdef __linux__
#include <libudev.h>
#include <linux/fs.h>
// from an fd
extern int block_device_discard(int fd, int64_t offset, int64_t len);
extern int get_block_device_size(int fd, int64_t *psize);
+extern int get_device_by_path(const char *path, char* partition, char* device, size_t max);
extern int get_device_by_fd(int fd, char* partition, char* device, size_t max);
// from a device (e.g., "sdb")