Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/dist/pdisk Add command to change partition types directly.
details: https://anonhg.NetBSD.org/src/rev/15578ee5941d
branches: trunk
changeset: 543168:15578ee5941d
user: soren <soren%NetBSD.org@localhost>
date: Tue Feb 18 16:20:37 2003 +0000
description:
Add command to change partition types directly.
>From Alexander Guy via OpenBSD.
diffstat:
dist/pdisk/pdisk.8 | 3 ++-
dist/pdisk/pdisk.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 1 deletions(-)
diffs (97 lines):
diff -r 76c53b853c95 -r 15578ee5941d dist/pdisk/pdisk.8
--- a/dist/pdisk/pdisk.8 Tue Feb 18 15:38:53 2003 +0000
+++ b/dist/pdisk/pdisk.8 Tue Feb 18 16:20:37 2003 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pdisk.8,v 1.9 2002/09/17 08:14:22 dbj Exp $
+.\" $NetBSD: pdisk.8,v 1.10 2003/02/18 16:20:37 soren Exp $
.Dd August 19, 2002
.Os
.Dt PDISK 8
@@ -100,6 +100,7 @@
p print the partition table
q quit editing (don't save changes)
r reorder partition entry in map
+t change the type of an existing partition
s change size of partition map
w write the partition table
.Ed
diff -r 76c53b853c95 -r 15578ee5941d dist/pdisk/pdisk.c
--- a/dist/pdisk/pdisk.c Tue Feb 18 15:38:53 2003 +0000
+++ b/dist/pdisk/pdisk.c Tue Feb 18 16:20:37 2003 +0000
@@ -124,6 +124,7 @@
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);
@@ -557,6 +558,7 @@
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");
}
@@ -607,6 +609,10 @@
case 's':
do_change_map_size(map);
break;
+ case 'T':
+ case 't':
+ do_change_type(map);
+ break;
case 'X':
case 'x':
if (!dflag) {
@@ -790,6 +796,49 @@
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->writable == 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)
Home |
Main Index |
Thread Index |
Old Index