From owner-freebsd-hackers Wed Sep 26 10: 4:51 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from tomts9-srv.bellnexxia.net (tomts9.bellnexxia.net [209.226.175.53]) by hub.freebsd.org (Postfix) with ESMTP id 2A11437B410; Wed, 26 Sep 2001 10:04:23 -0700 (PDT) Received: from khan.anarcat.dyndns.org ([65.92.169.79]) by tomts9-srv.bellnexxia.net (InterMail vM.4.01.03.16 201-229-121-116-20010115) with ESMTP id <20010926170412.SGDK25005.tomts9-srv.bellnexxia.net@khan.anarcat.dyndns.org>; Wed, 26 Sep 2001 13:04:12 -0400 Received: from shall.anarcat.dyndns.org (shall.anarcat.dyndns.org [192.168.0.1]) by khan.anarcat.dyndns.org (Postfix) with ESMTP id EE9371AAD; Wed, 26 Sep 2001 13:03:53 -0400 (EDT) Received: by shall.anarcat.dyndns.org (Postfix, from userid 1000) id 02C4E20B36; Wed, 26 Sep 2001 13:03:50 -0400 (EDT) Date: Wed, 26 Sep 2001 13:03:50 -0400 From: The Anarcat To: freebsd-doc@freebsd.org Cc: freebsd-hackers@freebsd.org Subject: libh?disk doc (deficiencies?) Message-ID: <20010926130350.C40172@shall.anarcat.dyndns.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="n2Pv11Ogg/Ox8ay5" Content-Disposition: inline User-Agent: Mutt/1.3.22.1i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --n2Pv11Ogg/Ox8ay5 Content-Type: multipart/mixed; boundary="oTHb8nViIGeoXxdp" Content-Disposition: inline --oTHb8nViIGeoXxdp Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable [crossposted to -hackers in a hope to have more information, sorry if this is inappropriate] Hi. I'm currently working a bit on libh, which includes a libhdisk library to interface libdisk(3), newfs, etc, in short, a interface to operate disk partition/slice edition =E0 la sysinstall. The thing is that I'm trying to figure out how all this stuff works. libdisk(3) is not very informative, in fact, it doesn't document anything below the "slice" level (FS_SWAP macro and structure of a Disk/Chunk tree, for example). I made a little graphic (ASCII!) to show how such a tree (Disk/Chunk) is made, along with an algorithm from sysinstall's label.c that extract relevant data out of it. I will make documentation for the Disk/Chunk class hierarchy and functions, and that will imply investigating libdisk's functions.=20 I think libdisk(3) should be split and rewrote. Anyways, isn't it policy to have *functions* instead of *libraries* documented in manpages? :) The thing is that I might not be the best person to do it, and I do not understand everything clearly yet. If anyone has any other source of information (apart from source code), please share. :) I will probably end up posting prs about libdisk's doc... One thing I haven't figured out yet is why there is an intermediate "Chunk" between Disk and slices (see picture, the first chunk on the right of the Disk box). I think the graphic is quite good, and should be included somewhere, for reference because it took me a while to figure it out. A. --oTHb8nViIGeoXxdp Content-Type: text/plain; charset=us-ascii Content-Description: libh/release/labeledit/algo.txt Content-Disposition: attachment; filename="algo.txt" Content-Transfer-Encoding: quoted-printable We have the structures: +--------+ +-------+ | Disk | | Chunk |=20 | | | | This chunk represents the disk in itself | chunks--->| part |=20 +--------+ +--|----+=20 | =20 +--------------|---------------------------+ |Slices (e.g. | freebsd, linux, dos) | | V | | +-----------+ +-----------+ | | | Chunk | | Chunk | | | | | | | | | | type=3Dfbsd | | type=3Dfat | | | | | | | | | | part next----->| part next----> ... | | | | | | | | | | +--|--------+ +---|-------+ | | | ? | +------|-----------------------------------+ | +------|-----------------------------------+ |Partitions (eg. fs, swap) | | V | | +--------------+ +--------+ | | | Chunk | | Chunk | | | | | | | | | | type=3Dpart | | ... | | | | | | | | | | next----->| next----> ... | | | | | | | | | subtype=3Dswap | | ... | | | | | | | | | +--------------+ +--------+ | | | +------------------------------------------+ /* All the chunks currently displayed on the screen */ static struct { struct chunk *c; PartType type; } label_chunk_info[MAX_CHUNKS + 1]; /* this function flattens such a tree in a single array */ static void record_label_chunks(Device **devs, Device *dev) { int i, j, p; struct chunk *c1, *c2; Disk *d; j =3D p =3D 0; /* First buzz through and pick up the FreeBSD slices */ for (i =3D 0; devs[i]; i++) { if ((dev && devs[i] !=3D dev) || !devs[i]->enabled) continue; d =3D (Disk *)devs[i]->private; if (!d->chunks) msgFatal("No chunk list found for %s!", d->name); /* Put the slice entries first */ for (c1 =3D d->chunks->part; c1; c1 =3D c1->next) { if (c1->type =3D=3D freebsd) { label_chunk_info[j].type =3D PART_SLICE; label_chunk_info[j].c =3D c1; ++j; } } } /* Now run through again and get the FreeBSD partition entries */ for (i =3D 0; devs[i]; i++) { if (!devs[i]->enabled) continue; d =3D (Disk *)devs[i]->private; /* Then buzz through and pick up the partitions */ for (c1 =3D d->chunks->part; c1; c1 =3D c1->next) { if (c1->type =3D=3D freebsd) { for (c2 =3D c1->part; c2; c2 =3D c2->next) { if (c2->type =3D=3D part) { if (c2->subtype =3D=3D FS_SWAP) label_chunk_info[j].type =3D PART_SWAP; else label_chunk_info[j].type =3D PART_FILESYSTEM; label_chunk_info[j].c =3D c2; ++j; } } } else if (c1->type =3D=3D fat) { label_chunk_info[j].type =3D PART_FAT; label_chunk_info[j].c =3D c1; ++j; } } } label_chunk_info[j].c =3D NULL; if (here >=3D j) { here =3D j ? j - 1 : 0; } } --oTHb8nViIGeoXxdp-- --n2Pv11Ogg/Ox8ay5 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjuyCnUACgkQttcWHAnWiGcIdwCeMGZ0JINGAJ9EAvP6reQdAuFb eCIAni5QtKHblw51OKnEq8lQshr3+Uy7 =7B4T -----END PGP SIGNATURE----- --n2Pv11Ogg/Ox8ay5-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message