Module Name: src
Committed By: jnemeth
Date: Tue Jun 25 03:50:18 UTC 2019
Modified Files:
src/sbin/gpt: gpt.c
Log Message:
Add gpt_change_hdr() similar to gpt_change_ent() for changing
arbitrary header fields.
To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sbin/gpt/gpt.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/gpt.c
diff -u src/sbin/gpt/gpt.c:1.79 src/sbin/gpt/gpt.c:1.80
--- src/sbin/gpt/gpt.c:1.79 Fri Jun 21 02:14:59 2019
+++ src/sbin/gpt/gpt.c Tue Jun 25 03:50:18 2019
@@ -35,7 +35,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $");
#endif
#ifdef __RCSID
-__RCSID("$NetBSD: gpt.c,v 1.79 2019/06/21 02:14:59 jnemeth Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.80 2019/06/25 03:50:18 jnemeth Exp $");
#endif
#include <sys/param.h>
@@ -1076,6 +1076,33 @@ gpt_change_ent(gpt_t gpt, const struct g
}
int
+gpt_change_hdr(gpt_t gpt, const struct gpt_find *find,
+ void (*cfn)(struct gpt_hdr *, void *, int), void *v)
+{
+ struct gpt_hdr *hdr;
+
+ if ((hdr = gpt_hdr(gpt)) == NULL)
+ return -1;
+
+ /* Change the primary header. */
+ (*cfn)(hdr, v, 0);
+
+ if (gpt_write_primary(gpt) == -1)
+ return -1;
+
+ hdr = gpt->tpg->map_data;
+ /* Change the secondary header. */
+ (*cfn)(hdr, v, 1);
+
+ if (gpt_write_backup(gpt) == -1)
+ return -1;
+
+ gpt_msg(gpt, "Header %s", find->msg);
+
+ return 0;
+}
+
+int
gpt_add_ais(gpt_t gpt, off_t *alignment, u_int *entry, off_t *size, int ch)
{
switch (ch) {