summaryrefslogtreecommitdiffstats
path: root/misc-utils/lsblk.c
diff options
context:
space:
mode:
authorSami Kerola2011-10-05 15:37:48 +0200
committerKarel Zak2011-10-10 14:51:26 +0200
commitf65b3bb6257bb0885fd8bfe3bd6f0f4b2739d4b4 (patch)
treeb08de834b0df710ee988e4f7dcdfe4f0b3709dee /misc-utils/lsblk.c
parentbuild-sys: check scanf %ms modifier (diff)
downloadkernel-qcow2-util-linux-f65b3bb6257bb0885fd8bfe3bd6f0f4b2739d4b4.tar.gz
kernel-qcow2-util-linux-f65b3bb6257bb0885fd8bfe3bd6f0f4b2739d4b4.tar.xz
kernel-qcow2-util-linux-f65b3bb6257bb0885fd8bfe3bd6f0f4b2739d4b4.zip
lsblk: inform about depencency to /sys/dev/block
The lsblk depends on /sys/dev/block/ symlinks, which appeared in kernel 2.6.27. Users with old, or non-sysfs configured, kernel got ealier message lsblk: md0: failed to initialize sysfs handler lsblk: xvda: failed to initialize sysfs handler [...] that I found a little too difficult to understand. This patch will change the message to lsblk: failed to access sysfs directory: /sys/dev/block: No such file or directory and informs in manual page what could be reason to that. [kzak@redhat.com: - use access() rather than opendir()] Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/lsblk.c')
-rw-r--r--misc-utils/lsblk.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index f9c06fe07..74a185087 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -947,6 +947,13 @@ errx_mutually_exclusive(const char *opts)
errx(EXIT_FAILURE, "%s %s", opts, _("options are mutually exclusive"));
}
+static void check_sysdevblock(void)
+{
+ if (access(_PATH_SYS_DEVBLOCK, R_OK) != 0)
+ err(EXIT_FAILURE, _("failed to access sysfs directory: %s"),
+ _PATH_SYS_DEVBLOCK);
+}
+
int main(int argc, char *argv[])
{
struct lsblk _ls;
@@ -1059,6 +1066,8 @@ int main(int argc, char *argv[])
}
}
+ check_sysdevblock();
+
if (!ncolumns) {
columns[ncolumns++] = COL_NAME;
columns[ncolumns++] = COL_MAJMIN;