Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- sys-utils/swapon.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c index 32a3107..c4d1544 100644 --- a/sys-utils/swapon.c +++ b/sys-utils/swapon.c @@ -475,7 +475,13 @@ static int swapon_checks(const char *special) unsigned long long devsize = 0; int permMask; - if (stat(special, &st) < 0) { + fd = open(special, O_RDONLY); + if (fd == -1) { + warn(_("cannot open %s"), special); + goto err; + } + + if (fstat(fd, &st) < 0) { warn(_("stat of %s failed"), special); goto err; } @@ -500,12 +506,6 @@ static int swapon_checks(const char *special) devsize = st.st_size; } - fd = open(special, O_RDONLY); - if (fd == -1) { - warn(_("cannot open %s"), special); - goto err; - } - if (S_ISBLK(st.st_mode) && blkdev_get_size(fd, &devsize)) { warnx(_("%s: get size failed"), special); goto err; -- 2.6.2 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html