Skip to content

shared/supervisor/usb_msc_flash.c: check for valid vfs from get_vfs() #10457

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

Merged
merged 1 commit into from
Jul 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions supervisor/shared/usb/usb_msc_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ uint8_t tud_msc_get_maxlun_cb(void) {
// - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, TEST_UNIT_READY, START_STOP_UNIT, MODE_SENSE6, REQUEST_SENSE
// - READ10 and WRITE10 have their own callbacks
int32_t tud_msc_scsi_cb(uint8_t lun, const uint8_t scsi_cmd[16], void *buffer, uint16_t bufsize) {
// Note that no command uses a response right now.
const void *response = NULL;
int32_t resplen = 0;

Expand Down Expand Up @@ -227,8 +228,10 @@ int32_t tud_msc_scsi_cb(uint8_t lun, const uint8_t scsi_cmd[16], void *buffer, u

void tud_msc_capacity_cb(uint8_t lun, uint32_t *block_count, uint16_t *block_size) {
fs_user_mount_t *vfs = get_vfs(lun);
disk_ioctl(vfs, GET_SECTOR_COUNT, block_count);
disk_ioctl(vfs, GET_SECTOR_SIZE, block_size);
if (vfs != NULL) {
disk_ioctl(vfs, GET_SECTOR_COUNT, block_count);
disk_ioctl(vfs, GET_SECTOR_SIZE, block_size);
}
}

bool tud_msc_is_writable_cb(uint8_t lun) {
Expand Down Expand Up @@ -259,6 +262,9 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void *buff
const uint32_t block_count = bufsize / MSC_FLASH_BLOCK_SIZE;

fs_user_mount_t *vfs = get_vfs(lun);
if (vfs == NULL) {
return -1;
}
uint32_t disk_block_count;
disk_ioctl(vfs, GET_SECTOR_COUNT, &disk_block_count);

Expand All @@ -281,6 +287,9 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t *
const uint32_t block_count = bufsize / MSC_FLASH_BLOCK_SIZE;

fs_user_mount_t *vfs = get_vfs(lun);
if (vfs == NULL) {
return -1;
}
disk_write(vfs, buffer, lba, block_count);
// Since by getting here we assume the mount is read-only to
// MicroPython let's update the cached FatFs sector if it's the one
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy