Skip to content

[issue]: disk_write(ventoy2disk/ff14) logic error when sector==0 #3693

Description

@lyn12233

Official FAQ

  • I have checked the official FAQ.

Ventoy Version

1.0.96

What about latest release

No. I didn't try the latest release.

Try alternative boot mode

No. I didn't try these alternative boot modes.

BIOS Mode

Legacy BIOS Mode

Partition Style

MBR

Disk Capacity

(untested)

Disk Manufacturer

No response

Image file checksum (if applicable)

No response

Image file download link (if applicable)

No response

What happened?

Though it may not make venoty2disk fail, diskio.c defines disk_write function as callback to fatfs lib. it considers a corner condition to preserve mbr header:

DRESULT disk_write (
	BYTE pdrv,			/* Physical drive nmuber to identify the drive */
	const BYTE *buff,	/* Data to be written */
	LBA_t sector,		/* Start sector in LBA */
	UINT count			/* Number of sectors to write */
)
{
    ......
    // skip MBR
    if (sector == 0)
    {
        memcpy(g_MbrSector, buff, sizeof(g_MbrSector));

        if (count == 1)
        {
            return RES_OK;
        }

        sector++;
        count--;
    ......

when sector0 is included in a write, the buffer actually written shifts 512 bytes. The correction is simply buff+=512. The reason why this may not be triggering issues is possibly that fatfs always won't write mbr header in conjunction with other data. However I suppose this logical error should be mended.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedThis issue has been fixed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions