Hi, Hopefully you someone can tell me what I'm doing wrong. First, the code. I placed this at the bottom of the main loop in com32/modules/disk.c as a simple test of writing to the disk: printf(" Host bus: %s, Interface type: %s\n\n", d->edd_params.host_bus_type, d->edd_params.interface_type); zero_buf = calloc(1, d->edd_params.bytes_per_sector); for(int sector = 0; sector < d->edd_params.sectors; sector++){ err = write_verify_sectors(d, sector,zero_buf,1); if (err == -1) { printf("sector: %d error: %d\n", sector, disk_errno); //disk_errno is always zero here } printf("sector: %d wrote:%d\r", sector, err); } if (zero_buf) { free(zero_buf); } } When run, the error case is always executed, but disk_errno is always zero. If I switch to write_sectors() the call succeeds (returns the same number of sectors requested), but the disk is not written. I can't find any examples of using the disk write functions anywhere in the code. Any suggestions would be appreciated. Thanks, Robert Jordan
Pierre-Alexandre Meyer
2010-Sep-20 01:25 UTC
[syslinux] can't get write_sectors to work...
On Sun, Sep 19, 2010 at 4:39 PM, Robert Jordan <rjordan at notampering.com>wrote:> Hi, >Hello Robert, When run, the error case is always executed, but disk_errno is always zero.> If I switch to write_sectors() the call succeeds (returns the same number > of sectors requested), but the disk is not written. I can't find any > examples of using the disk write functions anywhere in the code.disk.c was basically a functional test for the new disklib library. The write_* functions, originally written in chain.c, were extracted. Plan was to rewrite chain.c with this library but this was never done, this is the reason no code is using these functions (the read_* ones are used by HDT though).> Any suggestions would be appreciated. >If write_verify_sectors fails and doesn't set errno, it means that the verify part failed (as expected since the disk is not written). Could you try the following patch? diff --git a/com32/gpllib/disk/write.c b/com32/gpllib/disk/write.c index 89e530d..4ed612a 100644 --- a/com32/gpllib/disk/write.c +++ b/com32/gpllib/disk/write.c @@ -39,7 +39,7 @@ int write_sectors(const struct driveinfo *drive_info, const unsigned int lba, struct ebios_dapa *dapa = __com32.cs_bounce; void *buf = (char *)__com32.cs_bounce + size; - memcpy(buf, data, size); + memcpy(buf, data, SECTOR * size); memset(&inreg, 0, sizeof inreg); if (drive_info->ebios) { Thanks, -- Pierre-Alexandre Meyer http://pub.mouraf.org/blog
On Sun, 2010-09-19 at 16:39 -0700, Robert Jordan wrote:> Hi,> When run, the error case is always executed, but disk_errno is always zero. > If I switch to write_sectors() the call succeeds (returns the same number > of sectors requested), but the disk is not written. I can't find any > examples of using the disk write functions anywhere in the code. Any > suggestions would be appreciated.Take a look at my EXTFS port as it supports disk writes (look at the changes to gpllib/write*). http://github.com/donhiatt/Syslinux-EXT2FS-Library-port The code is still based on the old gpllib/disk* stuff but I'm going to port it to the new disklib branch as soon as I have some free time. Cheers, don