From b492189d95a523e9176c1dac4de0fb1216a3af14 Mon Sep 17 00:00:00 2001 From: Dan Horak Date: Sat, 19 Jul 2008 16:32:00 +0200 Subject: [PATCH] s390-tools-1.5.0-fdasd-raid --- fdasd/fdasd.c | 55 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 45 insertions(+), 10 deletions(-) diff --git a/fdasd/fdasd.c b/fdasd/fdasd.c index dce9ed3..d011b69 100644 --- a/fdasd/fdasd.c +++ b/fdasd/fdasd.c @@ -214,10 +214,10 @@ fdasd_error(fdasd_anchor_t *anc, enum fdasd_failure why, char *str) static int read_line(void) { - bzero(line_buffer, LINE_LENGTH); line_ptr = line_buffer; if (!fgets(line_buffer, LINE_LENGTH, stdin)) return 0; + line_buffer[LINE_LENGTH-1] = 0; while (*line_ptr && !isgraph(*line_ptr)) line_ptr++; return *line_ptr; @@ -278,6 +278,8 @@ fdasd_partition_type (char *str) strcpy(str, "Linux native"); else if (strncmp("SWAP ", str, 6) == 0) strcpy(str, "Linux swap"); + else if (strncmp("RAID ", str, 6) == 0) + strcpy(str, "Linux Raid"); else strcpy(str, "unknown"); @@ -1062,6 +1064,7 @@ fdasd_write_vtoc_labels (fdasd_anchor_t *anc) strncpy(c1, s2, 31); } else { + char str[20]; char *tmp = strstr(ch, "SWAP"); /* create a new data set name */ @@ -1069,7 +1072,15 @@ fdasd_write_vtoc_labels (fdasd_anchor_t *anc) k++; setpos(anc, k, i-1); - + + strncpy(s2, ch, 44); + s2[44]=0; + vtoc_ebcdic_dec(s2, s2, 44); + c2 = strstr(s2, "PART"); + if (c2 != NULL) strncpy(str, c2+=9, 6); + str[6] = '\0'; + fdasd_partition_type(str); + strncpy(ch, "LINUX.V " " ", 44); @@ -1087,8 +1098,16 @@ fdasd_write_vtoc_labels (fdasd_anchor_t *anc) c1 += 4; if (tmp) strncpy(c1, ".SWAP", 5); - else - strncpy(c1, ".NATIVE", 7); + else { + if (strcmp("unknown", str) == 0) { + strncpy(c1, ".NATIVE", 7); + } + else { + strncpy(c1, ".", 1); + strncpy(c1+1, c2, 6); + } + } + } vtoc_ebcdic_enc(ch, ch, 44); if (anc->verbose) printf("f1 "); @@ -1325,9 +1344,10 @@ fdasd_change_part_type (fdasd_anchor_t *anc) printf("current partition type is: %s\n\n", fdasd_partition_type(str)); printf(" 1 Linux native\n" \ - " 2 Linux swap\n\n"); + " 2 Linux swap\n" \ + " 3 Linux raid\n\n"); part_type = 0; - while ((part_type < 1) || (part_type > 2)) { + while ((part_type < 1) || (part_type > 3)) { while (!isdigit(part_type = read_char("new partition type: "))); part_type -= 48; @@ -1340,6 +1360,9 @@ fdasd_change_part_type (fdasd_anchor_t *anc) case 2: strncpy(str, "SWAP ", 6); break; + case 3: + strncpy(str, "RAID ", 6); + break; default: printf("'%d' is not supported!\n", part_type); } @@ -1503,7 +1526,7 @@ fdasd_process_invalid_vtoc(fdasd_anchor_t *anc) static void fdasd_process_valid_vtoc(fdasd_anchor_t *anc, unsigned long blk) { - int f1_counter = 0, f7_counter = 0, f5_counter = 0; + int f1_counter = 0, f7_counter = 0, f5_counter = 0, oldfmt = 0; int i, part_no, f1_size = sizeof(format1_label_t); partition_info_t *part_info = anc->first; format1_label_t f1_label; @@ -1538,14 +1561,26 @@ fdasd_process_valid_vtoc(fdasd_anchor_t *anc, unsigned long blk) vtoc_ebcdic_enc(part_info->f1->DS1DSNAM, part_info->f1->DS1DSNAM, 44); - if ((part_no < 0) || (part_no >= USABLE_PARTITIONS)) + /* this dasd has data set names 0000-0002 + but we use now 0001-0003 */ + if (part_no == -1) + oldfmt++; + + if (((oldfmt == 0) && (part_no < 0)) + || (part_no >= USABLE_PARTITIONS)) printf("WARNING: partition number (%i) found " "in data set name of an existing " "partition\ndoes not match range of " "possible partition numbers (1-%d)\n\n", part_no + 1, USABLE_PARTITIONS); - else - setpos(anc, part_no, f1_counter); + else { + if (oldfmt) /* correct +1 */ { + setpos(anc, part_no+1, f1_counter); + printf("Correcting f1 header number!\n"); + } + else + setpos(anc, part_no, f1_counter); + } part_info = part_info->next; f1_counter++; -- 1.6.0.6