Subject: misc/33695: Netbsd/Freebsd disklabel syntax compatibility
To: None <,,>
From: None <>
List: netbsd-bugs
Date: 06/10/2006 23:10:00
>Number:         33695
>Category:       misc
>Synopsis:       Netbsd/Freebsd disklabel syntax compatibility
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    misc-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jun 10 23:10:00 +0000 2006
>Originator:     Arnaud Lacombe
>Release:        3.99.21
Last day I wanted to be able to access a disk (on an USB<->IDE adapter) 
from both freebsd and netbsd. The only problem I encountered was that
netbsd was unable to read properly the label (and thus, it couldn't
configure each slice). I fixed the problem by writing the freebsd
disklabel (given by `disklabel -A /dev/...') on the disk from the netbsd box.

Freebsd disklabel is almost the same as netbsd one, except that the
field `sectors/unit' on freebsd is `total sectors' on netbsd . On both
system, it fills the `d_secperunit' field in the disklabel structure.
Attached patch allows to use both the netbsd and freebsd notation.

try to write the disklabel -A output from a freebsd box to a netbsd box
--- disklabel/main.c.orig       Sun Jun 11 00:16:58 2006
+++ disklabel/main.c    Sun Jun 11 00:19:00 2006
@@ -1459,7 +1459,7 @@
                                lp->d_ncylinders = v;
-               if (!strcmp(cp, "total sectors")) {
+               if (!strcmp(cp, "total sectors") || !strcmp(cp, "sectors/unit")) {
                        if (GETNUM32(tp, &v) != 0) {
                                warnx("line %d: bad %s: %s", lineno, cp, tp);