From: Junichi Uekawa Date: Mon, 10 Jul 2023 12:14:56 +0000 (+0900) Subject: iterate according to review comments. X-Git-Tag: v2.40-rc1~324^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5a02eb13ee8c80dc753cbe65f0ccc0c72d2e696e;p=thirdparty%2Futil-linux.git iterate according to review comments. --- diff --git a/misc-utils/fincore.c b/misc-utils/fincore.c index e8dfef2353..c92d10b544 100644 --- a/misc-utils/fincore.c +++ b/misc-utils/fincore.c @@ -246,16 +246,21 @@ static int fincore_name(struct fincore_control *ctl, return -errno; } - if (S_ISBLK(sb.st_mode) || S_ISREG(sb.st_mode)) { - if (blkdev_get_size(fd, size) == 0) - rc = fincore_fd(ctl, fd, name, *size, count_incore); - else + if (S_ISBLK(sb.st_mode)) { + rc = blkdev_get_size(fd, size); + if (rc) warn(_("failed ioctl to get size: %s"), name); + } else if (S_ISREG(sb.st_mode)) { + *size = sb.st_size; } else { rc = 1; /* ignore things like symlinks * and directories*/ } + if (!rc) { + rc = fincore_fd(ctl, fd, name, *size, count_incore); + } + close (fd); return rc; }