shithub: riscv

Download patch

ref: dca7c99602b6aaf5bd8fdab80d0b4958054970e5
parent: 52c77e17cacef05e111c777404566a822254a92c
author: ment <[email protected]>
date: Sun May 8 20:02:02 EDT 2011

disk/partfs: minor bugfixes

--- a/sys/src/cmd/disk/partfs.c
+++ b/sys/src/cmd/disk/partfs.c
@@ -49,7 +49,7 @@
 	for (p = tab; p < tab + nelem(tab); p++)
 		if (p->inuse)
 			fmtprint(&fmt, "part %s %lld %lld\n",
-				p->name, p->offset, p->length);
+				p->name, p->offset, p->offset + p->length);
 	return fmtstrflush(&fmt);
 }
 
@@ -67,11 +67,14 @@
 		werrstr("partition name already in use");
 		return -1;
 	}
-	for (p = tab; p < tab + nelem(tab) && p->inuse; p++)
-		if (strcmp(p->name, name) == 0) {
+	for (p = tab; p < tab + nelem(tab); p++)
+		if (p->inuse && strcmp(p->name, name) == 0) {
 			werrstr("partition name already in use");
 			return -1;
 		}
+	for (p = tab; p < tab + nelem(tab); p++)
+		if (!p->inuse) 
+			break;
 	if(p == tab + nelem(tab)){
 		werrstr("no free partition slots");
 		return -1;