else {
size_t bytes;
- for (bytes = 0; bytes < priv->base.rom_size; /* empty */) {
+ for (bytes = 0; bytes < rom_size; /* empty */) {
const ssize_t got = pread(fd, buffer, rom_size - bytes,
rom_base + bytes);
if (got == -1) {
int fd;
struct stat st;
int err = 0;
+ size_t rom_size;
size_t total_bytes;
return errno;
}
+ rom_size = st.st_size;
+ if ( rom_size == 0 )
+ rom_size = 0x10000;
/* This is a quirky thing on Linux. Even though the ROM and the file
* for the ROM in sysfs are read-only, the string "1" must be written to
write( fd, "1", 1 );
lseek( fd, 0, SEEK_SET );
- for ( total_bytes = 0 ; total_bytes < st.st_size ; /* empty */ ) {
+ for ( total_bytes = 0 ; total_bytes < rom_size ; /* empty */ ) {
const int bytes = read( fd, (char *) buffer + total_bytes,
- st.st_size - total_bytes );
+ rom_size - total_bytes );
if ( bytes == -1 ) {
err = errno;
break;