fsck.cramfs: use open+fstat rather than stat+open
Fixes: https://github.com/karelzak/util-linux/issues/1353 Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
86328e78ea
commit
b0f8d63e63
|
@ -152,14 +152,15 @@ static void test_super(int *start, size_t * length)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
/* find the physical size of the file or block device */
|
|
||||||
if (stat(filename, &st) < 0)
|
|
||||||
err(FSCK_EX_ERROR, _("stat of %s failed"), filename);
|
|
||||||
|
|
||||||
fd = open(filename, O_RDONLY);
|
fd = open(filename, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
err(FSCK_EX_ERROR, _("cannot open %s"), filename);
|
err(FSCK_EX_ERROR, _("cannot open %s"), filename);
|
||||||
|
|
||||||
|
/* find the physical size of the file or block device */
|
||||||
|
if (fstat(fd, &st) < 0)
|
||||||
|
err(FSCK_EX_ERROR, _("stat of %s failed"), filename);
|
||||||
|
|
||||||
if (S_ISBLK(st.st_mode)) {
|
if (S_ISBLK(st.st_mode)) {
|
||||||
unsigned long long bytes;
|
unsigned long long bytes;
|
||||||
if (blkdev_get_size(fd, &bytes))
|
if (blkdev_get_size(fd, &bytes))
|
||||||
|
|
Loading…
Reference in New Issue