Block delete capability for read-only devices.

Submitted by:	neel
MFC after:	2 weeks
This commit is contained in:
Alexander Motin 2015-03-15 08:09:56 +00:00
parent e5197e3a08
commit 7e8e553940
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=280017
2 changed files with 5 additions and 2 deletions

View File

@ -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;

View File

@ -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;