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.6.1 retrieving revision 1.12 diff -u -p -r1.3.6.1 -r1.12 --- src/sbin/gpt/remove.c 2007/12/27 00:46:58 1.3.6.1 +++ src/sbin/gpt/remove.c 2013/11/28 01:37:14 1.12 @@ -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.6.1 2007/12/27 00:46:58 mjf Exp $"); +__RCSID("$NetBSD: remove.c,v 1.12 2013/11/28 01:37:14 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))); @@ -142,13 +143,8 @@ rem(int fd) gpt_write(fd, lbt); gpt_write(fd, tpg); -#ifdef __FreeBSD__ - printf("%sp%u removed\n", device_name, m->map_index); -#endif -#ifdef __NetBSD__ printf("partition %d removed from %s\n", m->map_index, device_name); -#endif } } @@ -157,6 +153,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,8 +166,10 @@ 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; + if (block < 1) usage_remove(); break; case 'i':