From owner-freebsd-libh Mon Oct 8 11:22:43 2001 Delivered-To: freebsd-libh@freebsd.org Received: from tomts10-srv.bellnexxia.net (tomts10.bellnexxia.net [209.226.175.54]) by hub.freebsd.org (Postfix) with ESMTP id DA4F637B405 for ; Mon, 8 Oct 2001 11:22:26 -0700 (PDT) Received: from khan.anarcat.dyndns.org ([65.94.128.156]) by tomts10-srv.bellnexxia.net (InterMail vM.4.01.03.16 201-229-121-116-20010115) with ESMTP id <20011008182225.PCDX4321.tomts10-srv.bellnexxia.net@khan.anarcat.dyndns.org> for ; Mon, 8 Oct 2001 14:22:25 -0400 Received: from shall.anarcat.dyndns.org (shall.anarcat.dyndns.org [192.168.0.1]) by khan.anarcat.dyndns.org (Postfix) with ESMTP id 265961B2E for ; Mon, 8 Oct 2001 14:22:21 -0400 (EDT) Received: by shall.anarcat.dyndns.org (Postfix, from userid 1000) id EEE3720B36; Mon, 8 Oct 2001 14:23:01 -0400 (EDT) Date: Mon, 8 Oct 2001 14:23:01 -0400 From: The Anarcat To: Libh Subject: basic label editor stub, take II Message-ID: <20011008142300.B53336@shall.anarcat.dyndns.org> Mail-Followup-To: The Anarcat , Libh Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="LwW0XdcUbUexiWVK" Content-Disposition: inline User-Agent: Mutt/1.3.22.1i Sender: owner-freebsd-libh@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --LwW0XdcUbUexiWVK Content-Type: multipart/mixed; boundary="TRYliJ5NKNqkz5bu" Content-Disposition: inline --TRYliJ5NKNqkz5bu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi again... I fitted a label editor stub in diskwizard. (attached patch) I have made a basic "iterator" that walks a DiskChunk hierarchy, breath-first, pre-order. I have also made a simple "print_chunk" proc to test that algorithm. It works fine. I will use it to create the partition list and the editing interface. I have included these algorithms in the new disklabel.tcl file. Now, my concern is the following... Eventually, this tool will (and should) be used to manipulate things such as /etc/fstab and partitions. The thing is that a lot of partitions types are *not* supported by libhdisk. We have the type proc to have a unique integer designating the partition "type": MethodDescription("type", "type", LanguageInterface::Object::MethodDescription::fDynamic, "0 - whole, 1 - unknown, 2 - fat, 3 - freebsd, 4 - extended, 5 - part, 6= - unused", MethodDescription::vtInt, MethodDescription::vtVoid), But partition types can be much more than that! For example, it is quite possible to have a NTFS or ext2fs partitions in there. Currently, this is not very important since support for these partitions is unstable at best. But we can probably hope for best support.=20 And anyways, it would be nice to have something other than "unknown" as partition type when we know what it is, because we know (Disk.cc:420, sliceTypeNames[]). Actually, the types from sliceTypeNames are available in the DiskChunk, as subtype(). So we would probably just need to implement subtype_text() or something. And as a matter of fact, Disk::slice_type_name already implements that: case 1: for ( SliceTypeName* t =3D sliceTypeNames; t->name; ++t ) if ( subtype =3D=3D t->type ) return(t->name); return("unknown"); case 2: return("fat"); case 3: switch ( subtype ) { case 165: for ( SliceTypeName* t =3D sliceTypeNames; t->name; ++t ) if ( subtype =3D=3D t->type ) return(t->name); default: return("unknown"); } But this is not accessible from DiskChunk... Anyways, this interface is getting rather heavy. Isn't there a way to export tables such as sliceTypeNames[] from C/C++ to TCL? Keeping on the work on the label editor... A. --TRYliJ5NKNqkz5bu Content-Type: text/plain; charset=us-ascii Content-Description: patch to add partition editor button Content-Disposition: attachment; filename=patch-20011008 Content-Transfer-Encoding: quoted-printable Index: diskwizard.tcl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/libh/cvs/libh/release/diskedit/diskwizard.tcl,v retrieving revision 1.5 diff -u -r1.5 diskwizard.tcl --- diskwizard.tcl 2001/10/04 18:21:35 1.5 +++ diskwizard.tcl 2001/10/08 18:02:18 @@ -1,5 +1,12 @@ global disks =20 +proc part_callback {hui button userdata} { + + source disklabel.tcl + disklabel + +} + proc disk_geometry_text {disk} { # XXX add size of disk in MB format "%d cyls/%d heads/%d sectors =3D %d sectors" [$disk bios_cyl] [= $disk bios_hd] [$disk bios_sect] [expr [$disk bios_cyl] * [$disk bios_hd] *= [$disk bios_sect]] @@ -52,9 +59,13 @@ =20 set quit_button [$cont button "quit_button" "&Quit" {quit_callback ""}] set fdisk_button [$cont button "fdisk_button" "&FDisk" {fdisk_callback= ""}] + set label_button [$cont button "label_button" "&Partition" {part_callb= ack ""}] + $quit_button resize "10 2" $fdisk_button resize "10 2" + $label_button resize "10 2" $quit_button move "0 0" + $label_button move "19 0" $fdisk_button move "38 0" =20 set menubar [$hui menuBar] --TRYliJ5NKNqkz5bu Content-Type: application/x-tcl Content-Description: new disklabel file Content-Disposition: attachment; filename="disklabel.tcl" Content-Transfer-Encoding: quoted-printable # walk a chunk architecture, exectuting proc on each chunk=0Aproc iterate_c= hunk {chunk procname} {=0A if {[info commands $procname] !=3D $procname}= {=0A puts stderr "unknown procedure $procname!!!"=0A }=0A =0A= if {![H::is_null $chunk]} {=0A $procname $chunk=0A iterat= e_chunk [$chunk next] $procname=0A iterate_chunk [$chunk part] $proc= name=0A }=0A}=0A=0Aproc print_chunk {chunk} {=0A =0A puts [format = "%s\t%s\t%s\t%s" \=0A [$chunk name] [$chunk type_text] \=0A = [$chunk offset] [$chunk end]]=0A=0A}=0A=0A# FIXME: no default fo= r diskname please!=0A# also, diskname should be something like ad0s2=0Aproc= disklabel {} {=0A puts stderr "unimplemented"=0A global main_window= =0A global menubar=0A global hui=0A global slices=0A global dia= log=0A global activedisk=0A=0A foreach diskname [Disk::Disk_Names] {= =0A if {![string match "*cd*" $diskname] &&=0A ![string m= atch "*md*" $diskname]=0A } {=0A if { [catch {set d [Disk= $diskname]} fid] } {=0A # XXX: we should put this in a wind= ow=0A puts stderr "warning: $fid"=0A } else {=0A = set activedisk [Disk $diskname]=0A iterate_ch= unk [$activedisk chunks] "print_chunk"=0A }=0A }=0A }= =0A return=0A} --TRYliJ5NKNqkz5bu-- --LwW0XdcUbUexiWVK 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 iEYEARECAAYFAjvB7wMACgkQttcWHAnWiGfaqwCfaOrzKDPjwGu5mZ9Mn5+Fi15I o7UAn3E/fUePUeaQOQgnnQODv6rWFS3g =UjEW -----END PGP SIGNATURE----- --LwW0XdcUbUexiWVK-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-libh" in the body of the message