Changeset 161


Ignore:
Timestamp:
Dec 8, 2005, 11:37:26 AM (14 years ago)
Author:
andree
Message:

Avoid overwriting the already correctly determined disk size by moving
the relevant code inside the if clause that checks the validity of the
previously calculated disk size.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.05/mondo/mondo/common/libmondo-devices.c

    r152 r161  
    12091209    if (outvalB <= 0) {
    12101210        log_msg(1, "Error getting size of %s: %s", drive, strerror(errno));
    1211     }
    12121211#if linux
    1213     fileid = open(drive, O_RDONLY);
    1214     if (fileid) {
    1215         if (ioctl(fileid, HDIO_GETGEO, &hdgeo) != -1) {
    1216             if (hdgeo.cylinders && hdgeo.heads && hdgeo.sectors) {
    1217                 cylindersleft = cylinders = hdgeo.cylinders;
    1218                 cylindersize = hdgeo.heads * hdgeo.sectors / 2;
    1219                 outvalA = cylindersize * cylinders / 1024;
    1220                 log_msg(2, "Got Harddisk geometry, C:%d, H:%d, S:%d",
    1221                         hdgeo.cylinders, hdgeo.heads, hdgeo.sectors);
    1222                 gotgeo = 1;
     1212        fileid = open(drive, O_RDONLY);
     1213        if (fileid) {
     1214            if (ioctl(fileid, HDIO_GETGEO, &hdgeo) != -1) {
     1215                if (hdgeo.cylinders && hdgeo.heads && hdgeo.sectors) {
     1216                    cylindersleft = cylinders = hdgeo.cylinders;
     1217                    cylindersize = hdgeo.heads * hdgeo.sectors / 2;
     1218                    outvalA = cylindersize * cylinders / 1024;
     1219                    log_msg(2, "Got Harddisk geometry, C:%d, H:%d, S:%d",
     1220                            hdgeo.cylinders, hdgeo.heads, hdgeo.sectors);
     1221                    gotgeo = 1;
     1222                } else {
     1223                    log_msg(1, "Harddisk geometry wrong");
     1224                }
    12231225            } else {
    1224                 log_msg(1, "Harddisk geometry wrong");
    1225             }
     1226                log_msg(1,
     1227                        "Error in ioctl() getting new hard disk geometry (%s), resizing in unsafe mode",
     1228                        strerror(errno));
     1229            }
     1230            close(fileid);
    12261231        } else {
    1227             log_msg(1,
    1228                     "Error in ioctl() getting new hard disk geometry (%s), resizing in unsafe mode",
     1232            log_msg(1, "Failed to open %s for reading: %s", drive,
    12291233                    strerror(errno));
    12301234        }
    1231         close(fileid);
    1232     } else {
    1233         log_msg(1, "Failed to open %s for reading: %s", drive,
    1234                 strerror(errno));
    1235     }
    1236     if (!gotgeo) {
    1237         log_msg(1, "Failed to get harddisk geometry, using old mode");
    1238     }
     1235        if (!gotgeo) {
     1236            log_msg(1, "Failed to get harddisk geometry, using old mode");
     1237        }
    12391238/* 
    12401239  if ((fd = open (drive, O_RDONLY)) != -1) {
     
    12491248 */
    12501249#endif
    1251 
     1250    }
    12521251// OLDER DISKS will give ridiculously low value for outvalB (so outvalA is returned) :)
    12531252// NEWER DISKS will give sane value for outvalB (close to outvalA, in other words) :)
     
    29012900    struct stat buf;
    29022901#endif
    2903 
    29042902    malloc_string(tmp);
    29052903    malloc_string(command);
Note: See TracChangeset for help on using the changeset viewer.