]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/cmd/disk/partfs.c
disk/format: removed 9fat magic VOLID value
[plan9front.git] / sys / src / cmd / disk / partfs.c
index a14e2c91adab8cd722482a2bbd6fb096bba6fb48..883f16d8482a050518471b650062bfe24a5a344a 100644 (file)
@@ -49,7 +49,7 @@ ctlstring(void)
        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 @@ addpart(char *name, vlong start, vlong end)
                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;