]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
iterate according to review comments.
authorJunichi Uekawa <dancer@debian.org>
Mon, 10 Jul 2023 12:14:56 +0000 (21:14 +0900)
committerJunichi Uekawa <dancer@debian.org>
Mon, 10 Jul 2023 12:14:56 +0000 (21:14 +0900)
misc-utils/fincore.c

index e8dfef23536f264f4510cd328a6f9e3ccc60e44b..c92d10b54401a44c3697240fc73443c038f09ba9 100644 (file)
@@ -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;
 }