From faeef4d2e9d5e38bed57846ba903009990f24422 Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Tue, 17 Nov 2015 22:32:48 +0800 Subject: losetup: support list direct io So that user can see if DIO is set for current loop device. Signed-off-by: Ming Lei --- lib/loopdev.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'lib/loopdev.c') diff --git a/lib/loopdev.c b/lib/loopdev.c index ff99dd444..54c620048 100644 --- a/lib/loopdev.c +++ b/lib/loopdev.c @@ -953,6 +953,28 @@ int loopcxt_is_readonly(struct loopdev_cxt *lc) return 0; } +/* + * @lc: context + * + * Returns: 1 if the dio flags is set. + */ +int loopcxt_is_dio(struct loopdev_cxt *lc) +{ + struct sysfs_cxt *sysfs = loopcxt_get_sysfs(lc); + + if (sysfs) { + int fl; + if (sysfs_read_int(sysfs, "loop/dio", &fl) == 0) + return fl; + } + if (loopcxt_ioctl_enabled(lc)) { + struct loop_info64 *lo = loopcxt_get_info(lc); + if (lo) + return lo->lo_flags & LO_FLAGS_DIRECT_IO; + } + return 0; +} + /* * @lc: context * @st: backing file stat or NULL -- cgit v1.2.3-55-g7522