]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsmem: report inaccessible /sys/devices/system/memory
authorKarel Zak <kzak@redhat.com>
Wed, 8 Jul 2020 06:51:45 +0000 (08:51 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 8 Jul 2020 06:51:45 +0000 (08:51 +0200)
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1794160
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/lsmem.c

index 80cad98cda9cb984ca72ea0593dfd1e45ba991cf..00f9d769c3ab99c6d43c2d322b7ae06fc5a85d66 100644 (file)
@@ -654,6 +654,8 @@ int main(int argc, char **argv)
                err(EXIT_FAILURE, _("failed to initialize %s handler"), _PATH_SYS_MEMORY);
        if (prefix && ul_path_set_prefix(lsmem->sysmem, prefix) != 0)
                err(EXIT_FAILURE, _("invalid argument to --sysroot"));
+       if (!ul_path_is_accessible(lsmem->sysmem))
+               err(EXIT_FAILURE, _("cannot open %s"), _PATH_SYS_MEMORY);
 
        /* Shortcut to avoid scols machinery on --summary=only */
        if (lsmem->want_table == 0 && lsmem->want_summary) {