Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sbin/gpt/remove.c,v rcsdiff: /ftp/cvs/cvsroot/src/sbin/gpt/remove.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.3.4.1 retrieving revision 1.10 diff -u -p -r1.3.4.1 -r1.10 --- src/sbin/gpt/remove.c 2008/01/09 01:38:07 1.3.4.1 +++ src/sbin/gpt/remove.c 2013/11/22 04:21:02 1.10 @@ -29,7 +29,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.3.4.1 2008/01/09 01:38:07 matt Exp $"); +__RCSID("$NetBSD: remove.c,v 1.10 2013/11/22 04:21:02 jnemeth Exp $"); #endif #include @@ -50,10 +50,10 @@ static off_t block, size; static unsigned int entry; const char removemsg1[] = "remove -a device ..."; -const char removemsg2[] = "remove [-b lba] [-i index] [-s lba] " - "[-t uuid] device ..."; +const char removemsg2[] = "remove [-b blocknr] [-i index] [-s sectors] " + "[-t type] device ..."; -static void +__dead static void usage_remove(void) { @@ -112,13 +112,14 @@ rem(int fd) hdr = gpt->map_data; ent = (void*)((char*)tbl->map_data + i * le32toh(hdr->hdr_entsz)); - le_uuid_dec(&ent->ent_type, &uuid); + le_uuid_dec(ent->ent_type, &uuid); if (!uuid_is_nil(&type, NULL) && !uuid_equal(&type, &uuid, NULL)) continue; /* Remove the primary entry by clearing the partition type. */ - uuid_create_nil((uuid_t *)&ent->ent_type, NULL); + uuid_create_nil(&uuid, NULL); + le_uuid_enc(ent->ent_type, &uuid); hdr->hdr_crc_table = htole32(crc32(tbl->map_data, le32toh(hdr->hdr_entries) * le32toh(hdr->hdr_entsz))); @@ -132,8 +133,8 @@ rem(int fd) ent = (void*)((char*)lbt->map_data + i * le32toh(hdr->hdr_entsz)); - /* Remove the secundary entry. */ - uuid_create_nil((uuid_t *)&ent->ent_type, NULL); + /* Remove the secondary entry. */ + le_uuid_enc(ent->ent_type, &uuid); hdr->hdr_crc_table = htole32(crc32(lbt->map_data, le32toh(hdr->hdr_entries) * le32toh(hdr->hdr_entsz))); @@ -157,6 +158,7 @@ cmd_remove(int argc, char *argv[]) { char *p; int ch, fd; + int64_t human_num; /* Get the remove options */ while ((ch = getopt(argc, argv, "ab:i:s:t:")) != -1) { @@ -169,9 +171,9 @@ cmd_remove(int argc, char *argv[]) case 'b': if (block > 0) usage_remove(); - block = strtoll(optarg, &p, 10); - if (*p != 0 || block < 1) + if (dehumanize_number(optarg, &human_num) < 0) usage_remove(); + block = human_num; break; case 'i': if (entry > 0)