From 2aa0acbdec2f9ad63f612a5ac6a5e644e45a63ed Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Thu, 28 Feb 2008 13:36:23 +0100 Subject: [PATCH] Remove the possibility to add a partition for non-partionned disk --- src/adv.c | 1 + src/intrface.c | 47 ++++++++++++++++++++++++++++------------------- src/partnone.c | 7 +------ 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/adv.c b/src/adv.c index a4c0823f..d99f246b 100644 --- a/src/adv.c +++ b/src/adv.c @@ -364,6 +364,7 @@ void interface_adv(disk_t *disk_car, const int verbose,const int dump_ind, const break; case 'a': case 'A': + if(disk_car->arch->add_partition!=NULL) { list_part=disk_car->arch->add_partition(disk_car,list_part, verbose, current_cmd); current_element=list_part; diff --git a/src/intrface.c b/src/intrface.c index 63082d90..29044f1a 100644 --- a/src/intrface.c +++ b/src/intrface.c @@ -744,7 +744,9 @@ static list_part_t *interface_analyse_ncurses(disk_t *disk_car, const int verbos { log_flush(); #ifdef HAVE_NCURSES - command=screen_buffer_display(stdscr,(list_part!=NULL?"QB":"Q"),menuAnalyse); + command=screen_buffer_display(stdscr, + (list_part!=NULL && disk_car->arch->add_partition!=NULL?"QB":"Q"), + menuAnalyse); #endif } if(command=='B') @@ -1084,19 +1086,22 @@ static list_part_t *ask_structure_ncurses(disk_t *disk_car,list_part_t *list_par wmove(stdscr,22,0); wclrtoeol(stdscr); /* before addstr for BSD compatibility */ waddstr(stdscr,"Keys "); - if(has_colors()) - wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); - waddstr(stdscr,"A"); - if(has_colors()) - wbkgdset(stdscr,' ' | COLOR_PAIR(0)); - waddstr(stdscr,": add partition, "); - if(has_colors()) - wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); - waddstr(stdscr,"L"); - if(has_colors()) - wbkgdset(stdscr,' ' | COLOR_PAIR(0)); - waddstr(stdscr,": load backup, "); - + /* If the disk can't be partionned, there is no partition to add and no partition to save */ + if(disk_car->arch->add_partition!=NULL) + { + if(has_colors()) + wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); + waddstr(stdscr,"A"); + if(has_colors()) + wbkgdset(stdscr,' ' | COLOR_PAIR(0)); + waddstr(stdscr,": add partition, "); + if(has_colors()) + wbkgdset(stdscr,' ' | A_BOLD | COLOR_PAIR(0)); + waddstr(stdscr,"L"); + if(has_colors()) + wbkgdset(stdscr,' ' | COLOR_PAIR(0)); + waddstr(stdscr,": load backup, "); + } if(list_part==NULL) { waddstr(stdscr,"Enter: to continue"); @@ -1215,6 +1220,7 @@ static list_part_t *ask_structure_ncurses(disk_t *disk_car,list_part_t *list_par break; case 'a': case 'A': + if(disk_car->arch->add_partition!=NULL) { list_part=disk_car->arch->add_partition(disk_car,list_part, verbose, current_cmd); rewrite=1; @@ -1252,11 +1258,14 @@ static list_part_t *ask_structure_ncurses(disk_t *disk_car,list_part_t *list_par break; case 'l': case 'L': - list_part=interface_load(disk_car,list_part,verbose); - rewrite=1; - offset=0; - pos_num=0; - pos=list_part; + if(disk_car->arch->add_partition!=NULL) + { + list_part=interface_load(disk_car,list_part,verbose); + rewrite=1; + offset=0; + pos_num=0; + pos=list_part; + } break; case 'q': case '\r': diff --git a/src/partnone.c b/src/partnone.c index cfec3789..1a9a97f2 100644 --- a/src/partnone.c +++ b/src/partnone.c @@ -68,7 +68,6 @@ static int check_part_none(disk_t *disk_car, const int verbose,partition_t *part static int get_geometry_from_nonembr(const unsigned char *buffer, const int verbose, CHS_t *geometry); static list_part_t *read_part_none(disk_t *disk_car, const int verbose, const int saveheader); static list_part_t *init_part_order_none(const disk_t *disk_car, list_part_t *list_part); -static list_part_t *add_partition_none(disk_t *disk_car,list_part_t *list_part, const int verbose, char **current_cmd); static void set_next_status_none(const disk_t *disk_car, partition_t *partition); static int test_structure_none(list_part_t *list_part); static int is_part_known_none(const partition_t *partition); @@ -128,7 +127,7 @@ arch_fnct_t arch_none= .get_geometry_from_mbr=get_geometry_from_nonembr, .check_part=check_part_none, .write_MBR_code=NULL, - .add_partition=add_partition_none, + .add_partition=NULL, .set_prev_status=set_next_status_none, .set_next_status=set_next_status_none, .test_structure=test_structure_none, @@ -211,10 +210,6 @@ static list_part_t *init_part_order_none(const disk_t *disk_car, list_part_t *li return list_part; } -static list_part_t *add_partition_none(disk_t *disk_car,list_part_t *list_part, const int verbose, char **current_cmd) -{ - return list_part; -} static void set_next_status_none(const disk_t *disk_car, partition_t *partition) {