diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2001-10-12 04:48:03 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2001-10-12 04:48:03 +0000 |
commit | 5a979ef8a968dd8cd258a257a753813d2489d030 (patch) | |
tree | 6324f5e82c5391dac4ebcb0477bb8a4ee605a28b | |
parent | b71dfadde17c337bd3cb142629be0e903123ece4 (diff) |
New feature for pdisk, change the type of a parition.
Useful since that is part of the OpenBSD/macppc installation procedure.
Code by Alexander Guy,
examined by drahn@
ok deraadt@
-rw-r--r-- | sbin/pdisk/partition_map.c | 2 | ||||
-rw-r--r-- | sbin/pdisk/pdisk.c | 51 |
2 files changed, 51 insertions, 2 deletions
diff --git a/sbin/pdisk/partition_map.c b/sbin/pdisk/partition_map.c index af3d8c355b7..48738221b84 100644 --- a/sbin/pdisk/partition_map.c +++ b/sbin/pdisk/partition_map.c @@ -70,7 +70,7 @@ // const char * kFreeType = "Apple_Free"; const char * kMapType = "Apple_partition_map"; -const char * kUnixType = "Apple_UNIX_SVR2"; +const char * kUnixType = "OpenBSD"; const char * kHFSType = "Apple_HFS"; const char * kPatchType = "Apple_Patches"; diff --git a/sbin/pdisk/pdisk.c b/sbin/pdisk/pdisk.c index b990482b2be..e8623e22db3 100644 --- a/sbin/pdisk/pdisk.c +++ b/sbin/pdisk/pdisk.c @@ -122,6 +122,7 @@ void do_display_entry(partition_map_header *map); void do_examine_patch_partition(partition_map_header *map); int do_expert(partition_map_header *map, char *name); void do_rename_partition(partition_map_header *map); +void do_change_type(partition_map_header *map); void do_reorder(partition_map_header *map); void do_write_partition_map(partition_map_header *map); void edit(char *name, int ask_logical_size); @@ -559,11 +560,12 @@ edit(char *name, int ask_logical_size) printf(" P (print ordered by base address)\n"); printf(" i initialize partition map\n"); printf(" s change size of partition map\n"); - printf(" c create new partition (standard MkLinux type)\n"); + printf(" c create new partition (standard OpenBSD type)\n"); printf(" C (create with type also specified)\n"); printf(" n (re)name a partition\n"); printf(" d delete a partition\n"); printf(" r reorder partition entry in map\n"); + printf(" t change a partition's type\n"); if (!rflag) { printf(" w write the partition table\n"); } @@ -609,6 +611,10 @@ edit(char *name, int ask_logical_size) case 's': do_change_map_size(map); break; + case 'T': + case 't': + do_change_type(map); + break; case 'X': case 'x': if (!dflag) { @@ -783,6 +789,49 @@ do_rename_partition(partition_map_header *map) return; } +void +do_change_type(partition_map_header *map) +{ + partition_map * entry; + long index; + char *type = NULL; + + if (map == NULL) { + bad_input("No partition map exists"); + return; + } + + if (!rflag && map->writeable == 0) { + printf("The map is not writeable.\n"); + } + + if (get_number_argument("Partition number: ", &index, kDefault) == 0) { + bad_input("Bad partition number"); + return; + } + + entry = find_entry_by_disk_address(index, map); + + if (entry == NULL ) { + printf("No such partition\n"); + goto out; + } + + printf("Existing partition type ``%s''.\n", entry->data->dpme_type); + if (get_string_argument("New type of partition: ", &type, 1) == 0) { + bad_input("Bad type"); + goto out; + } + + strncpy(entry->data->dpme_type, type, DPISTRLEN); + map->changed = 1; + +out: + if (type) + free(type); + return; +} + void do_delete_partition(partition_map_header *map) |