new constant SINGLE_PARTITION_TYPE to improve code testing
This commit is contained in:
parent
1c05a14387
commit
1c09ffcb6f
11 changed files with 98 additions and 16 deletions
|
@ -25,6 +25,7 @@
|
|||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "types.h"
|
||||
#include "common.h"
|
||||
#include "parti386.h"
|
||||
|
@ -35,28 +36,52 @@
|
|||
#include "partxbox.h"
|
||||
#include "addpart.h"
|
||||
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_GPT)
|
||||
extern const arch_fnct_t arch_gpt;
|
||||
extern const arch_fnct_t arch_i386;
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_HUMAX)
|
||||
extern const arch_fnct_t arch_humax;
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_I386)
|
||||
extern const arch_fnct_t arch_i386;
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_MAC)
|
||||
extern const arch_fnct_t arch_mac;
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_SUN)
|
||||
extern const arch_fnct_t arch_sun;
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_XBOX)
|
||||
extern const arch_fnct_t arch_xbox;
|
||||
#endif
|
||||
|
||||
list_part_t *add_partition_cli(disk_t *disk, list_part_t *list_part, char **current_cmd)
|
||||
{
|
||||
if(*current_cmd==NULL)
|
||||
return list_part;
|
||||
assert(current_cmd!=NULL);
|
||||
/*@ assert valid_read_string(*current_cmd); */
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_GPT)
|
||||
if(disk->arch==&arch_gpt)
|
||||
return add_partition_gpt_cli(disk, list_part, current_cmd);
|
||||
else if(disk->arch==&arch_i386)
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_I386)
|
||||
if(disk->arch==&arch_i386)
|
||||
return add_partition_i386_cli(disk, list_part, current_cmd);
|
||||
else if(disk->arch==&arch_humax)
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_HUMAX)
|
||||
if(disk->arch==&arch_humax)
|
||||
return add_partition_humax_cli(disk, list_part, current_cmd);
|
||||
else if(disk->arch==&arch_mac)
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_MAC)
|
||||
if(disk->arch==&arch_mac)
|
||||
return add_partition_mac_cli(disk, list_part, current_cmd);
|
||||
else if(disk->arch==&arch_sun)
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_SUN)
|
||||
if(disk->arch==&arch_sun)
|
||||
return add_partition_sun_cli(disk, list_part, current_cmd);
|
||||
else if(disk->arch==&arch_xbox)
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_XBOX)
|
||||
if(disk->arch==&arch_xbox)
|
||||
return add_partition_xbox_cli(disk, list_part, current_cmd);
|
||||
#endif
|
||||
return list_part;
|
||||
}
|
||||
|
|
|
@ -27,18 +27,30 @@
|
|||
#include "common.h"
|
||||
#include "autoset.h"
|
||||
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_GPT)
|
||||
extern const arch_fnct_t arch_gpt;
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_HUMAX)
|
||||
extern const arch_fnct_t arch_humax;
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_MAC)
|
||||
extern const arch_fnct_t arch_mac;
|
||||
#endif
|
||||
|
||||
void autoset_unit(disk_t *disk)
|
||||
{
|
||||
if(disk==NULL)
|
||||
return ;
|
||||
if(
|
||||
disk->arch==&arch_mac ||
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_GPT)
|
||||
disk->arch==&arch_gpt ||
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_HUMAX)
|
||||
disk->arch==&arch_humax ||
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_MAC)
|
||||
disk->arch==&arch_mac ||
|
||||
#endif
|
||||
(disk->geom.heads_per_cylinder==1 && disk->geom.sectors_per_head==1))
|
||||
disk->unit=UNIT_SECTOR;
|
||||
else
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
*/
|
||||
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_I386)
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
@ -35,4 +36,4 @@ int write_part_gpt(disk_t *disk_car, const list_part_t *list_part, const int ro,
|
|||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
*/
|
||||
|
||||
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_GPT)
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
@ -310,3 +310,4 @@ int write_part_gpt(disk_t *disk_car, const list_part_t *list_part, const int ro,
|
|||
disk_car->sync(disk_car);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
*/
|
||||
|
||||
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_HUMAX)
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
@ -362,3 +362,4 @@ static const char *get_partition_typename_humax(const partition_t *partition)
|
|||
{
|
||||
return "Partition";
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -24,9 +24,20 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_HUMAX)
|
||||
/*@
|
||||
@ requires valid_disk(disk_car);
|
||||
@ requires \valid_read(disk_car);
|
||||
@ requires valid_list_part(list_part);
|
||||
@ requires \valid(current_cmd);
|
||||
@ requires separation: \separated(disk_car, list_part, current_cmd, *current_cmd);
|
||||
@ requires valid_read_string(*current_cmd);
|
||||
@*/
|
||||
// ensures valid_list_part(\result);
|
||||
// ensures valid_read_string(*current_cmd);
|
||||
list_part_t *add_partition_humax_cli(const disk_t *disk_car,list_part_t *list_part, char **current_cmd);
|
||||
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
} /* closing brace for extern "C" */
|
||||
#endif
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
*/
|
||||
#ifndef _PARTI386_H
|
||||
#define _PARTI386_H
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_I386)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -56,3 +57,4 @@ int recover_i386_logical(disk_t *disk, const unsigned char *buffer, partition_t
|
|||
} /* closing brace for extern "C" */
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -24,9 +24,21 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_SUN)
|
||||
|
||||
/*@
|
||||
@ requires valid_disk(disk_car);
|
||||
@ requires \valid_read(disk_car);
|
||||
@ requires valid_list_part(list_part);
|
||||
@ requires \valid(current_cmd);
|
||||
@ requires separation: \separated(disk_car, list_part, current_cmd, *current_cmd);
|
||||
@ requires valid_read_string(*current_cmd);
|
||||
@*/
|
||||
// ensures valid_list_part(\result);
|
||||
// ensures valid_read_string(*current_cmd);
|
||||
list_part_t *add_partition_sun_cli(const disk_t *disk_car,list_part_t *list_part, char **current_cmd);
|
||||
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
} /* closing brace for extern "C" */
|
||||
#endif
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
*/
|
||||
|
||||
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_XBOX)
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
@ -389,3 +389,4 @@ static const char *get_partition_typename_xbox(const partition_t *partition)
|
|||
{
|
||||
return get_partition_typename_xbox_aux(partition->part_type_xbox);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_XBOX)
|
||||
|
||||
struct xbox_partition
|
||||
{
|
||||
|
@ -33,8 +34,19 @@ struct xbox_partition
|
|||
uint32_t bootnbr;
|
||||
} __attribute__ ((gcc_struct, __packed__));
|
||||
|
||||
/*@
|
||||
@ requires valid_disk(disk_car);
|
||||
@ requires \valid_read(disk_car);
|
||||
@ requires valid_list_part(list_part);
|
||||
@ requires \valid(current_cmd);
|
||||
@ requires separation: \separated(disk_car, list_part, current_cmd, *current_cmd);
|
||||
@ requires valid_read_string(*current_cmd);
|
||||
@*/
|
||||
// ensures valid_list_part(\result);
|
||||
// ensures valid_read_string(*current_cmd);
|
||||
list_part_t *add_partition_xbox_cli(const disk_t *disk_car,list_part_t *list_part, char **current_cmd);
|
||||
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
} /* closing brace for extern "C" */
|
||||
#endif
|
||||
|
|
|
@ -39,7 +39,9 @@
|
|||
#include "log_part.h"
|
||||
|
||||
#define SUN_LABEL_MAGIC 0xDABE
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_SUN)
|
||||
extern const arch_fnct_t arch_sun;
|
||||
#endif
|
||||
|
||||
static void set_sun_info_i386(partition_t *partition);
|
||||
static int test_sun_i386(const disk_t *disk_car, const sun_partition_i386 *sunlabel, const partition_t *partition, const int verbose);
|
||||
|
@ -73,6 +75,7 @@ static int test_sun_i386(const disk_t *disk_car, const sun_partition_i386 *sunla
|
|||
offset2cylinder(disk_car,partition->part_offset),
|
||||
offset2head(disk_car,partition->part_offset),
|
||||
offset2sector(disk_car,partition->part_offset));
|
||||
#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_SUN)
|
||||
{
|
||||
int i;
|
||||
partition_t *new_partition=partition_new(NULL);
|
||||
|
@ -93,6 +96,7 @@ static int test_sun_i386(const disk_t *disk_car, const sun_partition_i386 *sunla
|
|||
}
|
||||
free(new_partition);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue