Changeset 217 in xtideuniversalbios for trunk/Serial_Server/library/FlatImage.cpp


Ignore:
Timestamp:
Jan 23, 2012, 10:08:13 AM (12 years ago)
Author:
gregli@…
google:author:
gregli@hotmail.com
Message:

Serial Server: various improvements, turned on LBA28 support by default.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Serial_Server/library/FlatImage.cpp

    r213 r217  
    1212#include "FlatImage.h"
    1313
    14 FlatImage::FlatImage( char *name, int p_readOnly, int p_drive, int p_create, unsigned long p_cyl, unsigned long p_sect, unsigned long p_head )   :   Image( name, p_readOnly, p_drive, p_create, p_cyl, p_sect, p_head )
     14FlatImage::FlatImage( char *name, int p_readOnly, int p_drive, int p_create, unsigned long p_cyl, unsigned long p_head, unsigned long p_sect, int p_useCHS )   :   Image( name, p_readOnly, p_drive, p_create, p_cyl, p_head, p_sect, p_useCHS )
    1515{
    16     double sizef;
     16    long filesize;
    1717
    1818    if( p_create )
     
    4040       
    4141        sizef = size2/2048.0;
    42         log( 0, "Created file '%s' with geometry %u:%u:%u, size %.1lf megabytes\n", name, p_cyl, p_sect, p_head, sizef );
     42        if( p_cyl > 1024 )
     43            log( 0, "Created file '%s', size %.1lf MB", name, sizef );
     44        else
     45            log( 0, "Created file '%s', geometry %u:%u:%u, size %.1lf MB", name, p_cyl, p_sect, p_head, sizef );
    4346    }
    4447
     
    4851
    4952    fseek( fp, 0, SEEK_END );
    50     totallba = ftell( fp );
     53    filesize = ftell( fp );
    5154
    52     if( !totallba )
    53         log( -1, "Could not get file size for '%s'", name );
     55    if( filesize == 0 || filesize == -1L )
     56        log( -1, "Could not get file size for '%s', file possibly larger than 2 GB", name );
    5457
    55     if( totallba & 0x1ff )
     58    if( filesize & 0x1ff )
    5659        log( -1, "'%s' not made up of 512 byte sectors", name );
    5760
    58     totallba >>= 9;
    59     if( totallba != (p_sect * p_head * p_cyl) )
    60     {
    61         if( p_sect || p_head || p_cyl )
    62             log( -1, "'%s', file size does not match geometry", name );
    63         else if( (totallba % 16) != 0 || ((totallba/16) % 63) != 0 )
    64             log( -1, "'%s', file size does not match standard geometry (x:16:63), please geometry explicitly with -g", name );
    65         else
    66         {
    67             sect = 63;
    68             head = 16;
    69             cyl = (totallba / sect / head);
    70         }
    71     }
    72     else
    73     {
    74         sect = p_sect;
    75         head = p_head;
    76         cyl = p_cyl;
    77     }
     61    totallba = filesize >> 9;     // 512 bytes per sector
    7862
    79     sizef = totallba/2048.0;
    80     log( 0, "Opening disk '%s', geometry %u:%u:%u, total size %.1lf MB", name, cyl, sect, head, sizef );
     63    init( name, p_readOnly, p_drive, p_cyl, p_head, p_sect, p_useCHS );
    8164}
    8265
Note: See TracChangeset for help on using the changeset viewer.