From owner-freebsd-geom@FreeBSD.ORG Sun Jan 25 00:51:40 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CEA8816A4CE; Sun, 25 Jan 2004 00:51:40 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5C1DE43D45; Sun, 25 Jan 2004 00:51:39 -0800 (PST) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.10/8.12.10) with ESMTP id i0P8pauO050680; Sun, 25 Jan 2004 09:51:37 +0100 (CET) (envelope-from phk@phk.freebsd.dk) To: "Greg 'groggy' Lehey" From: "Poul-Henning Kamp" In-Reply-To: Your message of "Sun, 25 Jan 2004 09:48:57 +1030." <20040124231857.GM20359@wantadilla.lemis.com> Date: Sun, 25 Jan 2004 09:51:36 +0100 Message-ID: <50679.1075020696@critter.freebsd.dk> cc: freebsd-geom@FreeBSD.org cc: Lukas Ertl Subject: Re: Updated geom_vinum X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jan 2004 08:51:41 -0000 In message <20040124231857.GM20359@wantadilla.lemis.com>, "Greg 'groggy' Lehey" writes: > >--4oF+6Ged69J0+4/e >Content-Type: text/plain; charset=us-ascii >Content-Disposition: inline > >On Saturday, 24 January 2004 at 8:44:43 +0100, Poul-Henning Kamp wrote: >> In message <20040124013406.GB20359@wantadilla.lemis.com>, "Greg 'groggy' Lehey" >> writes: >> >>> While a lot of things go away as the result of GEOM, others don't, >>> like the I/O stats and revive parameters for example. >> >> Geom takes care of the I/O stats, see gstat(8) > >It only does a subset of the Vinum stats. What is missing ? -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From owner-freebsd-geom@FreeBSD.ORG Sun Jan 25 00:56:16 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2189B16A4CE; Sun, 25 Jan 2004 00:56:16 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id BCB6A43D39; Sun, 25 Jan 2004 00:56:14 -0800 (PST) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.10/8.12.10) with ESMTP id i0P8uDuO050756; Sun, 25 Jan 2004 09:56:13 +0100 (CET) (envelope-from phk@phk.freebsd.dk) To: "Greg 'groggy' Lehey" From: "Poul-Henning Kamp" In-Reply-To: Your message of "Sun, 25 Jan 2004 12:33:55 +1030." <20040125020355.GS20359@wantadilla.lemis.com> Date: Sun, 25 Jan 2004 09:56:13 +0100 Message-ID: <50755.1075020973@critter.freebsd.dk> cc: freebsd-geom@FreeBSD.org cc: Soeren Straarup cc: Lukas Ertl Subject: Re: Updated geom_vinum X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jan 2004 08:56:16 -0000 In message <20040125020355.GS20359@wantadilla.lemis.com>, "Greg 'groggy' Lehey" writes: >Wouldn't it be better to do this by default? In general, I'd think it >would be a good idea to have PostScript which prints on printers. What I'd really like to see is for somebody to use one of the GUI api's to graphviz to make us a small X tool which shows this graph (so I don't have to waste paper) and allows one to print it as well. Any takers ? Ideally it should parse the XML (there's already code to help do this in libgeom so don't panic), but I'll be satisfied if it takes the shortcut and uses the confdot sysctl for starters. Poul-Henning PS: The "todolist" I posted earlier should no be interpreted to mean that I think I expect to do it all personally, feel free to grap tasks and start working :-) -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From owner-freebsd-geom@FreeBSD.ORG Sun Jan 25 02:27:16 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EA01616A4CE for ; Sun, 25 Jan 2004 02:27:16 -0800 (PST) Received: from ozlabs.org (ozlabs.org [203.10.76.45]) by mx1.FreeBSD.org (Postfix) with ESMTP id 163E243D46 for ; Sun, 25 Jan 2004 02:27:14 -0800 (PST) (envelope-from grog@lemis.com) Received: from blackwater.lemis.com (blackwater.lemis.com [192.109.197.80]) by ozlabs.org (Postfix) with ESMTP id 19AE82BD73 for ; Sun, 25 Jan 2004 21:27:12 +1100 (EST) Received: by blackwater.lemis.com (Postfix, from userid 1004) id EBC6C51209; Sun, 25 Jan 2004 20:57:09 +1030 (CST) Date: Sun, 25 Jan 2004 20:57:09 +1030 From: Greg 'groggy' Lehey To: Poul-Henning Kamp Message-ID: <20040125102709.GA50402@wantadilla.lemis.com> References: <20040124231857.GM20359@wantadilla.lemis.com> <50679.1075020696@critter.freebsd.dk> <20040124013406.GB20359@wantadilla.lemis.com> <31415.1074930283@critter.freebsd.dk> <20040124231857.GM20359@wantadilla.lemis.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="6TrnltStXW4iwmi0" Content-Disposition: inline In-Reply-To: <50679.1075020696@critter.freebsd.dk> <20040124231857.GM20359@wantadilla.lemis.com> User-Agent: Mutt/1.4.1i Organization: The FreeBSD Project Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-418-838-708 WWW-Home-Page: http://www.FreeBSD.org/ X-PGP-Fingerprint: 9A1B 8202 BCCE B846 F92F 09AC 22E6 F290 507A 4223 cc: freebsd-geom@freebsd.org cc: Lukas Ertl Subject: Re: Updated geom_vinum X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jan 2004 10:27:17 -0000 --6TrnltStXW4iwmi0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sunday, 25 January 2004 at 9:51:36 +0100, Poul-Henning Kamp wrote: > In message <20040124231857.GM20359@wantadilla.lemis.com>, "Greg 'groggy' Lehey" > writes: >> >> --4oF+6Ged69J0+4/e >> Content-Type: text/plain; charset=us-ascii >> Content-Disposition: inline >> >> On Saturday, 24 January 2004 at 8:44:43 +0100, Poul-Henning Kamp wrote: >>> In message <20040124013406.GB20359@wantadilla.lemis.com>, "Greg 'groggy' Lehey" >>> writes: >>> >>>> While a lot of things go away as the result of GEOM, others don't, >>>> like the I/O stats and revive parameters for example. >>> >>> Geom takes care of the I/O stats, see gstat(8) >> >> It only does a subset of the Vinum stats. > > What is missing ? As I said: > It only does a subset of the Vinum stats. It's also unclear how it > can handle important Vinum-specific things like the number of > fragmented requests. There are other things too, but in view of this issue, I don't think it's worth discussing the relative merits of the other stats. It would be more interesting to consider a distributed manner of keeping stats. Greg -- See complete headers for address and phone numbers. --6TrnltStXW4iwmi0 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (FreeBSD) iD8DBQFAE5n9IubykFB6QiMRAoAUAKCcEyiVnGXbc6SB0Cde+YWwk1IIMACcCneW ldvu3dJrjqiiWZrDCMC2+gk= =TqOm -----END PGP SIGNATURE----- --6TrnltStXW4iwmi0-- From owner-freebsd-geom@FreeBSD.ORG Sun Jan 25 02:30:58 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6B80516A4CE; Sun, 25 Jan 2004 02:30:58 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id E74B943D41; Sun, 25 Jan 2004 02:30:56 -0800 (PST) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.10/8.12.10) with ESMTP id i0PAUsuO051554; Sun, 25 Jan 2004 11:30:54 +0100 (CET) (envelope-from phk@phk.freebsd.dk) To: "Greg 'groggy' Lehey" From: "Poul-Henning Kamp" In-Reply-To: Your message of "Sun, 25 Jan 2004 20:57:09 +1030." <20040125102709.GA50402@wantadilla.lemis.com> Date: Sun, 25 Jan 2004 11:30:54 +0100 Message-ID: <51553.1075026654@critter.freebsd.dk> cc: freebsd-geom@FreeBSD.org cc: Lukas Ertl Subject: Re: Updated geom_vinum X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jan 2004 10:30:58 -0000 In message <20040125102709.GA50402@wantadilla.lemis.com>, "Greg 'groggy' Lehey" writes: >>> It only does a subset of the Vinum stats. >> >> What is missing ? > >As I said: > >> It only does a subset of the Vinum stats. It's also unclear how it >> can handle important Vinum-specific things like the number of >> fragmented requests. > >There are other things too, but in view of this issue, I don't think >it's worth discussing the relative merits of the other stats. It >would be more interesting to consider a distributed manner of keeping >stats. I wasn't asking to start a pissing contest, I was asking to find out if there is anything which should be added to the GEOM stats. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From owner-freebsd-geom@FreeBSD.ORG Sun Jan 25 10:07:47 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A4DB416A4CE for ; Sun, 25 Jan 2004 10:07:47 -0800 (PST) Received: from pasmtp.tele.dk (pasmtp.tele.dk [193.162.159.95]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6063043D31 for ; Sun, 25 Jan 2004 10:07:46 -0800 (PST) (envelope-from xride@x12.dk) Received: from x12.dk (xforce.dk [80.164.11.218]) by pasmtp.tele.dk (Postfix) with ESMTP id E38021EC314 for ; Sun, 25 Jan 2004 19:07:44 +0100 (CET) Received: by x12.dk (Postfix, from userid 666) id A36F338; Sun, 25 Jan 2004 19:07:44 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by x12.dk (Postfix) with ESMTP id 8E6EB28 for ; Sun, 25 Jan 2004 19:07:44 +0100 (CET) Date: Sun, 25 Jan 2004 19:07:44 +0100 (CET) From: Soeren Straarup To: freebsd-geom@freebsd.org Message-ID: <20040125190313.U77841-100000@x12.dk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Subject: How to test the new geom_vinum code? X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jan 2004 18:07:47 -0000 Hi I tried to test the code, but i failed. I don't know where i fallied in the test though. I loaded the klm Then tried to mount /dev/gvinum/ Or do i have to dump using the old vinum, then start backup the geom_vinum and newfs the virtual disk and resotre? Best regards S=F8ren. Soeren Straarup | aka OZ2DAK aka Xride FreeBSD wannabe | FreeBSD since 2.2.6-R If you see the light at the end of the tunnel, then make sure it is not a train.. From owner-freebsd-geom@FreeBSD.ORG Sun Jan 25 10:17:22 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A74FE16A4CE for ; Sun, 25 Jan 2004 10:17:22 -0800 (PST) Received: from mailbox.univie.ac.at (mailbox.univie.ac.at [131.130.1.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id EA81D43D3F for ; Sun, 25 Jan 2004 10:17:20 -0800 (PST) (envelope-from l.ertl@univie.ac.at) Received: from leelou (adslle.cc.univie.ac.at [131.130.102.11]) i0PIHEBG301546; Sun, 25 Jan 2004 19:17:16 +0100 Date: Sun, 25 Jan 2004 19:17:09 +0100 (CET) From: Lukas Ertl To: Soeren Straarup In-Reply-To: <20040125190313.U77841-100000@x12.dk> Message-ID: <20040125191407.I14463@leelou.in.tern> References: <20040125190313.U77841-100000@x12.dk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-DCC-ZID-Univie-Metrics: imap 4241; Body=2 Fuz1=2 Fuz2=2 cc: freebsd-geom@freebsd.org Subject: Re: How to test the new geom_vinum code? X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jan 2004 18:17:22 -0000 On Sun, 25 Jan 2004, Soeren Straarup wrote: > I tried to test the code, but i failed. I don't know where i fallied in > the test though. Please keep in mind, that this code is considered pre-alpha. > I loaded the klm > Then tried to mount /dev/gvinum/ > > Or do i have to dump using the old vinum, then start backup the geom_vinum > and newfs the virtual disk and resotre? No, you just have to stop vinum before loading geom_vinum. Then everything should just work as usual. regards. le -- Lukas Ertl eMail: l.ertl@univie.ac.at UNIX Systemadministrator Tel.: (+43 1) 4277-14073 Vienna University Computer Center Fax.: (+43 1) 4277-9140 University of Vienna http://mailbox.univie.ac.at/~le/ From owner-freebsd-geom@FreeBSD.ORG Sun Jan 25 12:51:25 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C610B16A4CE for ; Sun, 25 Jan 2004 12:51:25 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 66EF743D62 for ; Sun, 25 Jan 2004 12:51:17 -0800 (PST) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.10/8.12.10) with ESMTP id i0PKpFuO057580 for ; Sun, 25 Jan 2004 21:51:15 +0100 (CET) (envelope-from phk@phk.freebsd.dk) To: geom@freebsd.org From: Poul-Henning Kamp Date: Sun, 25 Jan 2004 21:51:15 +0100 Message-ID: <57579.1075063875@critter.freebsd.dk> Subject: manual page comments... X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jan 2004 20:51:26 -0000 I sat down with a printout of the manual pages and a pencil, here are my comments. Overall: great stuff, thanks a lot! I'd like to suggest that symmetric operations gets merged, for instance g_new_consumer() and g_destroy_consumer etc. We should probably also tie all these into a revised version of geom(4). About examples: I wonder if a geom_example page with a heavily commented "null" class might be a better idea than a lot of skeleton examples in the various pages. DECLARE_GEOM_CLASS Mention that it works both for compiled in and KLD'ed classes. Mention that on activation all preexisting providers are offered for tasting. We to document the member functions as well, and I wonder if they should be described on this page, on a "g_class" page or on one dedicated page for each. ->destroy_geom is also called at other times, in particular as a result of the user asking for it to happen. In the g_class initialization, please mention that people MUST use C99 initialization (like the example) so we can change the struct later on (this is important!). g_attach merge with g_detach page ? "From now on a geom ... of another class" is not really correct and rather unclear. Mention that access counts are necessary before actual I/O can happen. g_bio remove mention of bio_bcount, bio_resid, they are, and should not be used in GEOM. bio_driver[12] s/$/(ie: the provider)/ bio_caller[12] s/$/(ie: the consumer)/ bio_completed Number of bytes completed, but they may not be completed from the front of the request. bio_from, bio_to, bio_children, bio_inbed, bio_parent: mention that they are normally read-only for a class. example: Technically it could be done without a softc, and that might be worth a comment, but please keep the softc in the example since it shows how to derive it from the bio. /* * Could be: * g_io_request(cbp, LIST_FIRST(&bp->bio_to->geom->consumers)); */ g_io_requst(cbp, sc->ex_consumer); g_destroy_consumer: merge with g_new_consumer ? s/Typically t/T/ g_destroy_geom: merge with g_new_geomf ? g_destroy_provider merge with g_new_providerf ? s/A topology lock/The topology lock/ (May apply other files as well) g_error_provider maybe merge with g_new_providerf s/sectorsize, the function/sectorsize and other initialization, the function/ g_new_geomf We need to document the member functions, either here, in a "g_geom" page or one each their own pages. s/geom you need to/geom you must/ (twice) g_new_providerf s/an undefined situation/programmer error/ g_post_event merge with g_cancel_event ? needs better example. mention that events are good for avoiding running out of stack and for lock-barrier transitions. g_provider_by_name you must hold topology. The reason this is not enforced with KASSERT is the clone routine in geom_dev which cannot (this is a problem I need to fix). g_read_data, g_write_data merge s/more than or equal to 512/a multiple of the sectorsize for the provider/ g_waitfor_event /can not be called recusively/can not be called from an event/ (we should enforce this with KASSERT if we can) better example. g_wither_geom explain that this is an automatic "garbage collect" to avoid duplicated code in all classes. Mention that the softc should be disposed off and NULL'ed before calling this functions. Mention that withering a geom is not enough to ensure you can unload a class. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From owner-freebsd-geom@FreeBSD.ORG Sun Jan 25 15:47:56 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C62E416A4CE for ; Sun, 25 Jan 2004 15:47:56 -0800 (PST) Received: from milla.ask33.net (milla.ask33.net [217.197.166.60]) by mx1.FreeBSD.org (Postfix) with ESMTP id A465143D1F for ; Sun, 25 Jan 2004 15:47:55 -0800 (PST) (envelope-from nick@milla.ask33.net) Received: by milla.ask33.net (Postfix, from userid 1001) id 70D1D3ABB53; Mon, 26 Jan 2004 00:48:48 +0100 (CET) Date: Mon, 26 Jan 2004 00:48:48 +0100 From: Pawel Jakub Dawidek To: freebsd-geom@freebsd.org Message-ID: <20040125234848.GH565@garage.freebsd.pl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="doKZ0ri6bHmN2Q5y" Content-Disposition: inline X-PGP-Key-URL: http://garage.freebsd.pl/jules.asc X-OS: FreeBSD 4.8-RELEASE-p13 i386 X-URL: http://garage.freebsd.pl User-Agent: Mutt/1.5.1i Subject: Preventing deadlocks on the event queue. X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jan 2004 23:47:56 -0000 --doKZ0ri6bHmN2Q5y Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello. So, I think I've found clever way to prevents deadlock caused by calling g_waitfor_event() from an event. My idea is to check if curthread in g_waitfor_event() is a g_event thread. http://garage.freebsd.pl/patches/geom_event_deadlock.patch --=20 Pawel Jakub Dawidek pawel@dawidek.net UNIX Systems Programmer/Administrator http://garage.freebsd.pl Am I Evil? Yes, I Am! http://cerber.sourceforge.net --doKZ0ri6bHmN2Q5y Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD) iQCVAwUBQBRV4D/PhmMH/Mf1AQEPCwQAmNn8FXRrIyT1HtCOpwQdz28i4MTGCKIN FLDR7YzEAiqYa9SMBpsmqbUL9N8RYtES0SzkhyEfVdAgCtYF1Ij8fwCqxLhJ4PGJ dOgf7EjWZalgQpHcwXVaQ2F6fcs6jFRpLsQrK6qZCJMh+dBEiQAWjEK2E7dsUaPq aLgwq1le3F8= =y0S+ -----END PGP SIGNATURE----- --doKZ0ri6bHmN2Q5y-- From owner-freebsd-geom@FreeBSD.ORG Sun Jan 25 20:12:25 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3624B16A4CE; Sun, 25 Jan 2004 20:12:25 -0800 (PST) Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 79C5243D3F; Sun, 25 Jan 2004 20:12:19 -0800 (PST) (envelope-from plan_b@videotron.ca) Received: from player ([24.202.183.77]) by VL-MO-MR004.ip.videotron.ca (iPlanet Messaging Server 5.2 HotFix 1.21 (built Sep 8 2003)) with SMTP id <0HS200HU0WTU7Q@VL-MO-MR004.ip.videotron.ca>; Sun, 25 Jan 2004 23:08:18 -0500 (EST) Date: Sun, 25 Jan 2004 23:09:11 -0500 From: slick To: hackers@freebsd.org, freebsd-geom@freebsd.org Message-id: MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4925.2800 X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Content-type: multipart/mixed; boundary="Boundary_(ID_ogyvznEVLFV5eupSOhg9Sg)" Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal Subject: code compatibility between normal and geom methods for accessingdisk devices X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jan 2004 04:12:25 -0000 This is a multi-part message in MIME format. --Boundary_(ID_ogyvznEVLFV5eupSOhg9Sg) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Hi, I wrote an fdisk program which uses several read(2) and write(2). My program should compile on any unix that uses sane libc. If compile it will work, except on systems that use geom methods. I read that geom is accessed via struct BIO. I can write a version of my program using struct BIO. I'm sure it will compile and work. Now should I maintain different version my program? Or should I write a set of function for each method, then some code to detect whatever method the kernel is using and use the appropriate set of functions. Also, I'm thinking, would it be a good idea to have another API to interface every other devices API. Like: Parent /dev using Master Device API Child /dev/disk using GEOM API Child /dev/net using NET API . . . . . . . . . I'm a bit confussed... plan_b@videotron.ca thanks for reading --Boundary_(ID_ogyvznEVLFV5eupSOhg9Sg) Content-type: text/plain; name=fdisk.txt; CHARSET=US-ASCII Content-transfer-encoding: 7BIT Content-disposition: attachment; filename=fdisk.txt #include #include #include #include #include #include #include int in; int out; int c = 0; int bc_size = 446; int pt_size = 66; unsigned char buffer[512]; int bc_copy(char *source, char *destination); int pt_copy(char *source, char *destination); int bc_print(char *source); int pt_print(char *source); int p_activate(char *source, char *partition); int p_type(char *source, char *partition, char *type); int ptbe_edit(char *source, char *partition, char *bc, char *bh, char *bs, char *ec, char *eh, char *es); int ptle_edit(char *source, char *partition, char *slba, char *lbas); int pt_sign(char *source); void pt_list(); void usage(); main(int argc, char **argv) { int opt; if (argc == 1) { usage(); return -1; } while ((opt = getopt(argc, argv, "a:c:C:e:E:hlp:P:S:t:u")) != -1) { switch (opt) { case 'a': if ((argc != 4)) { usage(); return -1; } p_activate(argv[2], argv[3]); break; case 'c': if ((argc != 4)) { usage(); return -1; } bc_copy(argv[2], argv[3]); break; case 'C': if ((argc != 4)) { usage(); return -1; } pt_copy(argv[2], argv[3]); break; case 'e': if ((argc != 10)) { usage(); return -1; } ptbe_edit(argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9]); break; case 'E': if ((argc != 6)) { usage(); return -1; } ptle_edit(argv[2], argv[3], argv[4], argv[5]); break; case 'h': usage(); break; case 'l': pt_list(); break; case 'p': if ((argc != 3)) { usage(); return -1; } bc_print(argv[2]); break; case 'P': if ((argc != 3)) { usage(); return -1; } pt_print(argv[2]); break; case 'S': if ((argc != 3)) { usage(); return -1; } pt_sign(argv[2]); break; case 't': if ((argc != 5)) { usage(); return -1; } p_type(argv[2], argv[3], argv[4]); break; case 'u': usage(); break; case '?': usage(); break; } argc -= optind; argv += optind; } } int p_activate(char *source, char *partition) { out = open(source, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR); while (c != 4) { lseek(out, bc_size, SEEK_SET); write(out, buffer, 1); bc_size = bc_size + 16; c++; } if ((strtoul(partition, NULL, 10) < 1) || (strtoul(partition, NULL, 10)) > 4) { printf("Partition Range: 1-4\n"); return -1; } bc_size = 430 + 16 * strtoul(partition, NULL, 10); buffer[0] = 128; lseek(out, bc_size, SEEK_SET); write(out, buffer, 1); } int bc_copy(char *source, char *destination) { in = open(source, O_RDONLY); out = open(destination, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR); read(in, buffer, bc_size); write(out, buffer, bc_size); printf("Boot Code has been transfered from %s to %s\n", source, destination); } int pt_copy(char *source, char *destination) { in = open(source, O_RDONLY); out = open(destination, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR); lseek(in, bc_size, SEEK_SET); read(in, buffer, pt_size); lseek(out, bc_size, SEEK_SET); write(out, buffer, pt_size); printf("Partition Table has been transfered from %s to %s\n", source, destination); } int ptbe_edit(char *source, char *partition, char *bc, char *bh, char *bs, char *ec, char *eh, char *es) { if ((strtoul(bc, NULL, 10) > 1024) || (strtoul(ec, NULL, 10) > 1024)) { printf("Maximum Cylinder value: 1024\n"); return -1; } if ((strtoul(bh, NULL, 10) > 255) || (strtoul(eh, NULL, 10) > 255)) { printf("Maximum Head value: 255\n"); return -1; } if ((strtoul(bs, NULL, 10) > 63) || (strtoul(es, NULL, 10) > 63)) { printf("Maximum Sector value: 63\n"); return -1; } if ((strtoul(partition, NULL, 10) < 1) || (strtoul(partition, NULL, 10) > 4)) { printf("Partition Range: 1-4\n"); return -1; } bc_size = 430 + 16 * strtoul(partition, NULL, 10); in = open(source, O_RDONLY); lseek(in, bc_size, SEEK_SET); read(in, buffer, 8); buffer[1] = strtoul(bh, NULL, 10); buffer[2] = (strtoul(bs, NULL, 10) + ((strtoul(bc, NULL, 10) & 768) >> 2)); buffer[3] = (strtoul(bc, NULL, 10) & 255); buffer[5] = strtoul(eh, NULL, 10); buffer[6] = (strtoul(es, NULL, 10) + ((strtoul(ec, NULL, 10) & 768) >> 2)); buffer[7] = (strtoul(ec, NULL, 10) & 255); out = open(source, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR); lseek(out, bc_size, SEEK_SET); write(out, buffer, 8); } int ptle_edit(char *source, char *partition, char *slba, char *lbas) { if (strtoul(slba, NULL, 10) > 2000000000) { printf("Maximum Starting LBA value: 2000000000\n"); return -1; } if (strtoul(lbas, NULL, 10) > 2000000000) { printf("Maximum LBA Size value: 2000000000\n"); return -1; } if ((strtoul(partition, NULL, 10) < 1) || (strtoul(partition, NULL, 10) > 4)) { printf("Partition Range: 1-4\n"); return -1; } bc_size = 438 + 16 * strtoul(partition, NULL, 10); buffer[0] = (strtoul(slba, NULL, 10) & 255); buffer[1] = ((strtoul(slba, NULL, 10) & 65280) >> 8); buffer[2] = ((strtoul(slba, NULL, 10) & 16711680) >> 16); buffer[3] = (strtoul(slba, NULL, 10) >> 24); buffer[4] = (strtoul(lbas, NULL, 10) & 255); buffer[5] = ((strtoul(lbas, NULL, 10) & 65280) >> 8); buffer[6] = ((strtoul(lbas, NULL, 10) & 16711680) >> 16); buffer[7] = (strtoul(lbas, NULL, 10) >> 24); out = open(source, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR); lseek(out, bc_size, SEEK_SET); write(out, buffer, 8); } int bc_print(char *source) { int bc = 0; in = open(source, O_RDONLY); read(in, buffer, bc_size); for (c; c < bc_size; c++) { if (bc == 16) { bc = 0; printf("\n"); } printf("%02x", buffer[c]); bc++; } printf("\n"); } int pt_print(char *source) { in = open(source, O_RDONLY); printf("\n"); while ( c != 4) { lseek(in, bc_size, SEEK_SET); read(in, buffer, 16); printf("Partition %2d is active %02x, type %02x, LBA start %d and LBA size %d\n", (c + 1), buffer[0], buffer[4], buffer[8] + (buffer[9] * 256) + (buffer[10] * 65536) + (buffer[11] * 16777216), buffer[12] + (buffer[13] * 256) + (buffer[14] * 65536) + (buffer[15] * 16777216)); printf("Beginning: %4d cylinder, %3d head, %2d sector\n", (((buffer[2] & 0xc0) << 2) + buffer[3]), buffer[1], (buffer[2] & 0x3f)); printf("Ending: %4d cylinder, %3d head, %2d sector\n\n", (((buffer[6] & 0xc0) << 2) + buffer[7]), buffer[5], (buffer[6] & 0x3f)); bc_size = bc_size + 16; c++; } } int p_type(char *source, char *partition, char *type) { if (strtoul(type, NULL, 10) > 255) { printf("Wrong Partition Type.\n"); pt_list(); return -1; } if ((strtoul(partition, NULL, 10) < 1) || (strtoul(partition, NULL, 10) > 4)) { printf("Partition Range: 1-4\n"); return -1; } bc_size = 434 + 16 * strtoul(partition, NULL, 10); buffer[0] = strtoul(type, NULL, 10); out = open(source, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR); lseek(out, bc_size, SEEK_SET); write(out, buffer, 1); } int pt_sign(char *source) { buffer[0] = 85; buffer[1] = 170; out = open(source, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR); lseek(out, 510, SEEK_SET); write(out, buffer, 2); } void pt_list() { printf("\n"); printf("00 Empty\n"); printf("01 12-bit FAT primary partition\n"); printf("04 16-bit FAT primary partition\n"); printf("05 Extended partition\n"); printf("06 BIGDOS FAT primary partition\n"); printf("07 NTFS primary partition\n"); printf("63 Unix System V (SCO, ISC Unix, UnixWare, ...), Mach, GNU Hurd\n"); printf("64 Novell Netware 286, 2.xx\n"); printf("65 Novell Netware 386, 3.xx or 4.xx\n"); printf("69 Novell Netware 5+, Novell Netware NSS Partition\n"); printf("82 Linux swap\n"); printf("83 Linux native partition\n"); printf("84 Hibernation partition\n"); printf("85 Linux extended partition\n"); printf("86 NTFS volume set\n"); printf("87 NTFS volume set\n"); printf("8b Legacy Fault Tolerant FAT32 volume\n"); printf("8c Legacy Fault Tolerant FAT32 volume using BIOS extended INT 13h\n"); printf("a0 Laptop hibernation partition\n"); printf("a5 NetBSD, FreeBSD, 386BSD\n"); printf("a6 OpenBSD\n"); printf("a9 NetBSD\n"); printf("eb BeOS\n"); printf("fb VMWare File System partition\n"); printf("fc VMWare Swap partition\n"); printf("\n"); } void usage() { printf("\n"); printf("fdisk - Partition Manager\n"); printf("\n"); printf("SYNOPSYS\n"); printf(" fdisk [-a:c:C:e:E:hlp:P:t:] [source] [destination] [partition] [type] [CHS start, CHS end] [LBA start, LBA size]\n"); printf("\n"); printf(" -a Activate [partition] on [source].\n"); printf(" -c Copy Boot Code from [source] to [destination].\n"); printf(" -C Copy Partition Table from [source] to [destination].\n"); printf(" -e Edit [partition] CHS parameters on [source].\n"); printf(" -E Edit [partition] LBA parameters on [source].\n"); printf(" -h Print help.\n"); printf(" -l Print Partition Type list.\n"); printf(" -p Print Boot Code from [source].\n"); printf(" -P Print Partition Table from [source].\n"); printf(" -S Sign the Partition Table.\n"); printf(" -t Change [partition] [type] on [source].\n"); printf(" -u Print help.\n"); printf("\n"); } --Boundary_(ID_ogyvznEVLFV5eupSOhg9Sg) Content-type: application/octet-stream; name=fdisk.c Content-transfer-encoding: quoted-printable Content-disposition: attachment; filename=fdisk.c #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= =0A= int in;=0A= int out;=0A= int c =3D 0;=0A= int bc_size =3D 446;=0A= int pt_size =3D 66;=0A= unsigned char buffer[512];=0A= =0A= int bc_copy(char *source, char *destination);=0A= int pt_copy(char *source, char *destination);=0A= int bc_print(char *source);=0A= int pt_print(char *source);=0A= int p_activate(char *source, char *partition);=0A= int p_type(char *source, char *partition, char *type);=0A= int ptbe_edit(char *source, char *partition, char *bc, char *bh, char = *bs, char *ec, char *eh, char *es);=0A= int ptle_edit(char *source, char *partition, char *slba, char *lbas);=0A= int pt_sign(char *source);=0A= void pt_list();=0A= void usage();=0A= =0A= main(int argc, char **argv) {=0A= int opt;=0A= if (argc =3D=3D 1) { usage(); return -1; }=0A= while ((opt =3D getopt(argc, argv, "a:c:C:e:E:hlp:P:S:t:u")) !=3D -1) {=0A= switch (opt) {=0A= case 'a':=0A= if ((argc !=3D 4)) {=0A= usage();=0A= return -1;=0A= }=0A= p_activate(argv[2], argv[3]);=0A= break;=0A= case 'c':=0A= if ((argc !=3D 4)) {=0A= usage();=0A= return -1;=0A= }=0A= bc_copy(argv[2], argv[3]);=0A= break;=0A= case 'C':=0A= if ((argc !=3D 4)) {=0A= usage();=0A= return -1;=0A= }=0A= pt_copy(argv[2], argv[3]);=0A= break;=0A= case 'e':=0A= if ((argc !=3D 10)) {=0A= usage();=0A= return -1;=0A= }=0A= ptbe_edit(argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], = argv[8], argv[9]);=0A= break;=0A= case 'E':=0A= if ((argc !=3D 6)) {=0A= usage();=0A= return -1;=0A= }=0A= ptle_edit(argv[2], argv[3], argv[4], argv[5]);=0A= break;=0A= case 'h':=0A= usage();=0A= break;=0A= case 'l':=0A= pt_list();=0A= break;=0A= case 'p':=0A= if ((argc !=3D 3)) {=0A= usage();=0A= return -1;=0A= }=0A= bc_print(argv[2]);=0A= break;=0A= case 'P':=0A= if ((argc !=3D 3)) {=0A= usage();=0A= return -1;=0A= }=0A= pt_print(argv[2]);=0A= break;=0A= case 'S':=0A= if ((argc !=3D 3)) {=0A= usage();=0A= return -1;=0A= }=0A= pt_sign(argv[2]);=0A= break;=0A= case 't':=0A= if ((argc !=3D 5)) {=0A= usage();=0A= return -1;=0A= }=0A= p_type(argv[2], argv[3], argv[4]);=0A= break;=0A= case 'u':=0A= usage();=0A= break;=0A= case '?':=0A= usage();=0A= break;=0A= }=0A= argc -=3D optind;=0A= argv +=3D optind;=0A= }=0A= }=0A= =0A= int p_activate(char *source, char *partition) {=0A= out =3D open(source, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);=0A= while (c !=3D 4) {=0A= lseek(out, bc_size, SEEK_SET);=0A= write(out, buffer, 1);=0A= bc_size =3D bc_size + 16;=0A= c++;=0A= }=0A= if ((strtoul(partition, NULL, 10) < 1) || (strtoul(partition, NULL, = 10)) > 4) { printf("Partition Range: 1-4\n"); return -1; }=0A= bc_size =3D 430 + 16 * strtoul(partition, NULL, 10);=0A= buffer[0] =3D 128;=0A= lseek(out, bc_size, SEEK_SET);=0A= write(out, buffer, 1);=0A= }=0A= =0A= int bc_copy(char *source, char *destination) {=0A= in =3D open(source, O_RDONLY);=0A= out =3D open(destination, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);=0A= read(in, buffer, bc_size);=0A= write(out, buffer, bc_size);=0A= printf("Boot Code has been transfered from %s to %s\n", source, = destination);=0A= }=0A= =0A= int pt_copy(char *source, char *destination) {=0A= in =3D open(source, O_RDONLY);=0A= out =3D open(destination, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);=0A= lseek(in, bc_size, SEEK_SET);=0A= read(in, buffer, pt_size);=0A= lseek(out, bc_size, SEEK_SET);=0A= write(out, buffer, pt_size);=0A= printf("Partition Table has been transfered from %s to %s\n", source, = destination);=0A= }=0A= =0A= int ptbe_edit(char *source, char *partition, char *bc, char *bh, char = *bs, char *ec, char *eh, char *es) {=0A= if ((strtoul(bc, NULL, 10) > 1024) || (strtoul(ec, NULL, 10) > 1024)) {=0A= printf("Maximum Cylinder value: 1024\n");=0A= return -1;=0A= }=0A= if ((strtoul(bh, NULL, 10) > 255) || (strtoul(eh, NULL, 10) > 255)) {=0A= printf("Maximum Head value: 255\n");=0A= return -1;=0A= }=0A= if ((strtoul(bs, NULL, 10) > 63) || (strtoul(es, NULL, 10) > 63)) {=0A= printf("Maximum Sector value: 63\n");=0A= return -1;=0A= }=0A= if ((strtoul(partition, NULL, 10) < 1) || (strtoul(partition, NULL, 10) = > 4)) { printf("Partition Range: 1-4\n"); return -1; }=0A= bc_size =3D 430 + 16 * strtoul(partition, NULL, 10);=0A= in =3D open(source, O_RDONLY);=0A= lseek(in, bc_size, SEEK_SET);=0A= read(in, buffer, 8);=0A= buffer[1] =3D strtoul(bh, NULL, 10);=0A= buffer[2] =3D (strtoul(bs, NULL, 10) + ((strtoul(bc, NULL, 10) & 768) = >> 2));=0A= buffer[3] =3D (strtoul(bc, NULL, 10) & 255);=0A= buffer[5] =3D strtoul(eh, NULL, 10);=0A= buffer[6] =3D (strtoul(es, NULL, 10) + ((strtoul(ec, NULL, 10) & 768) = >> 2));=0A= buffer[7] =3D (strtoul(ec, NULL, 10) & 255);=0A= out =3D open(source, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);=0A= lseek(out, bc_size, SEEK_SET);=0A= write(out, buffer, 8);=0A= }=0A= =0A= int ptle_edit(char *source, char *partition, char *slba, char *lbas) {=0A= if (strtoul(slba, NULL, 10) > 2000000000) {=0A= printf("Maximum Starting LBA value: 2000000000\n");=0A= return -1;=0A= }=0A= if (strtoul(lbas, NULL, 10) > 2000000000) {=0A= printf("Maximum LBA Size value: 2000000000\n");=0A= return -1;=0A= }=0A= if ((strtoul(partition, NULL, 10) < 1) || (strtoul(partition, NULL, 10) = > 4)) { printf("Partition Range: 1-4\n"); return -1; }=0A= bc_size =3D 438 + 16 * strtoul(partition, NULL, 10);=0A= buffer[0] =3D (strtoul(slba, NULL, 10) & 255);=0A= buffer[1] =3D ((strtoul(slba, NULL, 10) & 65280) >> 8);=0A= buffer[2] =3D ((strtoul(slba, NULL, 10) & 16711680) >> 16);=0A= buffer[3] =3D (strtoul(slba, NULL, 10) >> 24);=0A= buffer[4] =3D (strtoul(lbas, NULL, 10) & 255);=0A= buffer[5] =3D ((strtoul(lbas, NULL, 10) & 65280) >> 8);=0A= buffer[6] =3D ((strtoul(lbas, NULL, 10) & 16711680) >> 16);=0A= buffer[7] =3D (strtoul(lbas, NULL, 10) >> 24);=0A= out =3D open(source, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);=0A= lseek(out, bc_size, SEEK_SET);=0A= write(out, buffer, 8);=0A= }=0A= =0A= int bc_print(char *source) {=0A= int bc =3D 0;=0A= in =3D open(source, O_RDONLY);=0A= read(in, buffer, bc_size);=0A= for (c; c < bc_size; c++) {=0A= if (bc =3D=3D 16) {=0A= bc =3D 0;=0A= printf("\n");=0A= }=0A= printf("%02x", buffer[c]);=0A= bc++;=0A= }=0A= printf("\n");=0A= }=0A= =0A= int pt_print(char *source) {=0A= in =3D open(source, O_RDONLY);=0A= printf("\n");=0A= while ( c !=3D 4) {=0A= lseek(in, bc_size, SEEK_SET);=0A= read(in, buffer, 16);=0A= printf("Partition %2d is active %02x, type %02x, LBA start %d and LBA = size %d\n", (c + 1), buffer[0], buffer[4], buffer[8] + (buffer[9] * 256) = + (buffer[10] * 65536) + (buffer[11] * 16777216), buffer[12] + = (buffer[13] * 256) + (buffer[14] * 65536) + (buffer[15] * 16777216));=0A= printf("Beginning: %4d cylinder, %3d head, %2d sector\n", (((buffer[2] = & 0xc0) << 2) + buffer[3]), buffer[1], (buffer[2] & 0x3f));=0A= printf("Ending: %4d cylinder, %3d head, %2d sector\n\n", = (((buffer[6] & 0xc0) << 2) + buffer[7]), buffer[5], (buffer[6] & 0x3f));=0A= bc_size =3D bc_size + 16;=0A= c++;=0A= }=0A= }=0A= =0A= int p_type(char *source, char *partition, char *type) {=0A= if (strtoul(type, NULL, 10) > 255) { printf("Wrong Partition Type.\n"); = pt_list(); return -1; }=0A= if ((strtoul(partition, NULL, 10) < 1) || (strtoul(partition, NULL, 10) = > 4)) { printf("Partition Range: 1-4\n"); return -1; }=0A= bc_size =3D 434 + 16 * strtoul(partition, NULL, 10);=0A= buffer[0] =3D strtoul(type, NULL, 10);=0A= out =3D open(source, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);=0A= lseek(out, bc_size, SEEK_SET);=0A= write(out, buffer, 1);=0A= }=0A= =0A= int pt_sign(char *source) {=0A= buffer[0] =3D 85;=0A= buffer[1] =3D 170;=0A= out =3D open(source, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);=0A= lseek(out, 510, SEEK_SET);=0A= write(out, buffer, 2);=0A= }=0A= =0A= void pt_list() {=0A= printf("\n");=0A= printf("00 Empty\n");=0A= printf("01 12-bit FAT primary partition\n");=0A= printf("04 16-bit FAT primary partition\n");=0A= printf("05 Extended partition\n");=0A= printf("06 BIGDOS FAT primary partition\n");=0A= printf("07 NTFS primary partition\n");=0A= printf("63 Unix System V (SCO, ISC Unix, UnixWare, ...), Mach, GNU = Hurd\n");=0A= printf("64 Novell Netware 286, 2.xx\n");=0A= printf("65 Novell Netware 386, 3.xx or 4.xx\n");=0A= printf("69 Novell Netware 5+, Novell Netware NSS Partition\n");=0A= printf("82 Linux swap\n");=0A= printf("83 Linux native partition\n");=0A= printf("84 Hibernation partition\n");=0A= printf("85 Linux extended partition\n");=0A= printf("86 NTFS volume set\n");=0A= printf("87 NTFS volume set\n");=0A= printf("8b Legacy Fault Tolerant FAT32 volume\n");=0A= printf("8c Legacy Fault Tolerant FAT32 volume using BIOS extended INT = 13h\n");=0A= printf("a0 Laptop hibernation partition\n");=0A= printf("a5 NetBSD, FreeBSD, 386BSD\n");=0A= printf("a6 OpenBSD\n");=0A= printf("a9 NetBSD\n");=0A= printf("eb BeOS\n");=0A= printf("fb VMWare File System partition\n");=0A= printf("fc VMWare Swap partition\n");=0A= printf("\n");=0A= }=0A= =0A= void usage() {=0A= printf("\n");=0A= printf("fdisk - Partition Manager\n");=0A= printf("\n");=0A= printf("SYNOPSYS\n");=0A= printf(" fdisk [-a:c:C:e:E:hlp:P:t:] [source] [destination] = [partition] [type] [CHS start, CHS end] [LBA start, LBA size]\n");=0A= printf("\n");=0A= printf(" -a Activate [partition] on [source].\n");=0A= printf(" -c Copy Boot Code from [source] to = [destination].\n");=0A= printf(" -C Copy Partition Table from [source] to = [destination].\n");=0A= printf(" -e Edit [partition] CHS parameters on [source].\n");=0A= printf(" -E Edit [partition] LBA parameters on [source].\n");=0A= printf(" -h Print help.\n");=0A= printf(" -l Print Partition Type list.\n");=0A= printf(" -p Print Boot Code from [source].\n");=0A= printf(" -P Print Partition Table from [source].\n");=0A= printf(" -S Sign the Partition Table.\n");=0A= printf(" -t Change [partition] [type] on [source].\n");=0A= printf(" -u Print help.\n");=0A= printf("\n");=0A= }=0A= --Boundary_(ID_ogyvznEVLFV5eupSOhg9Sg)-- From owner-freebsd-geom@FreeBSD.ORG Sun Jan 25 22:28:09 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4387B16A4CE; Sun, 25 Jan 2004 22:28:09 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id C410C43D31; Sun, 25 Jan 2004 22:28:07 -0800 (PST) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.10/8.12.10) with ESMTP id i0Q6RxuO062002; Mon, 26 Jan 2004 07:28:05 +0100 (CET) (envelope-from phk@phk.freebsd.dk) To: slick From: "Poul-Henning Kamp" In-Reply-To: Your message of "Sun, 25 Jan 2004 23:09:11 EST." Date: Mon, 26 Jan 2004 07:27:59 +0100 Message-ID: <62001.1075098479@critter.freebsd.dk> cc: hackers@freebsd.org cc: freebsd-geom@freebsd.org Subject: Re: code compatibility between normal and geom methods for accessingdisk devices X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jan 2004 06:28:09 -0000 In message , slick writes: > I wrote an fdisk program which uses several read(2) and write(2). You program needs to realize that disks have sectors. You cannot read a single byte from a disk at a time, you need to read an entire sector and pick the byte out you want. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From owner-freebsd-geom@FreeBSD.ORG Mon Jan 26 07:53:15 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8FD3516A4CE for ; Mon, 26 Jan 2004 07:53:15 -0800 (PST) Received: from mailbox.univie.ac.at (mailbox.univie.ac.at [131.130.1.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8756C43D90 for ; Mon, 26 Jan 2004 07:52:17 -0800 (PST) (envelope-from l.ertl@univie.ac.at) Received: from pcle2.cc.univie.ac.at (pcle2.cc.univie.ac.at [131.130.2.177]) i0QFocL9337626; Mon, 26 Jan 2004 16:50:41 +0100 Date: Mon, 26 Jan 2004 16:50:38 +0100 (CET) From: Lukas Ertl To: Pawel Jakub Dawidek In-Reply-To: <20040125234848.GH565@garage.freebsd.pl> Message-ID: <20040126164924.C90355@pcle2.cc.univie.ac.at> References: <20040125234848.GH565@garage.freebsd.pl> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-DCC-ZID-Univie-Metrics: imap 4245; Body=0 Fuz1=0 Fuz2=0 cc: freebsd-geom@freebsd.org Subject: Re: Preventing deadlocks on the event queue. X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jan 2004 15:53:15 -0000 On Mon, 26 Jan 2004, Pawel Jakub Dawidek wrote: > Hello. > > So, I think I've found clever way to prevents deadlock caused by > calling g_waitfor_event() from an event. > > My idea is to check if curthread in g_waitfor_event() is a g_event thread. > > http://garage.freebsd.pl/patches/geom_event_deadlock.patch Do you really want to make this a separate function? Since it's just a one-line comparison, wouldn't a macro suffice? regards, le -- Lukas Ertl eMail: l.ertl@univie.ac.at UNIX Systemadministrator Tel.: (+43 1) 4277-14073 Vienna University Computer Center Fax.: (+43 1) 4277-9140 University of Vienna http://mailbox.univie.ac.at/~le/ From owner-freebsd-geom@FreeBSD.ORG Mon Jan 26 08:12:10 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9387416A4CE for ; Mon, 26 Jan 2004 08:12:10 -0800 (PST) Received: from milla.ask33.net (milla.ask33.net [217.197.166.60]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7E69143D5E for ; Mon, 26 Jan 2004 08:12:02 -0800 (PST) (envelope-from nick@milla.ask33.net) Received: by milla.ask33.net (Postfix, from userid 1001) id C9B903ABB51; Mon, 26 Jan 2004 17:13:00 +0100 (CET) Date: Mon, 26 Jan 2004 17:13:00 +0100 From: Pawel Jakub Dawidek To: Lukas Ertl Message-ID: <20040126161300.GJ565@garage.freebsd.pl> References: <20040125234848.GH565@garage.freebsd.pl> <20040126164924.C90355@pcle2.cc.univie.ac.at> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="J+eNKFoVC4T1DV3f" Content-Disposition: inline In-Reply-To: <20040126164924.C90355@pcle2.cc.univie.ac.at> X-PGP-Key-URL: http://garage.freebsd.pl/jules.asc X-OS: FreeBSD 4.8-RELEASE-p13 i386 X-URL: http://garage.freebsd.pl User-Agent: Mutt/1.5.1i cc: freebsd-geom@freebsd.org Subject: Re: Preventing deadlocks on the event queue. X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jan 2004 16:12:10 -0000 --J+eNKFoVC4T1DV3f Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 26, 2004 at 04:50:38PM +0100, Lukas Ertl wrote: +> > So, I think I've found clever way to prevents deadlock caused by +> > calling g_waitfor_event() from an event. +> > +> > My idea is to check if curthread in g_waitfor_event() is a g_event thr= ead. +> > +> > http://garage.freebsd.pl/patches/geom_event_deadlock.patch +>=20 +> Do you really want to make this a separate function? Since it's just a +> one-line comparison, wouldn't a macro suffice? I want to avoid exporting 'g_event_proc' from geom_kern.c (it is declareted staticaly there). --=20 Pawel Jakub Dawidek pawel@dawidek.net UNIX Systems Programmer/Administrator http://garage.freebsd.pl Am I Evil? Yes, I Am! http://cerber.sourceforge.net --J+eNKFoVC4T1DV3f Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD) iQCVAwUBQBU8jD/PhmMH/Mf1AQEOjwQAiCGlv4I//+SCIlo4E/2UR9x01qEIJLU0 Z6gDU0dj6OJImVCdj3mih3/0C9KWaeQCRx/BrU9rkxZ0Ji9dcsIb5moP/oxMifwr +F/lBc57rZQdiD/iOOzz3e3hzNgjRAWgwSQ2Vdi4fNpZklZjFNKMtAe6B9DTnnEE o6aBr0LllAM= =Yah5 -----END PGP SIGNATURE----- --J+eNKFoVC4T1DV3f-- From owner-freebsd-geom@FreeBSD.ORG Mon Jan 26 08:15:41 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 804DD16A4CE for ; Mon, 26 Jan 2004 08:15:41 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id E0AA843D31 for ; Mon, 26 Jan 2004 08:15:39 -0800 (PST) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.10/8.12.10) with ESMTP id i0QGFbuO066985; Mon, 26 Jan 2004 17:15:37 +0100 (CET) (envelope-from phk@phk.freebsd.dk) To: Pawel Jakub Dawidek From: "Poul-Henning Kamp" In-Reply-To: Your message of "Mon, 26 Jan 2004 17:13:00 +0100." <20040126161300.GJ565@garage.freebsd.pl> Date: Mon, 26 Jan 2004 17:15:37 +0100 Message-ID: <66984.1075133737@critter.freebsd.dk> cc: freebsd-geom@freebsd.org cc: Lukas Ertl Subject: Re: Preventing deadlocks on the event queue. X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jan 2004 16:15:41 -0000 In message <20040126161300.GJ565@garage.freebsd.pl>, Pawel Jakub Dawidek writes >On Mon, Jan 26, 2004 at 04:50:38PM +0100, Lukas Ertl wrote: >+> > So, I think I've found clever way to prevents deadlock caused by >+> > calling g_waitfor_event() from an event. >+> > >+> > My idea is to check if curthread in g_waitfor_event() is a g_event thr= >ead. >+> > >+> > http://garage.freebsd.pl/patches/geom_event_deadlock.patch >+>=20 >+> Do you really want to make this a separate function? Since it's just a >+> one-line comparison, wouldn't a macro suffice? > >I want to avoid exporting 'g_event_proc' from geom_kern.c (it is declareted >staticaly there). Right, g_event_proc should stay local to geom_kern.c if at all possible. I'm still trying to see if I can find a more elegant way to do it, but curproc/curthread is probably the trick. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From owner-freebsd-geom@FreeBSD.ORG Mon Jan 26 08:51:50 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4318D16A4CE for ; Mon, 26 Jan 2004 08:51:50 -0800 (PST) Received: from mailbox.univie.ac.at (mailbox.univie.ac.at [131.130.1.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id D03E643D45 for ; Mon, 26 Jan 2004 08:51:48 -0800 (PST) (envelope-from l.ertl@univie.ac.at) Received: from wireless (adslle.cc.univie.ac.at [131.130.102.11]) i0QGpfaO362016; Mon, 26 Jan 2004 17:51:43 +0100 Date: Mon, 26 Jan 2004 17:51:32 +0100 (CET) From: Lukas Ertl To: Pawel Jakub Dawidek In-Reply-To: <20040126161300.GJ565@garage.freebsd.pl> Message-ID: <20040126175100.W619@korben.in.tern> References: <20040125234848.GH565@garage.freebsd.pl> <20040126161300.GJ565@garage.freebsd.pl> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-DCC-ZID-Univie-Metrics: imap 4243; Body=0 Fuz1=0 Fuz2=0 cc: freebsd-geom@freebsd.org Subject: Re: Preventing deadlocks on the event queue. X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jan 2004 16:51:50 -0000 On Mon, 26 Jan 2004, Pawel Jakub Dawidek wrote: > On Mon, Jan 26, 2004 at 04:50:38PM +0100, Lukas Ertl wrote: > +> > +> Do you really want to make this a separate function? Since it's just a > +> one-line comparison, wouldn't a macro suffice? > > I want to avoid exporting 'g_event_proc' from geom_kern.c (it is declareted > staticaly there). Ah, yes, sorry, I missed the fact that the function would end up in geom_kern.c. regards, le -- Lukas Ertl eMail: l.ertl@univie.ac.at UNIX Systemadministrator Tel.: (+43 1) 4277-14073 Vienna University Computer Center Fax.: (+43 1) 4277-9140 University of Vienna http://mailbox.univie.ac.at/~le/