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

Added support for SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL #2532

Merged
merged 1 commit into from May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/class/msc/msc_device.c
Expand Up @@ -685,6 +685,24 @@ static int32_t proc_builtin_scsi(uint8_t lun, uint8_t const scsi_cmd[16], uint8_
}
break;

case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
resplen = 0;

if (tud_msc_prevent_allow_medium_removal_cb)
{
scsi_prevent_allow_medium_removal_t const * prevent_allow = (scsi_prevent_allow_medium_removal_t const *) scsi_cmd;
if ( !tud_msc_prevent_allow_medium_removal_cb(lun, prevent_allow->prohibit_removal, prevent_allow->control) )
{
// Failed status response
resplen = - 1;

// set default sense if not set by callback
if ( p_msc->sense_key == 0 ) set_sense_medium_not_present(lun);
}
}
break;


case SCSI_CMD_READ_CAPACITY_10:
{
uint32_t block_count;
Expand Down
3 changes: 3 additions & 0 deletions src/class/msc/msc_device.h
Expand Up @@ -131,6 +131,9 @@ TU_ATTR_WEAK uint8_t tud_msc_get_maxlun_cb(void);
// - Start = 1 : active mode, if load_eject = 1 : load disk storage
TU_ATTR_WEAK bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject);

//Invoked when we receive the Prevent / Allow Medium Removal command
TU_ATTR_WEAK bool tud_msc_prevent_allow_medium_removal_cb(uint8_t lun, uint8_t prohibit_removal, uint8_t control);

// Invoked when received REQUEST_SENSE
TU_ATTR_WEAK int32_t tud_msc_request_sense_cb(uint8_t lun, void* buffer, uint16_t bufsize);

Expand Down