Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/gpt Add gpt_change_hdr() similar to gpt_change_ent() fo...
details: https://anonhg.NetBSD.org/src/rev/a5b18af0e5f2
branches: trunk
changeset: 457434:a5b18af0e5f2
user: jnemeth <jnemeth%NetBSD.org@localhost>
date: Tue Jun 25 03:42:45 2019 +0000
description:
Add gpt_change_hdr() similar to gpt_change_ent() for changing
arbitrary header fields.
diffstat:
sbin/gpt/gpt.c | 29 ++++++++++++++++++++++++++++-
sbin/gpt/gpt.h | 2 ++
2 files changed, 30 insertions(+), 1 deletions(-)
diffs (58 lines):
diff -r 6bf8578c4dde -r a5b18af0e5f2 sbin/gpt/gpt.c
--- a/sbin/gpt/gpt.c Tue Jun 25 03:41:05 2019 +0000
+++ b/sbin/gpt/gpt.c Tue Jun 25 03:42:45 2019 +0000
@@ -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 @@
}
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) {
diff -r 6bf8578c4dde -r a5b18af0e5f2 sbin/gpt/gpt.h
--- a/sbin/gpt/gpt.h Tue Jun 25 03:41:05 2019 +0000
+++ b/sbin/gpt/gpt.h Tue Jun 25 03:42:45 2019 +0000
@@ -116,6 +116,8 @@
};
int gpt_change_ent(gpt_t, const struct gpt_find *,
void (*)(struct gpt_ent *, void *, int), void *);
+int gpt_change_hdr(gpt_t, const struct gpt_find *,
+ void (*)(struct gpt_hdr *, void *, int), void *);
int gpt_add_find(gpt_t, struct gpt_find *, int);
#define GPT_AIS "a:i:s:"
Home |
Main Index |
Thread Index |
Old Index