ARMmbed / ARMmbed/DAPLink

possible issue for Drag and Drop feature on Mac OS

Open
#745 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
2.8k
Forks
1.1k
Avg merge
3d 12h
Merged PRs (30d)
1

Description

The drag and drop code logic seems to rely on that the bin/hex file is transferred to contiguous sectors.

static void file_data_handler(uint32_t sector, const uint8_t *buf, uint32_t num_of_sectors)
{
stream_type_t stream;
uint32_t size;

// this is the key for starting a file write - we dont care what file types are sent
// just look for something unique (NVIC table, hex, srec, etc) until root dir is updated
if (!file_transfer_state.stream_started) {
// look for file types we can program
stream = stream_start_identify((uint8_t *)buf, VFS_SECTOR_SIZE * num_of_sectors);

if (STREAM_TYPE_NONE != stream) {
transfer_stream_open(stream, sector);
}
}

if (file_transfer_state.stream_started) {
// Ignore sectors coming before this file
if (sector < file_transfer_state.start_sector) {
return;
}

// sectors must be in order
if (**sector != file_transfer_state.file_next_sector**) {
vfs_mngr_printf("vfs_manager file_data_handler sector=%i\r\n", sector);

if (sector < file_transfer_state.file_next_sector) {
vfs_mngr_printf(" sector out of order! lowest ooo = %i\r\n",
file_transfer_state.last_ooo_sector);

if (VFS_INVALID_SECTOR == file_transfer_state.last_ooo_sector) {
file_transfer_state.last_ooo_sector = sector;
}

file_transfer_state.last_ooo_sector =
MIN(file_transfer_state.last_ooo_sector, sector);
} else {
vfs_mngr_printf(" sector not part of file transfer\r\n");
}

vfs_mngr_printf(" discarding data - size transferred=0x%x, data=%x,%x,%x,%x,...\r\n",
file_transfer_state.size_transferred, buf[0], buf[1], buf[2], buf[3]);
return;
}

// This sector could be part of the file so record it
size = VFS_SECTOR_SIZE * num_of_sectors;
file_transfer_state.size_transferred += size;
file_transfer_state.file_next_sector = sector + num_of_sectors;

// If stream processing is done then discard the data
if (file_transfer_state.stream_finished) {
vfs_mngr_printf("vfs_manager file_data_handler\r\n sector=%i, size=%i\r\n", sector, size);
vfs_mngr_printf(" discarding data - size transferred=0x%x, data=%x,%x,%x,%x,...\r\n",
file_transfer_state.size_transferred, buf[0], buf[1], buf[2], buf[3]);
transfer_update_state(ERROR_SUCCESS);
return;
}

transfer_stream_data(sector, buf, size);
}
}

I found that this is true for Windows, but on Mac, the OS can put one file in non-contiguous sectors, and this will cause trouble for the logic implemented above.

Any thought on this?

Contributor guide

Open the contributing guide

Research direction

Start at the file_data_handler entry point and trace how file_transfer_state tracks sectors during a Mac drag-and-drop transfer. Reproduce or inspect a non-contiguous transfer and determine what behavior is required; done means the transfer handles non-contiguous sectors correctly without discarding file data, with the behavior validated on Mac and Windows.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, embedded-iot
Domain
embedded-iot
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.