Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial support for raw devices #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 27 additions & 26 deletions src/block_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ blockif_open(const char *optstr, UNUSED const char *ident)
struct blockif_ctxt *bc;
struct stat sbuf;
// struct diocgattr_arg arg;
off_t size, psectsz, psectoff;
off_t size, psectsz, psectoff, blocks;
int extra, fd, i, sectsz;
int nocache, sync, ro, candelete, geom, ssopt, pssopt;

Expand Down Expand Up @@ -493,17 +493,18 @@ blockif_open(const char *optstr, UNUSED const char *ident)
sectsz = DEV_BSIZE;
psectsz = psectoff = 0;
candelete = geom = 0;
blocks = 0;
if (S_ISCHR(sbuf.st_mode)) {
perror("xhyve: raw device support unimplemented");
goto err;
// if (ioctl(fd, DIOCGMEDIASIZE, &size) < 0 ||
// ioctl(fd, DIOCGSECTORSIZE, &sectsz))
// {
// perror("Could not fetch dev blk/sector size");
// goto err;
// }
// assert(size != 0);
// assert(sectsz != 0);
if (ioctl(fd, DKIOCGETBLOCKCOUNT, &blocks) < 0 ||
ioctl(fd, DKIOCGETBLOCKSIZE, &sectsz))
{
perror("Could not fetch dev blk/sector size");
goto err;
}
assert(blocks != 0);
assert(sectsz != 0);

size = blocks * sectsz;
// if (ioctl(fd, DIOCGSTRIPESIZE, &psectsz) == 0 && psectsz > 0)
// ioctl(fd, DIOCGSTRIPEOFFSET, &psectoff);
// strlcpy(arg.name, "GEOM::candelete", sizeof(arg.name));
Expand All @@ -523,21 +524,21 @@ blockif_open(const char *optstr, UNUSED const char *ident)
goto err;
}

// /*
// * Some backend drivers (e.g. cd0, ada0) require that the I/O
// * size be a multiple of the device's sector size.
// *
// * Validate that the emulated sector size complies with this
// * requirement.
// */
// if (S_ISCHR(sbuf.st_mode)) {
// if (ssopt < sectsz || (ssopt % sectsz) != 0) {
// fprintf(stderr, "Sector size %d incompatible "
// "with underlying device sector size %d\n",
// ssopt, sectsz);
// goto err;
// }
// }
/*
* Some backend drivers (e.g. cd0, ada0) require that the I/O
* size be a multiple of the device's sector size.
*
* Validate that the emulated sector size complies with this
* requirement.
*/
if (S_ISCHR(sbuf.st_mode)) {
if (ssopt < sectsz || (ssopt % sectsz) != 0) {
fprintf(stderr, "Sector size %d incompatible "
"with underlying device sector size %d\n",
ssopt, sectsz);
goto err;
}
}

sectsz = ssopt;
psectsz = pssopt;
Expand Down