diff options
author | Karel Zak | 2012-10-17 11:43:39 +0200 |
---|---|---|
committer | Karel Zak | 2012-10-17 11:51:10 +0200 |
commit | df0f2ad7633b3e2cc830298239cbaaa656e724cd (patch) | |
tree | 40646b1d76974de64e966dc60948ef2265e4fd82 /lib/loopdev.c | |
parent | lib/loopdev: improve debug messages (diff) | |
download | kernel-qcow2-util-linux-df0f2ad7633b3e2cc830298239cbaaa656e724cd.tar.gz kernel-qcow2-util-linux-df0f2ad7633b3e2cc830298239cbaaa656e724cd.tar.xz kernel-qcow2-util-linux-df0f2ad7633b3e2cc830298239cbaaa656e724cd.zip |
lib/loopdev: check for /sys
The current loopdev code prefers /sys to get information about
loop devices. The old methods like scan /dev are fallback solution
only. Unfortunately, the code does not check if /sys is mounted.
Addresses: http://blog.flameeyes.eu/2012/10/sophistication-can-be-bad
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib/loopdev.c')
-rw-r--r-- | lib/loopdev.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/loopdev.c b/lib/loopdev.c index a552fb755..dc93a69d7 100644 --- a/lib/loopdev.c +++ b/lib/loopdev.c @@ -167,6 +167,12 @@ int loopcxt_init(struct loopdev_cxt *lc, int flags) if (rc) return rc; + if (stat(_PATH_SYS_BLOCK, &st) || !S_ISDIR(st.st_mode)) { + lc->flags |= LOOPDEV_FL_NOSYSFS; + lc->flags &= ~LOOPDEV_FL_NOIOCTL; + DBG(lc, loopdev_debug("init: disable /sys usage")); + } + if (!(lc->flags & LOOPDEV_FL_NOSYSFS) && get_linux_version() >= KERNEL_VERSION(2,6,37)) { /* |