summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2015-03-15 08:09:56 +0000
committermav <mav@FreeBSD.org>2015-03-15 08:09:56 +0000
commit476187cac818f89a8d8ffcf96fc0257121e9a2e6 (patch)
tree6454d31b8bdd0be8c4851d7ee997bd21a95cbda4 /usr.sbin
parente497716fbdc70d18195c3f432c3b428b0c1dbcea (diff)
downloadFreeBSD-src-476187cac818f89a8d8ffcf96fc0257121e9a2e6.zip
FreeBSD-src-476187cac818f89a8d8ffcf96fc0257121e9a2e6.tar.gz
Block delete capability for read-only devices.
Submitted by: neel MFC after: 2 weeks
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bhyve/block_if.c2
-rw-r--r--usr.sbin/bhyve/pci_ahci.c5
2 files changed, 5 insertions, 2 deletions
diff --git a/usr.sbin/bhyve/block_if.c b/usr.sbin/bhyve/block_if.c
index 23aad01..ceb48fe 100644
--- a/usr.sbin/bhyve/block_if.c
+++ b/usr.sbin/bhyve/block_if.c
@@ -230,6 +230,8 @@ blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be)
case BOP_DELETE:
if (!bc->bc_candelete)
err = EOPNOTSUPP;
+ else if (bc->bc_rdonly)
+ err = EROFS;
else if (bc->bc_ischr) {
arg[0] = br->br_offset;
arg[1] = br->br_iov[0].iov_len;
diff --git a/usr.sbin/bhyve/pci_ahci.c b/usr.sbin/bhyve/pci_ahci.c
index 6a0af28..2303882 100644
--- a/usr.sbin/bhyve/pci_ahci.c
+++ b/usr.sbin/bhyve/pci_ahci.c
@@ -840,10 +840,11 @@ handle_identify(struct ahci_port *p, int slot, uint8_t *cfis)
} else {
uint16_t buf[256];
uint64_t sectors;
- int sectsz, psectsz, psectoff, candelete;
+ int sectsz, psectsz, psectoff, candelete, ro;
uint16_t cyl;
uint8_t sech, heads;
+ ro = blockif_is_ro(p->bctx);
candelete = blockif_candelete(p->bctx);
sectsz = blockif_sectsz(p->bctx);
sectors = blockif_size(p->bctx) / sectsz;
@@ -906,7 +907,7 @@ handle_identify(struct ahci_port *p, int slot, uint8_t *cfis)
buf[101] = (sectors >> 16);
buf[102] = (sectors >> 32);
buf[103] = (sectors >> 48);
- if (candelete) {
+ if (candelete && !ro) {
buf[69] |= ATA_SUPPORT_RZAT | ATA_SUPPORT_DRAT;
buf[105] = 1;
buf[169] = ATA_SUPPORT_DSM_TRIM;
OpenPOWER on IntegriCloud