Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/block_if.c
| Show First 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | |||||
| static void | static void | ||||
| blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be, uint8_t *buf) | blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be, uint8_t *buf) | ||||
| { | { | ||||
| struct blockif_req *br; | struct blockif_req *br; | ||||
| off_t arg[2]; | off_t arg[2]; | ||||
| ssize_t clen, len, off, boff, voff; | ssize_t clen, len, off, boff, voff; | ||||
| int i, err; | int i, err; | ||||
| struct spacectl_range range; | |||||
| br = be->be_req; | br = be->be_req; | ||||
| if (br->br_iovcnt <= 1) | if (br->br_iovcnt <= 1) | ||||
| buf = NULL; | buf = NULL; | ||||
| err = 0; | err = 0; | ||||
| switch (be->be_op) { | switch (be->be_op) { | ||||
| case BOP_READ: | case BOP_READ: | ||||
| if (buf == NULL) { | if (buf == NULL) { | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | else if (bc->bc_rdonly) | ||||
| err = EROFS; | err = EROFS; | ||||
| else if (bc->bc_ischr) { | else if (bc->bc_ischr) { | ||||
| arg[0] = br->br_offset; | arg[0] = br->br_offset; | ||||
| arg[1] = br->br_resid; | arg[1] = br->br_resid; | ||||
| if (ioctl(bc->bc_fd, DIOCGDELETE, arg)) | if (ioctl(bc->bc_fd, DIOCGDELETE, arg)) | ||||
| err = errno; | err = errno; | ||||
| else | else | ||||
| br->br_resid = 0; | br->br_resid = 0; | ||||
| } else | } else { | ||||
| err = EOPNOTSUPP; | range.r_offset = br->br_offset; | ||||
| range.r_len = br->br_resid; | |||||
| if (fspacectl(bc->bc_fd, SPACECTL_DEALLOC, &range, 0)) | |||||
| err = errno; | |||||
| else | |||||
| br->br_resid = 0; | |||||
| } | |||||
| break; | break; | ||||
| default: | default: | ||||
| err = EINVAL; | err = EINVAL; | ||||
| break; | break; | ||||
| } | } | ||||
| be->be_status = BST_DONE; | be->be_status = BST_DONE; | ||||
| ▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | if (S_ISCHR(sbuf.st_mode)) { | ||||
| if (ioctl(fd, DIOCGSTRIPESIZE, &psectsz) == 0 && psectsz > 0) | if (ioctl(fd, DIOCGSTRIPESIZE, &psectsz) == 0 && psectsz > 0) | ||||
| ioctl(fd, DIOCGSTRIPEOFFSET, &psectoff); | ioctl(fd, DIOCGSTRIPEOFFSET, &psectoff); | ||||
| strlcpy(arg.name, "GEOM::candelete", sizeof(arg.name)); | strlcpy(arg.name, "GEOM::candelete", sizeof(arg.name)); | ||||
| arg.len = sizeof(arg.value.i); | arg.len = sizeof(arg.value.i); | ||||
| if (nodelete == 0 && ioctl(fd, DIOCGATTR, &arg) == 0) | if (nodelete == 0 && ioctl(fd, DIOCGATTR, &arg) == 0) | ||||
| candelete = arg.value.i; | candelete = arg.value.i; | ||||
| if (ioctl(fd, DIOCGPROVIDERNAME, name) == 0) | if (ioctl(fd, DIOCGPROVIDERNAME, name) == 0) | ||||
| geom = 1; | geom = 1; | ||||
| } else | } else { | ||||
| psectsz = sbuf.st_blksize; | psectsz = sbuf.st_blksize; | ||||
| /* Avoid fallback implementation */ | |||||
| candelete = fpathconf(fd, _PC_FDEALLOC_PRESENT) == 1; | |||||
| } | |||||
| #ifndef WITHOUT_CAPSICUM | #ifndef WITHOUT_CAPSICUM | ||||
| if (caph_ioctls_limit(fd, cmds, nitems(cmds)) == -1) | if (caph_ioctls_limit(fd, cmds, nitems(cmds)) == -1) | ||||
| errx(EX_OSERR, "Unable to apply rights for sandbox"); | errx(EX_OSERR, "Unable to apply rights for sandbox"); | ||||
| #endif | #endif | ||||
| if (ssopt != 0) { | if (ssopt != 0) { | ||||
| if (!powerof2(ssopt) || !powerof2(pssopt) || ssopt < 512 || | if (!powerof2(ssopt) || !powerof2(pssopt) || ssopt < 512 || | ||||
| ▲ Show 20 Lines • Show All 438 Lines • Show Last 20 Lines | |||||