Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/gpt - write a function to set the entity, so that we do...
details: https://anonhg.NetBSD.org/src/rev/b84c78018674
branches: trunk
changeset: 341996:b84c78018674
user: christos <christos%NetBSD.org@localhost>
date: Wed Dec 02 01:01:55 2015 +0000
description:
- write a function to set the entity, so that we don't reset to guid.
- entry 0 means create entry.
diffstat:
sbin/gpt/add.c | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
diffs (67 lines):
diff -r 953276a912ef -r b84c78018674 sbin/gpt/add.c
--- a/sbin/gpt/add.c Wed Dec 02 00:56:09 2015 +0000
+++ b/sbin/gpt/add.c Wed Dec 02 01:01:55 2015 +0000
@@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
#endif
#ifdef __RCSID
-__RCSID("$NetBSD: add.c,v 1.34 2015/12/01 23:29:07 christos Exp $");
+__RCSID("$NetBSD: add.c,v 1.35 2015/12/02 01:01:55 christos Exp $");
#endif
#include <sys/types.h>
@@ -71,12 +71,23 @@
#define usage() gpt_usage(NULL, &c_add)
+static void
+ent_set(struct gpt_ent *ent, const map_t map, const gpt_uuid_t xtype,
+ const uint8_t *xname)
+{
+ gpt_uuid_copy(ent->ent_type, xtype);
+ ent->ent_lba_start = htole64(map->map_start);
+ ent->ent_lba_end = htole64(map->map_start + map->map_size - 1LL);
+ if (xname != NULL)
+ utf8_to_utf16(xname, ent->ent_name, sizeof(ent->ent_name));
+}
+
static int
add(gpt_t gpt)
{
map_t map;
struct gpt_hdr *hdr;
- struct gpt_ent *ent, e;
+ struct gpt_ent *ent;
unsigned int i;
off_t alignsecs;
char buf[128];
@@ -128,18 +139,11 @@
}
}
- memset(&e, 0, sizeof(e));
- gpt_uuid_copy(e.ent_type, type);
- e.ent_lba_start = htole64(map->map_start);
- e.ent_lba_end = htole64(map->map_start + map->map_size - 1LL);
- if (name != NULL)
- utf8_to_utf16(name, e.ent_name, 36);
-
- memcpy(ent, &e, sizeof(e));
+ ent_set(ent, map, type, name);
gpt_write_primary(gpt);
ent = gpt_ent_backup(gpt, i);
- memcpy(ent, &e, sizeof(e));
+ ent_set(ent, map, type, name);
gpt_write_backup(gpt);
gpt_uuid_snprintf(buf, sizeof(buf), "%d", type);
@@ -185,7 +189,7 @@
if (optind != argc)
return usage();
- if ((sectors = gpt_check_ais(gpt, alignment, entry, size)) == -1)
+ if ((sectors = gpt_check_ais(gpt, alignment, ~0, size)) == -1)
return -1;
return add(gpt);
Home |
Main Index |
Thread Index |
Old Index