Pull up following revision(s) (requested by jnemeth in ticket #847):
sbin/gpt/recover.c: revision 1.6 Instruct user to use resizedisk if media size has changed, as resizedisk will adjust the media size in the headers, whereas recover simply copies the existing header over the missing one. XXX recover and resizedisk should probably be merged (even if just partially, so that recover can properly handle media size changes). Also, reading in the GPT should probably be centralised so that error handling can be centralised, and users aren't given misleading messages (i.e. they aren't told to run recover when they should be running resizedisk). However, something that can be quickly pulled up to netbsd-7 was needed, and there isn't time for a major overhaul or rewrite.
This commit is contained in:
parent
4c2ee506fa
commit
0015a1119e
|
@ -33,7 +33,7 @@
|
|||
__FBSDID("$FreeBSD: src/sbin/gpt/recover.c,v 1.8 2005/08/31 01:47:19 marcel Exp $");
|
||||
#endif
|
||||
#ifdef __RCSID
|
||||
__RCSID("$NetBSD: recover.c,v 1.4.20.1 2015/06/02 19:49:38 snj Exp $");
|
||||
__RCSID("$NetBSD: recover.c,v 1.4.20.2 2015/06/29 17:24:28 snj Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -64,7 +64,7 @@ usage_recover(void)
|
|||
static void
|
||||
recover(int fd)
|
||||
{
|
||||
off_t last;
|
||||
uint64_t last;
|
||||
map_t *gpt, *tpg;
|
||||
map_t *tbl, *lbt;
|
||||
struct gpt_hdr *hdr;
|
||||
|
@ -92,6 +92,13 @@ recover(int fd)
|
|||
|
||||
last = mediasz / secsz - 1LL;
|
||||
|
||||
if (gpt != NULL &&
|
||||
((struct gpt_hdr *)(gpt->map_data))->hdr_lba_alt != last) {
|
||||
warnx("%s: media size has changed, please use 'gpt resizedisk'",
|
||||
device_name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (tbl != NULL && lbt == NULL) {
|
||||
lbt = map_add(last - tbl->map_size, tbl->map_size,
|
||||
MAP_TYPE_SEC_GPT_TBL, tbl->map_data);
|
||||
|
|
Loading…
Reference in New Issue