Slightly improved error handling when converion from one partition table

format to another is not lossless.
This commit is contained in:
martin 2022-06-11 18:30:02 +00:00
parent d5590295ea
commit 74e9a67aa7
6 changed files with 31 additions and 14 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: disks.c,v 1.82 2022/06/09 18:26:06 martin Exp $ */
/* $NetBSD: disks.c,v 1.83 2022/06/11 18:30:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -779,12 +779,13 @@ delete_scheme(struct pm_devs *p)
}
static void
static bool
convert_copy(struct disk_partitions *old_parts,
struct disk_partitions *new_parts)
{
struct disk_part_info oinfo, ninfo;
part_id i;
bool err = false;
for (i = 0; i < old_parts->num_part; i++) {
if (!old_parts->pscheme->get_part_info(old_parts, i, &oinfo))
@ -799,17 +800,23 @@ convert_copy(struct disk_partitions *old_parts,
old_parts->pscheme->
secondary_partitions(
old_parts, oinfo.start, false);
if (sec_part)
convert_copy(sec_part, new_parts);
if (sec_part && !convert_copy(sec_part,
new_parts))
err = true;
}
continue;
}
if (!new_parts->pscheme->adapt_foreign_part_info(new_parts,
&ninfo, old_parts->pscheme, &oinfo))
&ninfo, old_parts->pscheme, &oinfo)) {
err = true;
continue;
new_parts->pscheme->add_partition(new_parts, &ninfo, NULL);
}
if (!new_parts->pscheme->add_partition(new_parts, &ninfo,
NULL))
err = true;
}
return !err;
}
bool
@ -838,10 +845,10 @@ convert_scheme(struct pm_devs *p, bool is_boot_drive, const char **err_msg)
return false;
}
convert_copy(old_parts, new_parts);
if (new_parts->num_part == 0 && old_parts->num_part != 0) {
if (!convert_copy(old_parts, new_parts)) {
/* need to cleanup */
if (err_msg)
*err_msg = MSG_cvtscheme_error;
new_parts->pscheme->free(new_parts);
return false;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.de,v 1.39 2022/06/09 18:26:06 martin Exp $ */
/* $NetBSD: msg.mi.de,v 1.40 2022/06/11 18:30:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -305,6 +305,8 @@ message cvtscheme_keep {beibehalten (nur einen Teil benutzen)}
message cvtscheme_delete {löschen (alle Daten gehen verloren!)}
message cvtscheme_convert {in ein anderes Schema konvertieren}
message cvtscheme_abort {abbrechen}
message cvtscheme_error
{Nicht alle Partitionen konnten übernommen werden}
/* Called with: Example
* $0 = device name wd0

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.en,v 1.42 2022/06/09 18:26:06 martin Exp $ */
/* $NetBSD: msg.mi.en,v 1.43 2022/06/11 18:30:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -292,6 +292,8 @@ message cvtscheme_keep {keep (use only part of disk)}
message cvtscheme_delete {delete (all data will be lost!)}
message cvtscheme_convert {convert to another partitioning method}
message cvtscheme_abort {abort}
message cvtscheme_error
{Could not convert all partitions}
/* Called with: Example
* $0 = device name wd0

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.es,v 1.35 2022/06/09 18:26:06 martin Exp $ */
/* $NetBSD: msg.mi.es,v 1.36 2022/06/11 18:30:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -299,6 +299,8 @@ message cvtscheme_keep {keep (use only part of disk)}
message cvtscheme_delete {delete (all data will be lost!)}
message cvtscheme_convert {convert to another partitioning method}
message cvtscheme_abort {abort}
message cvtscheme_error
{Could not convert all partitions}
/* Called with: Example
* $0 = device name wd0

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.fr,v 1.40 2022/06/09 18:26:06 martin Exp $ */
/* $NetBSD: msg.mi.fr,v 1.41 2022/06/11 18:30:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -303,6 +303,8 @@ message cvtscheme_keep {keep (use only part of disk)}
message cvtscheme_delete {delete (all data will be lost!)}
message cvtscheme_convert {convert to another partitioning method}
message cvtscheme_abort {abort}
message cvtscheme_error
{Could not convert all partitions}
/* Called with: Example
* $0 = device name wd0

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.pl,v 1.41 2022/06/09 18:26:06 martin Exp $ */
/* $NetBSD: msg.mi.pl,v 1.42 2022/06/11 18:30:02 martin Exp $ */
/* Based on english version: */
/* NetBSD: msg.mi.pl,v 1.36 2004/04/17 18:55:35 atatat Exp */
@ -286,6 +286,8 @@ message cvtscheme_keep {zostaw (uzyj tylko czesci dysku)}
message cvtscheme_delete {skasuj (wszystkie dane beda utracone!)}
message cvtscheme_convert {uzyj innego typu tablicy partycji}
message cvtscheme_abort {anuluj}
message cvtscheme_error
{Could not convert all partitions}
/* Called with: Example
* $0 = device name wd0