summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2010-10-24 20:30:19 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2010-10-24 20:30:19 +0200
commit7fbc038d1e62f4211aef0b0cc68d4be98f7df3a3 (patch)
treed4c9e19cbb1f828e8333ec6111660c0af91c5ecb
parentc9cd19d63db1dd2011370ee0bfc90ecc518f8ae2 (diff)
New prototype for size_to_unit()
-rw-r--r--src/ewf.c6
-rw-r--r--src/fnctdsk.c3
-rw-r--r--src/fnctdsk.h2
-rw-r--r--src/godmode.c11
-rw-r--r--src/hdaccess.c8
-rw-r--r--src/intrface.c3
-rw-r--r--src/log_part.c3
-rw-r--r--src/msdos.c6
-rw-r--r--src/win32.c14
9 files changed, 35 insertions, 21 deletions
diff --git a/src/ewf.c b/src/ewf.c
index 6174b0a..2424f9f 100644
--- a/src/ewf.c
+++ b/src/ewf.c
@@ -176,8 +176,9 @@ 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];
+ size_to_unit(disk->disk_size, buffer_disk_size);
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),
+ data->file_name, buffer_disk_size,
disk->geom.cylinders, disk->geom.heads_per_cylinder, disk->geom.sectors_per_head,
((data->mode&O_RDWR)==O_RDWR?"":" (RO)"));
return disk->description_txt;
@@ -187,8 +188,9 @@ static const char *fewf_description_short(disk_t *disk)
{
const struct info_fewf_struct *data=(const struct info_fewf_struct *)disk->data;
char buffer_disk_size[100];
+ size_to_unit(disk->disk_size, buffer_disk_size);
snprintf(disk->description_short_txt, sizeof(disk->description_txt),"Image %s - %s%s",
- data->file_name, size_to_unit(disk->disk_size,buffer_disk_size),
+ data->file_name, buffer_disk_size,
((data->mode&O_RDWR)==O_RDWR?"":" (RO)"));
return disk->description_short_txt;
}
diff --git a/src/fnctdsk.c b/src/fnctdsk.c
index 02e814e..a647c47 100644
--- a/src/fnctdsk.c
+++ b/src/fnctdsk.c
@@ -395,7 +395,7 @@ unsigned int get_geometry_from_list_part(const disk_t *disk_car, const list_part
return heads_per_cylinder;
}
-const char *size_to_unit(uint64_t disk_size, char *buffer)
+void size_to_unit(const uint64_t disk_size, char *buffer)
{
if(disk_size<(uint64_t)10*1024)
sprintf(buffer,"%u B", (unsigned)disk_size);
@@ -407,5 +407,4 @@ const char *size_to_unit(uint64_t disk_size, char *buffer)
sprintf(buffer,"%u GB / %u GiB", (unsigned)(disk_size/1000/1000/1000), (unsigned)(disk_size/1024/1024/1024));
else
sprintf(buffer,"%u TB / %u TiB", (unsigned)(disk_size/1000/1000/1000/1000), (unsigned)(disk_size/1024/1024/1024/1024));
- return buffer;
}
diff --git a/src/fnctdsk.h b/src/fnctdsk.h
index 8f6569f..79cedb4 100644
--- a/src/fnctdsk.h
+++ b/src/fnctdsk.h
@@ -40,7 +40,7 @@ void partition_reset(partition_t *partition, const arch_fnct_t *arch);
partition_t *partition_new(const arch_fnct_t *arch);
unsigned int get_geometry_from_list_part(const disk_t *disk_car, const list_part_t *list_part, const int verbose);
int delete_list_disk(list_disk_t *list_disk);
-const char *size_to_unit(uint64_t disk_size, char *buffer);
+void size_to_unit(const uint64_t disk_size, char *buffer);
int is_part_overlapping(const list_part_t *list_part);
void dup_partition_t(partition_t *dest, const partition_t *src);
diff --git a/src/godmode.c b/src/godmode.c
index 28ae96c..6da0446 100644
--- a/src/godmode.c
+++ b/src/godmode.c
@@ -138,8 +138,10 @@ static int interface_part_bad_ncurses(disk_t *disk_car, list_part_t *list_part)
{
char buffer_disk_size[100];
char buffer_disk_size_found[100];
+ size_to_unit(disk_car->disk_size, buffer_disk_size);
+ size_to_unit(disk_size, buffer_disk_size_found);
wprintw(stdscr,"The harddisk (%s) seems too small! (< %s)",
- size_to_unit(disk_car->disk_size,buffer_disk_size), size_to_unit(disk_size,buffer_disk_size_found));
+ buffer_disk_size, buffer_disk_size_found);
}
wmove(stdscr,7,0);
wprintw(stdscr,"Check the harddisk size: HD jumpers settings, BIOS detection...");
@@ -185,7 +187,8 @@ static int interface_part_bad_ncurses(disk_t *disk_car, list_part_t *list_part)
{
wprintw(stdscr,"%s, ",parts->part->info);
}
- wprintw(stdscr,"%s",size_to_unit(parts->part->part_size,buffer_part_size));
+ size_to_unit(parts->part->part_size, buffer_part_size);
+ wprintw(stdscr,"%s", buffer_part_size);
} else
{
waddstr(stdscr, " ");
@@ -270,8 +273,10 @@ static int interface_part_bad_log(disk_t *disk_car, list_part_t *list_part)
{
char buffer_disk_size[100];
char buffer_disk_size_found[100];
+ size_to_unit(disk_car->disk_size, buffer_disk_size);
+ size_to_unit(disk_size, buffer_disk_size_found);
log_warning("The harddisk (%s) seems too small! (< %s)\n",
- size_to_unit(disk_car->disk_size,buffer_disk_size), size_to_unit(disk_size,buffer_disk_size_found));
+ buffer_disk_size, buffer_disk_size_found);
}
if(list_part->next==NULL)
{
diff --git a/src/hdaccess.c b/src/hdaccess.c
index e1d2538..1f1df3b 100644
--- a/src/hdaccess.c
+++ b/src/hdaccess.c
@@ -1059,8 +1059,9 @@ 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];
+ size_to_unit(disk_car->disk_size, buffer_disk_size);
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->device, 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)"));
return disk_car->description_txt;
@@ -1070,13 +1071,14 @@ static const char *file_description_short(disk_t *disk_car)
{
const struct info_file_struct *data=(const struct info_file_struct *)disk_car->data;
char buffer_disk_size[100];
+ size_to_unit(disk_car->disk_size, buffer_disk_size);
if(disk_car->model==NULL)
snprintf(disk_car->description_short_txt, sizeof(disk_car->description_txt),"Disk %s - %s%s",
- disk_car->device, size_to_unit(disk_car->disk_size,buffer_disk_size),
+ disk_car->device, buffer_disk_size,
((data->mode&O_RDWR)==O_RDWR?"":" (RO)"));
else
snprintf(disk_car->description_short_txt, sizeof(disk_car->description_txt),"Disk %s - %s%s - %s",
- disk_car->device, size_to_unit(disk_car->disk_size,buffer_disk_size),
+ disk_car->device, buffer_disk_size,
((data->mode&O_RDWR)==O_RDWR?"":" (RO)"),
disk_car->model);
return disk_car->description_short_txt;
diff --git a/src/intrface.c b/src/intrface.c
index b0312c1..d593b9c 100644
--- a/src/intrface.c
+++ b/src/intrface.c
@@ -152,7 +152,8 @@ static list_part_t *ask_structure_ncurses(disk_t *disk_car,list_part_t *list_par
{
wprintw(stdscr,"%s, ",parts->part->info);
}
- wprintw(stdscr,"%s",size_to_unit(parts->part->part_size,buffer_part_size));
+ size_to_unit(parts->part->part_size, buffer_part_size);
+ wprintw(stdscr,"%s", buffer_part_size);
}
}
if(structure_status==0)
diff --git a/src/log_part.c b/src/log_part.c
index 5d4f9a1..5efd7de 100644
--- a/src/log_part.c
+++ b/src/log_part.c
@@ -37,7 +37,8 @@ void log_partition(const disk_t *disk_car, const partition_t *partition)
char buffer_part_size[100];
msg=aff_part_aux(AFF_PART_ORDER|AFF_PART_STATUS, disk_car, partition);
log_info("%s",msg);
+ size_to_unit(partition->part_size, buffer_part_size);
if(partition->info[0]!='\0')
- log_info("\n %s, %s",partition->info,size_to_unit(partition->part_size,buffer_part_size));
+ log_info("\n %s, %s", partition->info, buffer_part_size);
log_info("\n");
}
diff --git a/src/msdos.c b/src/msdos.c
index 06cca88..16d1e63 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -432,8 +432,9 @@ const char *disk_description(disk_t *disk_car)
{
struct info_disk_struct*data=disk_car->data;
char buffer_disk_size[100];
+ size_to_unit(disk_car->disk_size, buffer_disk_size),
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),
+ data->disk, 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)":"");
return disk_car->description_txt;
@@ -443,8 +444,9 @@ static const char *disk_description_short(disk_t *disk_car)
{
struct info_disk_struct*data=disk_car->data;
char buffer_disk_size[100];
+ size_to_unit(disk_car->disk_size, buffer_disk_size);
snprintf(disk_car->description_short_txt, sizeof(disk_car->description_txt),"Disk %2x - %s",
- data->disk, size_to_unit(disk_car->disk_size,buffer_disk_size));
+ data->disk, buffer_disk_size);
return disk_car->description_short_txt;
}
diff --git a/src/win32.c b/src/win32.c
index 6c1c109..6ad7696 100644
--- a/src/win32.c
+++ b/src/win32.c
@@ -345,14 +345,15 @@ static const char *file_win32_description(disk_t *disk_car)
{
struct info_file_win32_struct *data=disk_car->data;
char buffer_disk_size[100];
+ size_to_unit(disk_car->disk_size, buffer_disk_size);
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 %lu %u %u%s",
- disk_car->device[4], size_to_unit(disk_car->disk_size,buffer_disk_size),
+ disk_car->device[4], 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 %lu %u %u%s",
- disk_car->device, size_to_unit(disk_car->disk_size,buffer_disk_size),
+ disk_car->device, 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)"));
return disk_car->description_txt;
@@ -362,17 +363,18 @@ static const char *file_win32_description_short(disk_t *disk_car)
{
struct info_file_win32_struct *data=disk_car->data;
char buffer_disk_size[100];
+ size_to_unit(disk_car->disk_size, buffer_disk_size);
if(disk_car->device[0]=='\\' && disk_car->device[1]=='\\' && disk_car->device[2]=='.' && disk_car->device[3]=='\\' && disk_car->device[5]==':')
{
if(disk_car->model==NULL)
snprintf(disk_car->description_short_txt,
sizeof(disk_car->description_txt), "Drive %c: - %s%s",
- disk_car->device[4], size_to_unit(disk_car->disk_size,buffer_disk_size),
+ disk_car->device[4], buffer_disk_size,
((data->mode&FILE_WRITE_DATA)==FILE_WRITE_DATA?"":" (RO)"));
else
snprintf(disk_car->description_short_txt,
sizeof(disk_car->description_txt), "Drive %c: - %s%s - %s",
- disk_car->device[4], size_to_unit(disk_car->disk_size,buffer_disk_size),
+ disk_car->device[4], buffer_disk_size,
((data->mode&FILE_WRITE_DATA)==FILE_WRITE_DATA?"":" (RO)"),
disk_car->model);
}
@@ -381,12 +383,12 @@ static const char *file_win32_description_short(disk_t *disk_car)
if(disk_car->model==NULL)
snprintf(disk_car->description_short_txt,
sizeof(disk_car->description_txt), "Disk %s - %s%s",
- disk_car->device, size_to_unit(disk_car->disk_size,buffer_disk_size),
+ disk_car->device, buffer_disk_size,
((data->mode&FILE_WRITE_DATA)==FILE_WRITE_DATA?"":" (RO)"));
else
snprintf(disk_car->description_short_txt,
sizeof(disk_car->description_txt), "Disk %s - %s%s - %s",
- disk_car->device, size_to_unit(disk_car->disk_size,buffer_disk_size),
+ disk_car->device, buffer_disk_size,
((data->mode&FILE_WRITE_DATA)==FILE_WRITE_DATA?"":" (RO)"),
disk_car->model);
}