Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/gpt Instruct user to use resizedisk if media size has c...
details: https://anonhg.NetBSD.org/src/rev/f695f8ba7a66
branches: trunk
changeset: 338938:f695f8ba7a66
user: jnemeth <jnemeth%NetBSD.org@localhost>
date: Thu Jun 18 01:37:23 2015 +0000
description:
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.
diffstat:
sbin/gpt/recover.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diffs (35 lines):
diff -r cde5cf017e28 -r f695f8ba7a66 sbin/gpt/recover.c
--- a/sbin/gpt/recover.c Wed Jun 17 17:43:23 2015 +0000
+++ b/sbin/gpt/recover.c Thu Jun 18 01:37:23 2015 +0000
@@ -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 @@
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 @@
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);
Home |
Main Index |
Thread Index |
Old Index