From: Karel Zak Date: Wed, 13 Jun 2012 11:55:49 +0000 (+0200) Subject: eject: don't try to use non-device path X-Git-Tag: v2.22-rc1~290 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8388bbb3dfae6ebb9d614012e7484ffb12de07a3;p=thirdparty%2Futil-linux.git eject: don't try to use non-device path Signed-off-by: Karel Zak --- diff --git a/sys-utils/eject.c b/sys-utils/eject.c index 240e27e74b..402152204c 100644 --- a/sys-utils/eject.c +++ b/sys-utils/eject.c @@ -983,8 +983,15 @@ int main(int argc, char **argv) free(device); device = disk; disk = NULL; - } else + } else { + struct stat st; + + if (stat(device, &st) != 0 || !S_ISBLK(st.st_mode)) + errx(EXIT_FAILURE, _("%s: not found mountpoint or device " + "with the given name"), device); + verbose(_("%s: is whole-disk device"), device); + } if (F_option == 0 && is_hotpluggable(device) == 0) errx(EXIT_FAILURE, _("%s: is not hot-pluggable device"), device);