Module Name: src Committed By: jnemeth Date: Thu Jun 18 01:37:23 UTC 2015
Modified Files: src/sbin/gpt: recover.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sbin/gpt/recover.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/gpt/recover.c diff -u src/sbin/gpt/recover.c:1.5 src/sbin/gpt/recover.c:1.6 --- src/sbin/gpt/recover.c:1.5 Mon Sep 29 20:28:57 2014 +++ src/sbin/gpt/recover.c Thu Jun 18 01:37:23 2015 @@ -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.5 2014/09/29 20:28:57 christos Exp $"); +__RCSID("$NetBSD: recover.c,v 1.6 2015/06/18 01:37:23 jnemeth 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);