Skip to content

Commit

Permalink
USB MSC: Fix SCIS mode sense write protection bit (iNavFlight#9572)
Browse files Browse the repository at this point in the history
  • Loading branch information
mluessi authored and JulianTiller committed Oct 18, 2024
1 parent 74ec220 commit bd1cee9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,12 @@ static int8_t SCSI_ModeSense6 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *
len--;
hmsc->bot_data[len] = MSC_Mode_Sense6_data[len];
}

// set bit 7 of the device configuration byte to indicate write protection
if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) {
hmsc->bot_data[2] = hmsc->bot_data[2] | (1 << 7);
}

return 0;
}

Expand All @@ -365,6 +371,12 @@ static int8_t SCSI_ModeSense10 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t
len--;
hmsc->bot_data[len] = MSC_Mode_Sense10_data[len];
}

// set bit 7 of the device configuration byte to indicate write protection
if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) {
hmsc->bot_data[3] = hmsc->bot_data[3] | (1 << 7);
}

return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,12 @@ static int8_t SCSI_ModeSense6 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *
len--;
hmsc->bot_data[len] = MSC_Mode_Sense6_data[len];
}

// set bit 7 of the device configuration byte to indicate write protection
if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) {
hmsc->bot_data[2] = hmsc->bot_data[2] | (1 << 7);
}

return 0;
}

Expand All @@ -370,6 +376,12 @@ static int8_t SCSI_ModeSense10 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t
len--;
hmsc->bot_data[len] = MSC_Mode_Sense10_data[len];
}

// set bit 7 of the device configuration byte to indicate write protection
if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) {
hmsc->bot_data[3] = hmsc->bot_data[3] | (1 << 7);
}

return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@ static int8_t SCSI_ModeSense6(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *p
len--;
hmsc->bot_data[len] = MSC_Mode_Sense6_data[len];
}

// set bit 7 of the device configuration byte to indicate write protection
if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) {
hmsc->bot_data[2] = hmsc->bot_data[2] | (1 << 7);
}

return 0;
}

Expand All @@ -371,6 +377,11 @@ static int8_t SCSI_ModeSense10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *
hmsc->bot_data[len] = MSC_Mode_Sense10_data[len];
}

// set bit 7 of the device configuration byte to indicate write protection
if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) {
hmsc->bot_data[3] = hmsc->bot_data[3] | (1 << 7);
}

return 0;
}

Expand Down

0 comments on commit bd1cee9

Please sign in to comment.