]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: inform about depencency to /sys/dev/block
authorSami Kerola <kerolasa@iki.fi>
Wed, 5 Oct 2011 13:37:48 +0000 (15:37 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 10 Oct 2011 12:51:26 +0000 (14:51 +0200)
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>
misc-utils/lsblk.8
misc-utils/lsblk.c

index 72085ac28d36cebd4203b993433a49c3905b7d0a..028b19f10818408a2dcc72946ce9c727e6b8eea6 100644 (file)
@@ -63,6 +63,15 @@ This option is equivalent to "-o NAME,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,RO
 .SH NOTES
 For the partitions are some information (e.g. queue attributes) inherited from
 parental device.
+.PP
+The
+.B lsblk
+needs to be able to lookup sysfs path by major:minor, which is done
+done by using
+.BR /sys/dev/block .
+The block sysfs appeared in kernel 2.6.27 (October 2008).  In case of
+problem with new enough kernel check that CONFIG_SYSFS was enabled at
+the time of kernel build.
 .SH AUTHORS
 .nf
 Milan Broz <mbroz@redhat.com>
index f9c06fe075b851e078cca8332c5a4bb3558993b5..74a18508782f4999552fddbb8c0953627cec9a7b 100644 (file)
@@ -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;