Add a third argument to the "cfn" function that is an argument to

gpt_change_ent().  The purpose of the third argument is to specify
whether the entry to be changed is a primary GPT entry or a secondary
GPT entry.  It is assumed that a secondary GPT entry will always
follow a corresponding primary entry.

This is in preparation for an upcoming change that will require it.
This commit is contained in:
jnemeth 2019-06-21 02:14:59 +00:00
parent 7ab6c1dfd5
commit e003a26f4c
5 changed files with 11 additions and 11 deletions

View File

@ -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.78 2019/06/20 10:41:58 martin Exp $");
__RCSID("$NetBSD: gpt.c,v 1.79 2019/06/21 02:14:59 jnemeth Exp $");
#endif
#include <sys/param.h>
@ -1015,7 +1015,7 @@ gpt_add_find(gpt_t gpt, struct gpt_find *find, int ch)
int
gpt_change_ent(gpt_t gpt, const struct gpt_find *find,
void (*cfn)(struct gpt_ent *, void *), void *v)
void (*cfn)(struct gpt_ent *, void *, int), void *v)
{
map_t m;
struct gpt_hdr *hdr;
@ -1058,14 +1058,14 @@ gpt_change_ent(gpt_t gpt, const struct gpt_find *find,
continue;
/* Change the primary entry. */
(*cfn)(ent, v);
(*cfn)(ent, v, 0);
if (gpt_write_primary(gpt) == -1)
return -1;
ent = gpt_ent_backup(gpt, i);
/* Change the secondary entry. */
(*cfn)(ent, v);
(*cfn)(ent, v, 1);
if (gpt_write_backup(gpt) == -1)
return -1;

View File

@ -115,7 +115,7 @@ struct gpt_find {
const char *msg;
};
int gpt_change_ent(gpt_t, const struct gpt_find *,
void (*)(struct gpt_ent *, void *), void *);
void (*)(struct gpt_ent *, void *, int), void *);
int gpt_add_find(gpt_t, struct gpt_find *, int);
#define GPT_AIS "a:i:s:"

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/label.c,v 1.3 2006/10/04 18:20:25 marcel Exp $");
#endif
#ifdef __RCSID
__RCSID("$NetBSD: label.c,v 1.29 2018/07/03 03:41:24 jnemeth Exp $");
__RCSID("$NetBSD: label.c,v 1.30 2019/06/21 02:14:59 jnemeth Exp $");
#endif
#include <sys/types.h>
@ -68,7 +68,7 @@ struct gpt_cmd c_label = {
#define usage() gpt_usage(NULL, &c_label)
static void
change(struct gpt_ent *ent, void *v)
change(struct gpt_ent *ent, void *v, int backup)
{
uint8_t *name = v;
utf8_to_utf16(name, ent->ent_name, __arraycount(ent->ent_name));

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/remove.c,v 1.10 2006/10/04 18:20:25 marcel Exp $");
#endif
#ifdef __RCSID
__RCSID("$NetBSD: remove.c,v 1.22 2018/07/03 03:41:24 jnemeth Exp $");
__RCSID("$NetBSD: remove.c,v 1.23 2019/06/21 02:14:59 jnemeth Exp $");
#endif
#include <sys/types.h>
@ -66,7 +66,7 @@ struct gpt_cmd c_remove = {
#define usage() gpt_usage(NULL, &c_remove)
static void
change(struct gpt_ent *ent, void *v)
change(struct gpt_ent *ent, void *v, int backup)
{
/* Remove the primary entry by clearing the partition type. */
gpt_uuid_copy(ent->ent_type, gpt_uuid_nil);

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/remove.c,v 1.10 2006/10/04 18:20:25 marcel Exp $");
#endif
#ifdef __RCSID
__RCSID("$NetBSD: type.c,v 1.15 2018/07/03 03:41:24 jnemeth Exp $");
__RCSID("$NetBSD: type.c,v 1.16 2019/06/21 02:14:59 jnemeth Exp $");
#endif
#include <sys/types.h>
@ -67,7 +67,7 @@ struct gpt_cmd c_type = {
#define usage() gpt_usage(NULL, &c_type)
static void
change(struct gpt_ent *ent, void *v)
change(struct gpt_ent *ent, void *v, int backup)
{
gpt_uuid_t *newtype = v;
gpt_uuid_copy(ent->ent_type, *newtype);