summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2009-04-12 11:49:36 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2009-04-12 11:49:36 +0200
commit480320fe82922296d6c181ddcc95fbf5cf566330 (patch)
treebe77470b892dd3fae623c9f677e7f752a860e283 /src
parent062da3696d295e903d2e3e97d225c6794653b597 (diff)
Cylinder is now long unsigned int. Fix a parameter inversion for the DOS version.
Diffstat (limited to 'src')
-rw-r--r--src/common.h4
-rw-r--r--src/edit.c6
-rw-r--r--src/ewf.c2
-rw-r--r--src/geometry.c6
-rw-r--r--src/hdaccess.c6
-rw-r--r--src/msdos.c17
-rw-r--r--src/parti386.c6
-rw-r--r--src/win32.c8
8 files changed, 27 insertions, 28 deletions
diff --git a/src/common.h b/src/common.h
index a8d1c7e..d30a6e7 100644
--- a/src/common.h
+++ b/src/common.h
@@ -237,7 +237,7 @@ typedef struct partition_struct partition_t;
typedef struct CHS_struct CHS_t;
typedef struct
{
- unsigned int cylinders;
+ unsigned long int cylinders;
unsigned int heads_per_cylinder;
unsigned int sectors_per_head;
// unsigned int bytes_per_sector;
@@ -245,7 +245,7 @@ typedef struct
struct CHS_struct
{
- unsigned int cylinder;
+ unsigned long int cylinder;
unsigned int head;
unsigned int sector;
};
diff --git a/src/edit.c b/src/edit.c
index 4ecca70..3b409c4 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -124,7 +124,7 @@ static void interface_editor_position(const disk_t *disk_car,uint64_t *lba)
int done = 0;
char def[LINE_LENGTH];
char response[LINE_LENGTH];
- unsigned int tmp_val;
+ unsigned long int tmp_val;
int command;
position.cylinder=offset2cylinder(disk_car,*lba);
position.head=offset2head(disk_car,*lba);
@@ -145,10 +145,10 @@ static void interface_editor_position(const disk_t *disk_car,uint64_t *lba)
switch (command) {
case 'c':
case 'C':
- sprintf(def, "%u", position.cylinder);
+ sprintf(def, "%lu", position.cylinder);
mvwaddstr(stdscr,INTER_GEOM_Y, INTER_GEOM_X, "Enter the number of cylinders: ");
if (get_string(response, LINE_LENGTH, def) > 0) {
- tmp_val = atoi(response);
+ tmp_val = atol(response);
if (tmp_val < disk_car->geom.cylinders) {
position.cylinder = tmp_val;
} else
diff --git a/src/ewf.c b/src/ewf.c
index 4b7ac35..ed06841 100644
--- a/src/ewf.c
+++ b/src/ewf.c
@@ -176,7 +176,7 @@ static const char *fewf_description(disk_t *disk)
{
const struct info_fewf_struct *data=(const struct info_fewf_struct *)disk->data;
char buffer_disk_size[100];
- snprintf(disk->description_txt, sizeof(disk->description_txt),"Image %s - %s - CHS %u %u %u%s",
+ snprintf(disk->description_txt, sizeof(disk->description_txt),"Image %s - %s - CHS %lu %u %u%s",
data->file_name, size_to_unit(disk->disk_size,buffer_disk_size),
disk->geom.cylinders, disk->geom.heads_per_cylinder, disk->geom.sectors_per_head,
((data->mode&O_RDWR)==O_RDWR?"":" (RO)"));
diff --git a/src/geometry.c b/src/geometry.c
index 73e8414..0357070 100644
--- a/src/geometry.c
+++ b/src/geometry.c
@@ -146,7 +146,7 @@ static void change_geometry_ncurses(disk_t *disk_car)
int done = 0;
char def[LINE_LENGTH];
char response[LINE_LENGTH];
- int tmp_val=0;
+ long int tmp_val=0;
int command;
int default_option=4;
int cyl_modified=0;
@@ -185,10 +185,10 @@ static void change_geometry_ncurses(disk_t *disk_car)
case 'c':
case 'C':
{
- sprintf(def, "%u", disk_car->geom.cylinders);
+ sprintf(def, "%lu", disk_car->geom.cylinders);
mvwaddstr(stdscr,INTER_GEOM_Y, INTER_GEOM_X, "Enter the number of cylinders: ");
if (get_string(response, LINE_LENGTH, def) > 0) {
- tmp_val = atoi(response);
+ tmp_val = atol(response);
if (tmp_val > 0) {
disk_car->geom.cylinders = tmp_val;
cyl_modified=1;
diff --git a/src/hdaccess.c b/src/hdaccess.c
index acae010..61519e7 100644
--- a/src/hdaccess.c
+++ b/src/hdaccess.c
@@ -756,13 +756,13 @@ void update_disk_car_fields(disk_t *disk_car)
}
else
{
- const unsigned int cylinder_num=disk_car->disk_real_size /
+ const unsigned long int cylinder_num=disk_car->disk_real_size /
(uint64_t)disk_car->geom.heads_per_cylinder /
(uint64_t)disk_car->geom.sectors_per_head /
(uint64_t)disk_car->sector_size;
if(cylinder_num>0 && disk_car->geom.cylinders != cylinder_num)
{
- log_debug("Fix cylinder count for %s: number of cylinders %u != %u (calculated)\n",
+ log_debug("Fix cylinder count for %s: number of cylinders %lu != %lu (calculated)\n",
disk_car->device, disk_car->geom.cylinders, cylinder_num);
disk_car->geom.cylinders = cylinder_num;
}
@@ -1023,7 +1023,7 @@ static const char *file_description(disk_t *disk_car)
{
const struct info_file_struct *data=(const struct info_file_struct *)disk_car->data;
char buffer_disk_size[100];
- snprintf(disk_car->description_txt, sizeof(disk_car->description_txt),"Disk %s - %s - CHS %u %u %u%s",
+ snprintf(disk_car->description_txt, sizeof(disk_car->description_txt),"Disk %s - %s - CHS %lu %u %u%s",
disk_car->device, size_to_unit(disk_car->disk_size,buffer_disk_size),
disk_car->geom.cylinders, disk_car->geom.heads_per_cylinder, disk_car->geom.sectors_per_head,
((data->mode&O_RDWR)==O_RDWR?"":" (RO)"));
diff --git a/src/msdos.c b/src/msdos.c
index 3425b41..5e85c1f 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -52,9 +52,9 @@ static int hd_identify_enh_bios(disk_t *param_disk,const int verbose);
static int check_enh_bios(const unsigned int disk, const int verbose);
static int hd_report_error(disk_t *disk_car, const uint64_t hd_offset, const unsigned int count, const int rc);
static const char *disk_description_short(disk_t *disk_car);
-static int disk_pread(disk_t *disk_car, const unsigned int count, void *buf, const uint64_t hd_offset);
-static int disk_pwrite(disk_t *disk_car, const unsigned int count, const void *buf, const uint64_t hd_offset);
-static int disk_nopwrite(disk_t *disk_car, const unsigned int count, const void *buf, const uint64_t offset);
+static int disk_pread(disk_t *disk_car, void *buf, const unsigned int count, const uint64_t hd_offset);
+static int disk_pwrite(disk_t *disk_car, const void *buf, const unsigned int count, const uint64_t hd_offset);
+static int disk_nopwrite(disk_t *disk_car, const void *buf, const unsigned int count, const uint64_t offset);
static int disk_sync(disk_t *disk_car);
static int disk_clean(disk_t *disk_car);
@@ -320,7 +320,7 @@ static int hd_identify_enh_bios(disk_t *disk_car,const int verbose)
}
computed_size=(uint64_t)disk_car->geom.cylinders*disk_car->geom.heads_per_cylinder*disk_car->geom.sectors_per_head*disk_car->sector_size;
if(verbose>0 || data->bad_geometry!=0)
- log_info("LBA %lu, computed %lu (CHS=%u,%u,%u)\n",
+ log_info("LBA %lu, computed %lu (CHS=%lu,%u,%u)\n",
(long unsigned)(disk_car->disk_size/disk_car->sector_size),
(long unsigned)(computed_size/disk_car->sector_size),
disk_car->geom.cylinders,
@@ -432,7 +432,7 @@ const char *disk_description(disk_t *disk_car)
{
struct info_disk_struct*data=disk_car->data;
char buffer_disk_size[100];
- snprintf(disk_car->description_txt, sizeof(disk_car->description_txt),"Disk %2x - %s - CHS %u %u %u%s",
+ snprintf(disk_car->description_txt, sizeof(disk_car->description_txt),"Disk %2x - %s - CHS %lu %u %u%s",
data->disk, size_to_unit(disk_car->disk_size,buffer_disk_size),
disk_car->geom.cylinders, disk_car->geom.heads_per_cylinder, disk_car->geom.sectors_per_head,
data->bad_geometry!=0?" (Buggy BIOS)":"");
@@ -484,14 +484,13 @@ static int disk_pread_aux(disk_t *disk_car, void *buf, const unsigned int count,
return count;
}
-static int disk_pread(disk_t *disk_car, const unsigned int count, void *buf, const uint64_t offset)
+static int disk_pread(disk_t *disk_car, void *buf, const unsigned int count, const uint64_t offset)
{
return align_pread(&disk_pread_aux, disk_car, buf, count, offset);
}
static int disk_pwrite_aux(disk_t *disk_car, const void *buf, const unsigned int count, const uint64_t hd_offset)
{
-
struct info_disk_struct*data=disk_car->data;
int i=0;
int rc;
@@ -510,12 +509,12 @@ static int disk_pwrite_aux(disk_t *disk_car, const void *buf, const unsigned int
return rc;
}
-static int disk_pwrite(disk_t *disk_car, const unsigned int count, const void *buf, const uint64_t offset)
+static int disk_pwrite(disk_t *disk_car, const void *buf, const unsigned int count, const uint64_t offset)
{
return align_pwrite(&disk_pread_aux, &disk_pwrite_aux, disk_car, buf, count, offset);
}
-static int disk_nopwrite(disk_t *disk_car,const unsigned int count, const void *buf, const uint64_t offset)
+static int disk_nopwrite(disk_t *disk_car, const void *buf, const unsigned int count, const uint64_t offset)
{
struct info_disk_struct *data=disk_car->data;
log_warning("disk_nopwrite(%d,%u,buffer,%lu(%u/%u/%u)) write refused\n", data->disk,
diff --git a/src/parti386.c b/src/parti386.c
index 44161db..d69be54 100644
--- a/src/parti386.c
+++ b/src/parti386.c
@@ -810,7 +810,7 @@ static int write_all_log_i386(disk_t *disk_car, const list_part_t *list_part, co
}
nextext_start.sector=1;
if(verbose>1)
- log_verbose("nextext_start %u/%u/%u %lu ? %lu\n", nextext_start.cylinder,nextext_start.head,nextext_start.sector,
+ log_verbose("nextext_start %lu/%u/%u %lu ? %lu\n", nextext_start.cylinder,nextext_start.head,nextext_start.sector,
(long unsigned)(CHS2offset(disk_car,&nextext_start)/disk_car->sector_size),
(long unsigned)((element->part->part_offset+element->part->part_size-1)/disk_car->sector_size));
if(CHS2offset(disk_car,&nextext_start)<=element->part->part_offset+element->part->part_size-1)
@@ -818,7 +818,7 @@ static int write_all_log_i386(disk_t *disk_car, const list_part_t *list_part, co
offset2CHS(disk_car,bloc_nextext->part_offset,&nextext_start);
nextext_start.sector=1;
if(verbose>1)
- log_verbose("nextext_start %u/%u/%u %lu ? %lu\n", nextext_start.cylinder,nextext_start.head,nextext_start.sector,
+ log_verbose("nextext_start %lu/%u/%u %lu ? %lu\n", nextext_start.cylinder,nextext_start.head,nextext_start.sector,
(long unsigned)(CHS2offset(disk_car,&nextext_start)/disk_car->sector_size),
(long unsigned)((element->part->part_offset+element->part->part_size-1)/disk_car->sector_size));
if(CHS2offset(disk_car,&nextext_start)<=element->part->part_offset+element->part->part_size-1)
@@ -827,7 +827,7 @@ static int write_all_log_i386(disk_t *disk_car, const list_part_t *list_part, co
}
}
if(verbose>1)
- log_verbose("nextext_start %u/%u/%u %lu ? %lu\n", nextext_start.cylinder,nextext_start.head,nextext_start.sector,
+ log_verbose("nextext_start %lu/%u/%u %lu ? %lu\n", nextext_start.cylinder,nextext_start.head,nextext_start.sector,
(long unsigned)(CHS2offset(disk_car,&nextext_start)/disk_car->sector_size),
(long unsigned)((element->part->part_offset+element->part->part_size-1)/disk_car->sector_size));
bloc_nextext->part_offset=CHS2offset(disk_car,&nextext_start);
diff --git a/src/win32.c b/src/win32.c
index d2a3b0c..6c1c109 100644
--- a/src/win32.c
+++ b/src/win32.c
@@ -150,7 +150,7 @@ void disk_get_geometry_win32(CHSgeometry_t *geom, HANDLE handle, const char *dev
if(geom->sectors_per_head!=0)
{
if(verbose>1)
- log_verbose("IOCTL_DISK_GET_DRIVE_GEOMETRY_EX %s Ok (%u, %u, %u)\n",
+ log_verbose("IOCTL_DISK_GET_DRIVE_GEOMETRY_EX %s Ok (%lu, %u, %u)\n",
device, geom->cylinders, geom->heads_per_cylinder, geom->sectors_per_head);
return ;
}
@@ -168,7 +168,7 @@ void disk_get_geometry_win32(CHSgeometry_t *geom, HANDLE handle, const char *dev
if(geom->sectors_per_head!=0)
{
if(verbose>1)
- log_verbose("IOCTL_DISK_GET_DRIVE_GEOMETRY %s Ok (%u, %u, %u)\n",
+ log_verbose("IOCTL_DISK_GET_DRIVE_GEOMETRY %s Ok (%lu, %u, %u)\n",
device, geom->cylinders, geom->heads_per_cylinder, geom->sectors_per_head);
return ;
}
@@ -346,12 +346,12 @@ static const char *file_win32_description(disk_t *disk_car)
struct info_file_win32_struct *data=disk_car->data;
char buffer_disk_size[100];
if(disk_car->device[0]=='\\' && disk_car->device[1]=='\\' && disk_car->device[2]=='.' && disk_car->device[3]=='\\' && disk_car->device[5]==':')
- snprintf(disk_car->description_txt, sizeof(disk_car->description_txt),"Drive %c: - %s - CHS %u %u %u%s",
+ snprintf(disk_car->description_txt, sizeof(disk_car->description_txt),"Drive %c: - %s - CHS %lu %u %u%s",
disk_car->device[4], size_to_unit(disk_car->disk_size,buffer_disk_size),
disk_car->geom.cylinders, disk_car->geom.heads_per_cylinder, disk_car->geom.sectors_per_head,
((data->mode&FILE_WRITE_DATA)==FILE_WRITE_DATA?"":" (RO)"));
else
- snprintf(disk_car->description_txt, sizeof(disk_car->description_txt),"Disk %s - %s - CHS %u %u %u%s",
+ snprintf(disk_car->description_txt, sizeof(disk_car->description_txt),"Disk %s - %s - CHS %lu %u %u%s",
disk_car->device, size_to_unit(disk_car->disk_size,buffer_disk_size),
disk_car->geom.cylinders, disk_car->geom.heads_per_cylinder, disk_car->geom.sectors_per_head,
((data->mode&FILE_WRITE_DATA)==FILE_WRITE_DATA?"":" (RO)"));