Changeset 161 in MondoRescue
- Timestamp:
- Dec 8, 2005, 11:37:26 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.05/mondo/mondo/common/libmondo-devices.c
r152 r161 1209 1209 if (outvalB <= 0) { 1210 1210 log_msg(1, "Error getting size of %s: %s", drive, strerror(errno)); 1211 }1212 1211 #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 } 1223 1225 } 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); 1226 1231 } 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, 1229 1233 strerror(errno)); 1230 1234 } 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 } 1239 1238 /* 1240 1239 if ((fd = open (drive, O_RDONLY)) != -1) { … … 1249 1248 */ 1250 1249 #endif 1251 1250 } 1252 1251 // OLDER DISKS will give ridiculously low value for outvalB (so outvalA is returned) :) 1253 1252 // NEWER DISKS will give sane value for outvalB (close to outvalA, in other words) :) … … 2901 2900 struct stat buf; 2902 2901 #endif 2903 2904 2902 malloc_string(tmp); 2905 2903 malloc_string(command);
Note:
See TracChangeset
for help on using the changeset viewer.