I need to securely erase an MMC card in an embedded system. However, my ioctl(BLKSECDISCARD)
returns EOPNOTSUPP
, (as does BLKDISCARD
).
By reading kernel code, the MMC driver enables DISCARD by setting QUEUE_FLAG_DISCARD
in kernel/linux/drivers/mmc/card/queue.c mmc_queue_setup_discard()
, which is called as follows:
if (mmc_can_erase(card))
mmc_queue_setup_discard(mq->queue, card);
Where mmc_can_erase()
is defined in kernel/linux/drivers/mmc/core/core.c
as:
int mmc_can_erase(struct mmc_card *card)
{
if ((card->host->caps & MMC_CAP_ERASE) &&
(card->csd.cmdclass & CCC_ERASE) && card->erase_size)
return 1;
return 0;
}
What is required for the conditions in mmc_can_erase()
to be met?
Is it a feature of the card, the controller, the driver, the way the kernel is built, or something else?
Ideally, I'd like to enable the BLKSECDISCARD
feature, but am unsure what I need to do, or even if it is possible on my embedded system. Can it be done?