Skip to content
Snippets Groups Projects
Unverified Commit 18df98b7 authored by Marcin Ślusarz's avatar Marcin Ślusarz Committed by GitHub
Browse files

Merge pull request #3943 from ldorau/test-fix-printing-length-of-bad-blocks-in-case-of-DAX-devices

test: fix printing length of bad blocks in case of DAX devices
parents 598af08b d68a037f
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,7 @@
#include "os_dimm.h"
#include "os_badblock.h"
#include "badblock.h"
#include "file.h"
#define MIN_POOL ((size_t)(1024 * 1024 * 8)) /* 8 MiB */
#define MIN_PART ((size_t)(1024 * 1024 * 2)) /* 2 MiB */
......@@ -71,6 +72,10 @@ do_list(const char *path)
goto exit_free;
}
int file_type = util_file_get_type(path);
if (file_type < 0)
UT_FATAL("!Cannot read type of the file");
UT_OUT("Found %u bad block(s):", bbs->bb_cnt);
unsigned b;
......@@ -78,8 +83,14 @@ do_list(const char *path)
UT_OUT("%llu %u",
/* offset is printed in 512b sectors */
bbs->bbv[b].offset >> 9,
/* length is printed in blocks */
bbs->bbv[b].length / (unsigned)st.st_blksize);
/*
* length is printed in:
* - 512b sectors in case of DAX devices,
* - blocks in case of regular files.
*/
(file_type == TYPE_DEVDAX) ?
bbs->bbv[b].length >> 9 :
bbs->bbv[b].length / (unsigned)st.st_blksize);
}
exit_free:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment