Skip to content

Commit d37d25d

Browse files
authored
Merge pull request #2532 from acscd/master
Added support for SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL
2 parents c773c61 + c8805c6 commit d37d25d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/class/msc/msc_device.c

+18
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,24 @@ static int32_t proc_builtin_scsi(uint8_t lun, uint8_t const scsi_cmd[16], uint8_
689689
}
690690
break;
691691

692+
case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
693+
resplen = 0;
694+
695+
if (tud_msc_prevent_allow_medium_removal_cb)
696+
{
697+
scsi_prevent_allow_medium_removal_t const * prevent_allow = (scsi_prevent_allow_medium_removal_t const *) scsi_cmd;
698+
if ( !tud_msc_prevent_allow_medium_removal_cb(lun, prevent_allow->prohibit_removal, prevent_allow->control) )
699+
{
700+
// Failed status response
701+
resplen = - 1;
702+
703+
// set default sense if not set by callback
704+
if ( p_msc->sense_key == 0 ) set_sense_medium_not_present(lun);
705+
}
706+
}
707+
break;
708+
709+
692710
case SCSI_CMD_READ_CAPACITY_10:
693711
{
694712
uint32_t block_count;

src/class/msc/msc_device.h

+3
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ TU_ATTR_WEAK uint8_t tud_msc_get_maxlun_cb(void);
131131
// - Start = 1 : active mode, if load_eject = 1 : load disk storage
132132
TU_ATTR_WEAK bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject);
133133

134+
//Invoked when we receive the Prevent / Allow Medium Removal command
135+
TU_ATTR_WEAK bool tud_msc_prevent_allow_medium_removal_cb(uint8_t lun, uint8_t prohibit_removal, uint8_t control);
136+
134137
// Invoked when received REQUEST_SENSE
135138
TU_ATTR_WEAK int32_t tud_msc_request_sense_cb(uint8_t lun, void* buffer, uint16_t bufsize);
136139

0 commit comments

Comments
 (0)