From 8fe1e638fa81d88e1e405f6221c7a592284c9b23 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 31 Oct 2015 17:29:02 +0000 Subject: lib/blkdev: add open_blkdev_or_file() function Purpose of this function is to open a path that is potentially pointing to a block device or file without races. The function also proper open(3) flags are used to check the device is not busy, and finally warning is been printed if a block device happens to be misaligned. Signed-off-by: Sami Kerola --- include/blkdev.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/blkdev.h') diff --git a/include/blkdev.h b/include/blkdev.h index c994795a2..46fb2cef0 100644 --- a/include/blkdev.h +++ b/include/blkdev.h @@ -97,6 +97,9 @@ struct hd_geometry { /* are we working with block device? */ int is_blkdev(int fd); +/* open block device or file */ +int open_blkdev_or_file(const struct stat *st, const char *name, const int oflag); + /* Determine size in bytes */ off_t blkdev_find_size (int fd); -- cgit v1.2.3-55-g7522