[patch] allow undo creating BSD and VTOC8 schemes with gpart(8)

Andrey V. Elsukov bu7cher at yandex.ru
Tue Apr 6 12:46:57 UTC 2010


Hi, All and Marcel,

I found that gpart(8) doesn't support undo for "create"
command for BSD and VTOC8 schemes, because they have internal
entries in table. I added this support and it seems it works.
So my question addressed to Marcel: is it correct? :)

-- 
WBR, Andrey V. Elsukov
-------------- next part --------------
Index: g_part.c
===================================================================
--- g_part.c	(revision 204945)
+++ g_part.c	(working copy)
@@ -1065,12 +1174,18 @@ g_part_ctl_undo(struct gctl_req *req, struct g_par
 	    table->gpt_created) ? 1 : 0;
 
 	if (reprobe) {
-		if (!LIST_EMPTY(&table->gpt_entry)) {
+		LIST_FOREACH(entry, &table->gpt_entry, gpe_entry) {
+			if (entry->gpe_internal)
+				continue;
 			error = EBUSY;
 			goto fail;
 		}
 		error = g_part_probe(gp, cp, table->gpt_depth);
 		if (error) {
+			while ((entry = LIST_FIRST(&table->gpt_entry)) != NULL) {
+				LIST_REMOVE(entry, gpe_entry);
+				g_free(entry);
+			}
 			g_topology_lock();
 			g_access(cp, -1, -1, -1);
 			g_part_wither(gp, error);


More information about the freebsd-geom mailing list