]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
eject: also use sysfs_blkdev_is_removable
authorThomas Weißschuh <thomas@t-8ch.de>
Wed, 11 Jan 2023 18:14:03 +0000 (18:14 +0000)
committerKarel Zak <kzak@redhat.com>
Tue, 24 Jan 2023 16:26:15 +0000 (17:26 +0100)
It correctly represents devices that can be ejected.

sys-utils/eject.c

index 717d9fe5b89e521f8b3992342390d48b420fca3d..6037ddc8f8450ca9e20e5429dce8271fac71e31b 100644 (file)
@@ -807,7 +807,7 @@ done:
        return count;
 }
 
-static int is_hotpluggable(const struct eject_control *ctl)
+static int is_ejectable(const struct eject_control *ctl)
 {
        struct path_cxt *pc = NULL;
        dev_t devno;
@@ -819,7 +819,7 @@ static int is_hotpluggable(const struct eject_control *ctl)
        if (!pc)
                return 0;
 
-       rc = sysfs_blkdev_is_hotpluggable(pc);
+       rc = sysfs_blkdev_is_hotpluggable(pc) || sysfs_blkdev_is_removable(pc);
        ul_unref_path(pc);
        return rc;
 }
@@ -911,8 +911,8 @@ int main(int argc, char **argv)
                verbose(&ctl, _("%s: is whole-disk device"), ctl.device);
        }
 
-       if (ctl.F_option == 0 && is_hotpluggable(&ctl) == 0)
-               errx(EXIT_FAILURE, _("%s: is not hot-pluggable device"), ctl.device);
+       if (ctl.F_option == 0 && is_ejectable(&ctl) == 0)
+               errx(EXIT_FAILURE, _("%s: is not ejectable device"), ctl.device);
 
        /* handle -n option */
        if (ctl.n_option) {