summaryrefslogtreecommitdiffstats
path: root/include/blkdev.h
diff options
context:
space:
mode:
authorSami Kerola2015-10-31 18:29:02 +0100
committerSami Kerola2015-11-22 21:56:05 +0100
commit8fe1e638fa81d88e1e405f6221c7a592284c9b23 (patch)
tree7b95d5f7c2276f0ccdc5e24d97b5343d942b0d08 /include/blkdev.h
parentinclude/fileutils: add is_same_inode() check (diff)
downloadkernel-qcow2-util-linux-8fe1e638fa81d88e1e405f6221c7a592284c9b23.tar.gz
kernel-qcow2-util-linux-8fe1e638fa81d88e1e405f6221c7a592284c9b23.tar.xz
kernel-qcow2-util-linux-8fe1e638fa81d88e1e405f6221c7a592284c9b23.zip
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 <kerolasa@iki.fi>
Diffstat (limited to 'include/blkdev.h')
-rw-r--r--include/blkdev.h3
1 files changed, 3 insertions, 0 deletions
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);