Skip to content

Commit

Permalink
Merge pull request machyve#9 from smoofra/master
Browse files Browse the repository at this point in the history
get proper size for raw block devices.
  • Loading branch information
dwoz authored Apr 23, 2017
2 parents 5297a8c + 5a98025 commit 555d0fb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/block_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,20 @@ blockif_open(const char *optstr, UNUSED const char *ident)
// candelete = arg.value.i;
// if (ioctl(fd, DIOCGPROVIDERNAME, name) == 0)
// geom = 1;
} else
} else if (S_ISBLK(sbuf.st_mode)) {
uint64_t num_blocks;
uint32_t block_size;
if (ioctl(fd, DKIOCGETBLOCKSIZE, (void*)&block_size) < 0) {
perror("DKIOCGETBLOCKSIZE");
}
if (ioctl(fd, DKIOCGETBLOCKCOUNT, (void*)&num_blocks) < 0) {
perror("DKIOCGETBLOCKCOUNT");
}
size = (off_t) (num_blocks * block_size);
sectsz = (int) block_size;
} else {
psectsz = sbuf.st_blksize;
}

if (ssopt != 0) {
if (!powerof2(ssopt) || !powerof2(pssopt) || ssopt < 512 ||
Expand Down

0 comments on commit 555d0fb

Please sign in to comment.