diff options
author | Ming Lei | 2015-11-17 15:32:48 +0100 |
---|---|---|
committer | Karel Zak | 2015-11-19 11:27:36 +0100 |
commit | faeef4d2e9d5e38bed57846ba903009990f24422 (patch) | |
tree | edeabbde252963bc44bc4e1e18eeccd76159fc6a /lib/loopdev.c | |
parent | losetup: support ioctl cmd of LOOP_SET_DIRECT_IO (diff) | |
download | kernel-qcow2-util-linux-faeef4d2e9d5e38bed57846ba903009990f24422.tar.gz kernel-qcow2-util-linux-faeef4d2e9d5e38bed57846ba903009990f24422.tar.xz kernel-qcow2-util-linux-faeef4d2e9d5e38bed57846ba903009990f24422.zip |
losetup: support list direct io
So that user can see if DIO is set for current loop device.
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Diffstat (limited to 'lib/loopdev.c')
-rw-r--r-- | lib/loopdev.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/loopdev.c b/lib/loopdev.c index ff99dd444..54c620048 100644 --- a/lib/loopdev.c +++ b/lib/loopdev.c @@ -955,6 +955,28 @@ int loopcxt_is_readonly(struct loopdev_cxt *lc) /* * @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 * @backing_file: filename * @offset: offset |