From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KQPXJ-00005p-Vk for mharc-grub-devel@gnu.org; Tue, 05 Aug 2008 12:37:26 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KQPXI-0008VG-2T for grub-devel@gnu.org; Tue, 05 Aug 2008 12:37:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KQPXF-0008Sb-Lj for grub-devel@gnu.org; Tue, 05 Aug 2008 12:37:23 -0400 Received: from [199.232.76.173] (port=43616 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KQPXF-0008S3-ED for grub-devel@gnu.org; Tue, 05 Aug 2008 12:37:21 -0400 Received: from ug-out-1314.google.com ([66.249.92.171]:4558) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KQPXD-0003W8-RZ for grub-devel@gnu.org; Tue, 05 Aug 2008 12:37:21 -0400 Received: by ug-out-1314.google.com with SMTP id l31so89904ugc.48 for ; Tue, 05 Aug 2008 09:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:in-reply-to :references:content-type:date:message-id:mime-version:x-mailer; bh=OTsHcZyEAUKkv8V+bjNeLNn5jr9aB+Qo5L4drXKKfZY=; b=hc6VR3aoA+q1P/tQt3BQb4RbUre3hlz3zE0g7uAjkCQe35LRU3Cy73t1CNNKeE3TyK klCeDb0mq6bhuD/XUoNGanh18QfO2ZXTZiPDEz5MdjlUsYP0omJ1k8PF8ttqIwTqQaBD ZS/SOi/SpuiV/i9CW5NcOMPMofNyl1XRfZ4d4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:in-reply-to:references:content-type:date:message-id :mime-version:x-mailer; b=npWmvPwJiP9KOzmFg7lFeYz9+VLTO41jEYCww6MxypzZJ9o0o+KIK2CCjFgm48kTk3 qisCN1onYXEpQHPByJF4TFuwQpe9e11wBP3MSlXG5nqIM8oF//jAaggcmGyRR6qvB1j0 9Kl3o4byulgPbx/iaDPtOlYdbQR8GCowmYjiM= Received: by 10.67.116.15 with SMTP id t15mr7125339ugm.53.1217954237841; Tue, 05 Aug 2008 09:37:17 -0700 (PDT) Received: from ?192.168.1.100? ( [213.37.137.93]) by mx.google.com with ESMTPS id 28sm316509ugc.79.2008.08.05.09.37.11 (version=SSLv3 cipher=RC4-MD5); Tue, 05 Aug 2008 09:37:16 -0700 (PDT) From: Javier =?ISO-8859-1?Q?Mart=EDn?= To: The development of GRUB 2 In-Reply-To: <87vdyfem5k.fsf@xs4all.nl> References: <1215137528.26019.58.camel@localhost> <87bq0sibu0.fsf@xs4all.nl> <1216601741.8334.122.camel@localhost> <877ib1khe9.fsf@xs4all.nl> <1217806150.9634.24.camel@localhost> <87iqug33m9.fsf@xs4all.nl> <1217891426.15145.38.camel@localhost> <87vdyfem5k.fsf@xs4all.nl> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-TDl1TDumuDD/eOqaK2qY" Date: Tue, 05 Aug 2008 18:39:41 +0200 Message-Id: <1217954381.14674.31.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) Subject: Re: [PATCH] Drivemap module X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Aug 2008 16:37:24 -0000 --=-TDl1TDumuDD/eOqaK2qY Content-Type: multipart/mixed; boundary="=-Zl4AbXwRtMXPWLC5S+/c" --=-Zl4AbXwRtMXPWLC5S+/c Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ok, I will reply to your last three messages on a single post: Hi there! =EF=BB=BFEl mar, 05-08-2008 a las 13:31 +0200, Marco Gerards escribi=C3=B3:= =20 > Hi, >=20 > Javier Mart=C3=ADn writes: >=20 > >> Anyway, since "they" are more likely to maintain the code in=20 > >> the long run than you, in general, the question is whether=20 > >> the code is more likely to become buggy by their hacking on=20 > >> it, if it follows project coding style or someone else's=20 > >> (your) "safer" coding style. Likely it's safer if using a=20 > >> consistent programming style. Although I personally don't=20 > >> see that it's very helpful to have a style that makes things=20 > >> down to the order of "=3D=3D" arguments be consistent within the=20 > >> project; haphazard only slows reading the tiniest bit, and I=20 > >> don't think it makes a different what order the arguments are... > > =EF=BB=BF > > Hmm... I was partially expecting a flamefest to start. Pity ^^ > > Well, let's spill a little napalm: the GNU style bracing is extremely > > silly!! Why the hell are the "if" and "else" blocks indented differentl= y > > in this example? > > if (condition) > > return 0; > > else > > { > > return -1; > > } > > Nah, I'm not really bringing that issue, I was just joking, and in fact > > I'm reconsidering my objections to the operator=3D=3D arguments order r= ule, > > even though I still consider my style safer and more sensible. If > > someone else wants to express their opinion on that issue, do it fast > > before I completely submit to Master Marco's will :D >=20 > Please don't be sarcastic, start flame wars or call names. It will not > help anyone. Ok, sorry, picturing you as a whip-cracking dominatrix was really not prope= r ^^. I was just joking about how fast can flamewars be started. >=20 > -- > Marco >=20 >=20 >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel =EF=BB=BF El mar, 05-08-2008 a las 13:23 +0200, Marco Gerards escribi=C3=B3: > Hi Javier, >=20 > Javier Mart=C3=ADn writes: >=20 > > El lun, 04-08-2008 a las 22:51 +0200, Marco Gerards escribi=C3=B3: > >> Javier Mart=C3=ADn writes: > >>=20 > >> > After your latest replay, I "reevaluated" my stubbornness WRT some o= f > >> > your advices, and I've changed a few things: > >> > > >> > - Variables are now declared (and, if possible, initialized) before > >> > precondition checks, even simple ones. The install_int13_handler > >> > function has not been modified, however, since I find it a bit > >> > nonsensical to put bunch of declarations without an obvious meaning = just > >> > after the "else" line: > >> > grub_uint32_t *ivtslot; > >> > grub_uint16_t *bpa_freekb; > >> > grub_size_t total_size; > >> > grub_uint16_t payload_sizekb; > >> > grub_uint8_t *handler_base; > >> > int13map_node_t *handler_map; > >> > grub_uint32_t ivtentry; > >>=20 > >> Please understand me correctly. Code just has to be written according > >> to our coding standards before it can and will be included. We can > >> discuss things endlessly but we will simply stick to the GNU Coding > >> Standards as you might expect. > >>=20 > >> I hope you can appreciate that all code of GRUB has the same coding > >> style, if you like this style or not. > > Big sigh. Function modified to conform to your preciousss coding style. > > I might look a bit childish or arrogant saying this, but what is the > > point upholding a coding style that, no matter how consistent it is, > > hinders readability. With so much local variables, they are hard to kee= p > > track of no matter the coding style, but with the old ("mixed, heretic"= ) > > style there was not need for a comment before each declaration: they > > were declared and used when needed instead of at the start of a block, > > because that function is inherently linear, not block-structured. >=20 > In your opinion it is not a good coding style. I just avoid > discussions about it because such discussions just waste my time. > Even if you are able to convince me, GRUB is a GNU project and will > remain to use the GCS. Which is fine, but the order of the arguments to =3D=3D is specified nowher= e in the GCS: the order you defend only appears in examples less than five = times. Thus, your insistence is a matter of internal consistence within GRU= B and is only based on examples in the GCS. Additionally, your previous sug= gestion to change checks line "entries =3D=3D 0 " to "!entries" are _agains= t_ the examples of the GCS, even for pointers. Then, given that the _examples_ in the GCS are non-authoritative, I was adv= ocating a simple change for better resilience against future changes. You w= ant to keep consistency with the current sources, and that I understand, so= I will perform the required trivial changes in my code to use the style us= ed in other GRUB code, but I still think it is worse and more error-prone. >=20 >=20 > >> > - Only one declaration per line: even though C is a bit absurd in no= t > >> > recognizing T* as a first class type and instead thinking of * as a > >> > qualifier to the variable name; and even though my code does not inc= ur > >> > into such ambiguities. > >> > - Comments moved as you required, reworded as needed > >> > - Extensive printf showing quasi-help in the "show" mode trimmed dow= n to > >> > just the first sentence. > >> > - Internal helper functions now use the standard error handling, i.e= . > >> > return grub_error (err, fmt, ...) > >> > - Comment about the strange "void" type instead of "void*" rephrased= to > >> > be clearer > >>=20 > >> Thanks a lot! > >>=20 > >> > There is, however, one point in which I keep my objection: compariso= ns > >> > between a variable and a constant should be of the form CONSTANT =3D= =3D > >> > variable and not in the reverse order, since an erroneous but quite > >> > possible change of =3D=3D for =3D results in a compile-time error in= stead of a > >> > _extremely_ difficult to trace runtime bug. Such kind of bugs are qu= ite > >> > excruciating to find in userspace applications within an IDE, so I c= an't > >> > even consider the pain to debug them in a bootloader. > >>=20 > >> I understand your concern, nevertheless, can you please change it? > > You understand my concern, but seemingly do not understand that in orde= r > > to conform to the Holy Coding Style you are asking me to write code tha= t > > can become buggy (and with a very hard to trace bug) with a simple > > deltion! (point: did you notice that last word _without_ a spelling > > checker? Now try to do so in a multithousand-line program). >=20 > Yes, I did notice it immediately. >=20 > The coding style is not holy in any way. Everyone has its own coding > style. You must understand I do not want to fully discuss it every > time someone sends in a patch, especially since it will not change > anyways. By the way, I just noticed that you write _normal_ text with two spaces aft= er a dot, just like comments in the code! o_O >=20 > > While tools like `svn diff' can help in these kind of problems, their > > utility is greatly diminished if the offending change is part of a > > multi-line change. Besides, sometimes checks like "if (a=3Db)", or more > > frequently "if (a=3Df())" are intentionally used in C, so the error mig= ht > > become even more difficult to spot and correct. I ask for a deep > > reflection on this issue: =EF=BB=BFmaybe I'm dead wrong and an arrogant= brat in > > my attempt to tackle the Holy GNU Coding Standards, but I'd like to ask > > input from more people on this. >=20 > I will refuse patches with "if (a =3D f())", if that makes you sleep > better ;-) In fact the GCS discourages that use, but allows the same in loop checks, p= articularly "while" loops. > =20 > >> > WRT accepting raw BIOS disk numbers, I agree with you in principle, = but > >> > I'm keeping the functionality for now, since I don't quite like the > >> > "drivemap (hd0) (hd1)" syntax - which device is which?. I'd rather h= ave > >> > something akin to "drivemap (hd0) (bios:hd1)", but I want to hear th= e > >> > opinions of people in this list. > >>=20 > >> I personally do not care a lot if BIOS disk numbers are used. > >> Although I do not see why it is useful. > >>=20 > >> As for the syntax, I would prefer something more GRUB2ish, like: > >>=20 > >> map --bios=3D(hd0) --os=3D(hd1) > > I agree. What about "grub" for the source drive instead of "os", with > > "bios" being the target drive? I mean: > > drivemap --grub=3D(hd1) --bios=3D(hd0) > > Would map 0x80 in the BIOS to grub's (hd1) drive which will most likely > > be BIOS drive 0x81. >=20 > It will not change the functionality which GRUB is active. But it > will change it for the OS that is loaded. So I do not think --grub=3D > is a good idea because of this. As for GRUB Legacy, it confused a lot > of people, so making people explicitly say that it is changed for the > OS, this confusion might go away :-) >=20 > > However, I prefer not to change it right now. Maybe when there are no > > other issues WRT to this patch we can set on to tackle this one. >=20 > So first I'll review this patch, then you will send in a new one? Of course. I meant that I prefer to smash all "syntactic" changes in the pa= tch before introducing a functionality change that could lead to new syntac= tic issues. > =20 > >> Or so, perhaps the long argument names can be chosen in a more clever > >> way :-) > >> > The new version of the patch is attached, and here is my suggested C= Log: > >> > > >> > 2008-08-XX Javier Martin > >>=20 > >> (newline) > >>=20 > >> > =EF=BB=BF* commands/i386/pc/drivemap.c : New file. > >> > * commands/i386/pc/drivemap_int13h.S : New file. > >> > =EF=BB=BF* conf/i386-pc.rmk (pkglib_MODULES) : Added drivema= p.mod > >> > (drivemap_mod_SOURCES) : New variable > >> > (drivemap_mod_ASFLAGS) : Likewise > >> > =EF=BB=BF(drivemap_mod_CFLAGS) : Likewise > >> > =EF=BB=BF(drivemap_mod_LDFLAGS) : Likewise > >> > =EF=BB=BF* include/grub/loader.h (grub_loader_register_prebo= ot) : New > >> > function prototype. Register a new pre-boot handler > >>=20 > >> No need how the change is used or why it was added. > >>=20 > >> > (grub_loader_unregister_preboot) : Likewise. Unregister hand= ler > >>=20 > >> Same here. > >>=20 > >> > (grub_preboot_hookid) : New typedef. Registered hook "handle= " > >>=20 > >> Same here. > >>=20 > >> > =EF=BB=BF* kern/loader.c =EF=BB=BF(grub_loader_register_preb= oot) : New function. > >> > (grub_loader_unregister_preboot) : Likewise. > >> > (preboot_hooks) : New variable. Linked list of preboot hooks > >>=20 > >> Same here. > >>=20 > >> > (grub_loader_boot) : Call the list of preboot-hooks before t= he > >> > actual loader > >>=20 > >> What's the `=EF=BB=BF'? > > The what? o_O >=20 > I see some weird character in your text. My font shows it as a block > before every `*'. I see nothing: "What's the `'?". Maybe it's some kind of tab? >=20 > >> Please do not add a space before the ":"=20 > > Ok, everything corrected. New CL entry: > > > > =EF=BB=BF2008-08-XX Javier Martin > > > > =EF=BB=BF* commands/i386/pc/drivemap.c: New file. > > * commands/i386/pc/drivemap_int13h.S: New file. > > =EF=BB=BF* conf/i386-pc.rmk (pkglib_MODULES): Added drivemap.mo= d > > (drivemap_mod_SOURCES): New variable > > (drivemap_mod_ASFLAGS): Likewise > > =EF=BB=BF(drivemap_mod_CFLAGS): Likewise > > =EF=BB=BF(drivemap_mod_LDFLAGS): Likewise > > =EF=BB=BF* include/grub/loader.h (grub_loader_register_preboot)= : New > > function prototype. > > (grub_loader_unregister_preboot): Likewise. > > (grub_preboot_hookid): New typedef. > > =EF=BB=BF* kern/loader.c =EF=BB=BF(grub_loader_register_preboot= ): New function. > > (grub_loader_unregister_preboot): Likewise. > > (preboot_hooks): New variable. > > (grub_loader_boot): Call the list of preboot-hooks before the > > actual loader >=20 > Please add a `.' after "New variable" and "Likewise", same for the > third and the last sentence. Sometimes you did it right :-). >=20 Done. New CL entry will go at the end of this neverending post. >=20 > >> Some comments can be found below. Can you please fix the code mention > >> in the review and similar code? I really want the code to be just > >> like any other GRUB code. Please understand that we have to maintain > >> this in the future. If everyone would use his own codingstyle, GRUB > >> would become unmaintainable. > >>=20 > >> > Index: commands/i386/pc/drivemap.c > >> > =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 > >> > --- commands/i386/pc/drivemap.c (revisi=C3=B3n: 0) > >> > +++ commands/i386/pc/drivemap.c (revisi=C3=B3n: 0) > >> > @@ -0,0 +1,417 @@ > >> > +/* drivemap.c - command to manage the BIOS drive mappings. */ > >> > +/* > >> > + * GRUB -- GRand Unified Bootloader > >> > + * Copyright (C) 2008 Free Software Foundation, Inc. > >> > + * > >> > + * GRUB is free software: you can redistribute it and/or modify > >> > + * it under the terms of the GNU General Public License as publish= ed by > >> > + * the Free Software Foundation, either version 3 of the License, = or > >> > + * (at your option) any later version. > >> > + * > >> > + * GRUB is distributed in the hope that it will be useful, > >> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > >> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > >> > + * GNU General Public License for more details. > >> > + * > >> > + * You should have received a copy of the GNU General Public Licen= se > >> > + * along with GRUB. If not, see . > >> > + */ > >> > + > >> > +#include > >> > +#include > >> > +#include > >> > +#include > >> > +#include > >> > +#include > >> > +#include > >> > +#include > >> > + > >> > +#define MODNAME "drivemap" > >> > + > >> > +static const struct grub_arg_option options[] =3D { > >> > + {"list", 'l', 0, "show the current mappings", 0, 0}, > >> > + {"reset", 'r', 0, "reset all mappings to the default values", 0, = 0}, > >> > + {0, 0, 0, 0, 0, 0} > >> > +}; > >> > + > >> > +/* Syms/vars/funcs exported from drivemap_int13h.S - start. */ > >> > + > >> > +/* Realmode far ptr =3D 2 * 16b */ > >> > +extern grub_uint32_t grub_drivemap_int13_oldhandler; > >> > +/* Size of the section to be copied */ > >> > +extern grub_uint16_t grub_drivemap_int13_size; > >> > + > >> > +/* This type is used for imported assembly labels, takes no storage= and is only > >> > + used to take the symbol address with &label. Do NOT put void* h= ere. */ > >> > +typedef void grub_symbol_t; > >> > +extern grub_symbol_t grub_drivemap_int13_handler_base; > >> > +extern grub_symbol_t grub_drivemap_int13_mapstart; > >> > + > >> > +void grub_drivemap_int13_handler (void); > >>=20 > >> The lines above belong in a header file. > > True, but they are used in a single file in the whole project and thus = I > > see it pointless to extract an unneeded header, which would become one > > more SVN object to track. However, if you insist I will split the heade= r > > file at once. In particular, I think the grub_symbol_t typedef should g= o > > into the "standard" GRUB headers somehow (but not in symbol.h, which is > > included from assembly files). >=20 > Please do so. >=20 > Other people might want to comment on the symbol change. They will > most likely miss it if we keep discussing it here ;-). Can you please > send that in as a separate change to give other the opportunity to > react on it? Ok, so in a first stage I will put the discussed block in a drivemap.h file= in include/, then when that's committed start a discussion about moving gr= ub_symbol_t from drivemap.h to another header file. >=20 > >> > +/* Syms/vars/funcs exported from drivemap_int13h.S - end. */ > >> > + > >> > + > >> > +static grub_preboot_hookid insthandler_hook; > >> > + > >> > +typedef struct drivemap_node > >> > +{ > >> > + grub_uint8_t newdrive; > >> > + grub_uint8_t redirto; > >> > + struct drivemap_node *next; > >> > +} drivemap_node_t; > >> > + > >> > +static drivemap_node_t *drivemap =3D 0; > >>=20 > >> No need to set this to zero. > > Yes, you said so already, but I wanted to make the initial state very > > explicit to a future developer, since that variable is checked against > > zero in several points. Given that the added source size is four bytes > > and the added binary size is _zero_, is all the fuss really necessary? > > Notice that I changed the other variable in which you pointed out this > > issue, because it is not checked against zero anywhere. >=20 > Please do so anyways. >=20 > >> > +static grub_err_t install_int13_handler (void); > >> > + > >> > +/* Puts the specified mapping into the table, replacing an existing= mapping > >> > + for newdrive or adding a new one if required. */ > >> > +static grub_err_t > >> > +drivemap_set (grub_uint8_t newdrive, grub_uint8_t redirto) > >> > + > >>=20 > >> Please do not add a newline here. > > Oops, sorry. I forgot to remove it when moving the comment >=20 > :-) >=20 > >> > + drivemap_node_t *mapping =3D 0; > >> > + drivemap_node_t *search =3D drivemap; > >> > + while (search) > >> > + { > >> > + if (search->newdrive =3D=3D newdrive) > >> > + { > >> > + mapping =3D search; > >> > + break; > >> > + } > >> > + search =3D search->next; > >> > + } > >> > + > >> > + =20 > >> > + /* Check for pre-existing mappings to modify before creating a ne= w one. */ > >> > + if (mapping) > >> > + mapping->redirto =3D redirto; > >> > + else=20 > >> > + { > >> > + mapping =3D grub_malloc (sizeof (drivemap_node_t)); > >> > + if (!mapping) > >> > + return grub_error (GRUB_ERR_OUT_OF_MEMORY, > >> > + "cannot allocate map entry, not enough m= emory"); > >> > + mapping->newdrive =3D newdrive; > >> > + mapping->redirto =3D redirto; > >> > + mapping->next =3D drivemap; > >> > + drivemap =3D mapping; > >> > + } > >> > + return GRUB_ERR_NONE; > >> > +} > >> > + > >> > +/* Removes the mapping for newdrive from the table. If there is no= mapping, > >> > + then this function behaves like a no-op on the map. */ > >> > +static void > >> > +drivemap_remove (grub_uint8_t newdrive) > >> > +{ > >> > + drivemap_node_t *mapping =3D 0; > >> > + drivemap_node_t *search =3D drivemap; > >> > + drivemap_node_t *previous =3D 0; > >> > + while (search) > >> > + { > >> > + if (search->newdrive =3D=3D newdrive) > >> > + { > >> > + mapping =3D search; > >> > + break; > >> > + } > >> > + previous =3D search; > >> > + search =3D search->next; > >> > + } > >> > + if (mapping) /* Found. */ > >>=20 > >> You forgot one. > > Corrected. Sorry. > >>=20 > >> > + { > >> > + if (previous) > >> > + previous->next =3D mapping->next; > >> > + else /* Entry was head of list. */ > >> > + drivemap =3D mapping->next; > >> > + grub_free (mapping); > >> > + } > >> > +} > >> > + > >> > +/* Given a device name, resolves its BIOS disk number and stores it= in the > >> > + passed location, which should only be trusted if ERR_NONE is ret= urned. */ > >> > +static grub_err_t > >> > +parse_biosdisk (const char *name, grub_uint8_t *disknum) > >> > +{ > >> > + grub_disk_t disk; > >> > + if (!name || 0 =3D=3D *name) > >> > + return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name empty"); > >> > + /* Skip the first ( in (hd0) - disk_open wants just the name. */ > >> > + if (*name =3D=3D '(') > >> > + name++; > >> > + =20 > >> > + disk =3D grub_disk_open (name); > >> > + if (!disk) > >> > + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown device \"%= s\"", name); > >> > + else > >> > + { > >> > + const enum grub_disk_dev_id id =3D disk->dev->id; > >> > + /* The following assignment is only sound if the device is in= deed a > >> > + biosdisk. The caller must check the return value. */ > >> > + if (disknum) > >> > + *disknum =3D disk->id; > >> > + grub_disk_close (disk); > >> > + if (GRUB_DISK_DEVICE_BIOSDISK_ID =3D=3D id) > >> > + return GRUB_ERR_NONE; > >> > + else return grub_error (GRUB_ERR_BAD_DEVICE, "%s is not a BIO= S disk", name); > >> > + } > >> > +} > >> > + > >> > +/* Given a BIOS disk number, returns its GRUB device name if it exi= sts. > >> > + For nonexisting BIOS dnums, this function returns ERR_UNKNOWN_DE= VICE. */ > >>=20 > >> This is GRUB_ERR_UNKNOWN_DEVICE > > I know, I consciously left the GRUB_ part out because 1) it would > > require the line to be split and 2) that prefix is all over the place. > > Corrected, however. > >>=20 > >> > +static grub_err_t > >> > +revparse_biosdisk(const grub_uint8_t dnum, const char **output) > >> > +{ > >> > + int found =3D 0; > >> > + auto int find (const char *name); > >> > + int find (const char *name) > >> > + { > >> > + const grub_disk_t disk =3D grub_disk_open (name); > >> > + if (!disk) > >> > + return 0; > >> > + else > >> > + { > >> > + if (disk->id =3D=3D dnum && GRUB_DISK_DEVICE_BIOSDISK_ID = =3D=3D disk->dev->id) > >> > + { > >> > + found =3D 1; > >> > + if (output) > >> > + *output =3D name; > >> > + } > >> > + grub_disk_close (disk); > >> > + return found; > >> > + } > >> > + } > >> > + > >> > + grub_disk_dev_iterate (find); > >> > + if (found) > >> > + return GRUB_ERR_NONE; > >> > + else return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "BIOS disk %d no= t found", dnum); > >>=20 > >> Please change this. > > Em... to what? What is the problem? Do you want me to reverse the > > comparison? i.e. if (!found) { return error; } else { return ok; } >=20 > The return is on the same line as the else. >=20 Corrected. >=20 > >> > +/* Given a GRUB-like device name and a convenient location, stores = the related > >> > + BIOS disk number. Accepts devices like \((f|h)dN\), with 0 <=3D= N < 128. */ > >> > +static grub_err_t > >> > +tryparse_diskstring (const char *str, grub_uint8_t *output) > >> > +{ > >> > + if (!str || 0 =3D=3D *str) > >> > + goto fail; > >> > + /* Skip opening paren in order to allow both (hd0) and hd0. */ > >> > + if (*str =3D=3D '(') > >> > + str++; > >> > + if ((str[0] =3D=3D 'f' || str[0] =3D=3D 'h') && str[1] =3D=3D 'd'= ) > >> > + { > >> > + grub_uint8_t bios_num =3D (str[0] =3D=3D 'h')? 0x80 : 0x00; > >> > + grub_errno =3D GRUB_ERR_NONE; > >> > + unsigned long drivenum =3D grub_strtoul (str + 2, 0, 0); > >> > + if (grub_errno !=3D GRUB_ERR_NONE || drivenum > 127) > >> > + /* N not a number or out of range */ > >> > + goto fail; > >>=20 > >> Can you put this between braces, now comment was added. > > Done. > >>=20 > >> > + else > >> > + { > >> > + bios_num |=3D drivenum; > >> > + if (output) > >> > + *output =3D bios_num; > >> > + return GRUB_ERR_NONE; > >> > + } > >> > + } > >> > + else goto fail; > >>=20 > >> ... > > What's the problem here? The lack of braces? The goto (as used in the > > ext2 code)? >=20 > goto is on the same line as the else. Corrected, though I find this change less logic than the last one (splittin= g the else retun grub_error(...)) line because this generates two _extremel= y_ short lines; >=20 > >> > +fail: > >> > + return grub_error (GRUB_ERR_BAD_ARGUMENT, "device format \"%s\" i= nvalid: must" > >> > + "be (f|h)dN, with 0 <=3D N < 128", str); > >> > +} > >> > + > >> > +static grub_err_t > >> > +grub_cmd_drivemap (struct grub_arg_list *state, int argc, char **ar= gs) > >> > +{ > >> > + if (state[0].set) > >> > + { > >> > + /* Show: list mappings. */ > >> > + if (!drivemap) > >> > + grub_printf ("No drives have been remapped"); > >> > + else > >> > + { > >> > + grub_printf ("Showing only remapped drives.\n"); > >> > + grub_printf ("Mapped\tGRUB\n"); > >> > + drivemap_node_t *curnode =3D drivemap; > >> > + while (curnode) > >> > + { > >> > + const char *dname =3D 0; > >> > + grub_err_t err =3D revparse_biosdisk (curnode->redirt= o, &dname); > >> > + if (err !=3D GRUB_ERR_NONE) > >> > + return grub_error (err, "invalid mapping: non-exist= ent disk" > >> > + "or not managed by the BIOS= "); > >> > + grub_printf("0x%02x\t%4s\n", curnode->newdrive, dname= ); > >> > + curnode =3D curnode->next; > >> > + } > >> > + } > >> > + } > >> > + else if (state[1].set) > >> > + { > >> > + /* Reset: just delete all mappings, freeing their memory. */ > >> > + drivemap_node_t *curnode =3D drivemap; > >> > + drivemap_node_t *prevnode =3D 0; > >> > + while (curnode) > >> > + { > >> > + prevnode =3D curnode; > >> > + curnode =3D curnode->next; > >> > + grub_free (prevnode); > >> > + } > >> > + drivemap =3D 0; > >> > + } > >> > + else > >> > + { > >> > + /* Neither flag: put mapping */ > >>=20 > >> ". */ > > Done > >>=20 > >> > + grub_uint8_t mapfrom =3D 0; > >> > + grub_uint8_t mapto =3D 0xFF; > >> > + grub_err_t err; > >> > + =20 > >> > + if (argc !=3D 2) > >> > + return grub_error (GRUB_ERR_BAD_ARGUMENT, "two arguments re= quired"); > >> > + > >> > + err =3D parse_biosdisk (args[0], &mapfrom); > >> > + if (err !=3D GRUB_ERR_NONE) > >> > + return err; > >> > + > >> > + err =3D tryparse_diskstring (args[1], &mapto); > >> > + if (err !=3D GRUB_ERR_NONE) /* Not a disk string. Maybe a raw= num then? */ > >>=20 > >> Please move this up. > > Done. > >>=20 > >> > + { =20 > >> > + grub_errno =3D GRUB_ERR_NONE; > >> > + unsigned long num =3D grub_strtoul (args[1], 0, 0); > >> > + if (grub_errno !=3D GRUB_ERR_NONE || num > 0xFF) /* Not = a raw num or too high. */ > >> > + return grub_error (grub_errno, > >> > + "Target specifier must be of the form= (fdN) or " > >> > + "(hdN), with 0 <=3D N < 128; or a pla= in dec/hex " > >> > + "number between 0 and 255"); > >> > + else mapto =3D (grub_uint8_t)num; > >> > + } > >> > + =20 > >> > + if (mapto =3D=3D mapfrom) /* Reset to default. */ > >>=20 > >> Same here. > > Done. > >>=20 > >> > + { > >> > + grub_dprintf (MODNAME, "Removing the mapping for %s (%02x= )", args[0], mapfrom); > >> > + drivemap_remove (mapfrom); > >> > + } > >> > + else /* Map. */ > >>=20 > >> Please move the comment inside the braces below. > > Done, and reworded. > >>=20 > >> > + { > >> > + grub_dprintf (MODNAME, "Mapping %s (%02x) to %02x\n", arg= s[0], mapfrom, mapto); > >> > + return drivemap_set ((grub_uint8_t)mapto, mapfrom); > >> > + } > >> > + } > >> > + > >> > + return GRUB_ERR_NONE; > >> > +} > >> > + > >> > +typedef struct __attribute__ ((packed)) int13map_node > >> > +{ > >> > + grub_uint8_t disknum; > >> > + grub_uint8_t mapto; > >> > +} int13map_node_t; > >> > + > >> > +/* The min amount of mem that must remain free after installing the= handler. > >> > + 32 KiB is just above 0x7C00-0x7E00, where the bootsector is load= ed. */ > >> > +#define MIN_FREE_MEM_KB 32 > >> > +#define INT13H_OFFSET(x) ( ((grub_uint8_t*)(x)) - ((grub_uint8_t*)&= grub_drivemap_int13_handler_base) ) > >> > +#define INT13H_REBASE(x) ( (void*) (((grub_uint8_t*)handler_base) += (x)) ) > >> > +#define INT13H_TONEWADDR(x) INT13H_REBASE( INT13H_OFFSET( x ) ) > >> > + > >> > +/* Int13h handler installer - reserves conventional memory for the = handler, > >> > + copies it over and sets the IVT entry for int13h. =20 > >> > + This code rests on the assumption that GRUB does not activate an= y kind of > >> > + memory mapping apart from identity paging, since it accesses rea= lmode > >> > + structures by their absolute addresses, like the IVT at 0 or the= BDA at > >> > + 0x400; and transforms a pmode pointer into a rmode seg:off far p= tr. */ > >> > +static grub_err_t > >> > +install_int13_handler (void) > >> > +{ > >> > + grub_size_t entries =3D 0; > >> > + drivemap_node_t *curentry =3D drivemap; > >> > + while (curentry) /* Count entries to prepare a contiguous map bl= ock. */ > >>=20 > >> ... > > Comment moved up. > >>=20 > >> > + { > >> > + entries++; > >> > + curentry =3D curentry->next; > >> > + } > >> > + if (0 =3D=3D entries) > >>=20 > >> I know this is what you prefer, but can you change this nevertheless? > > I refer to my objection near the top of the post. >=20 > I know you object, but did you change it? Done. >=20 > >> > + grub_dprintf (MODNAME, "No drives marked as remapped, install= ation of" > >> > + "an int13h handler is not required."); > >> > + return GRUB_ERR_NONE; /* No need to install the int13h handl= er. */ > >> > + } > >> > + else > >> > + { > >> > + grub_dprintf (MODNAME, "Installing int13h handler...\n"); > >> > + grub_uint32_t *ivtslot =3D (grub_uint32_t*)0x0000004c; > >> > + =20 > >> > + /* Save the pointer to the old int13h handler. */ > >> > + grub_drivemap_int13_oldhandler =3D *ivtslot; > >> > + grub_dprintf (MODNAME, "Old int13 handler at %04x:%04x\n", > >> > + (grub_drivemap_int13_oldhandler >> 16) & 0x0ffff, > >> > + grub_drivemap_int13_oldhandler & 0x0ffff); > >> > + > >> > + /* Reserve a section of conventional memory as "BIOS memory" = for handler: > >> > + BDA offset 0x13 contains the top of such memory. */ > >> > + grub_uint16_t *bpa_freekb =3D (grub_uint16_t*)0x00000413; > >> > + grub_dprintf (MODNAME, "Top of conventional memory: %u KiB\n"= , *bpa_freekb); > >> > + grub_size_t total_size =3D grub_drivemap_int13_size > >> > + + (entries + 1) * sizeof(int13map_node_= t); > >> > + grub_uint16_t payload_sizekb =3D (total_size >> 10) + > >> > + (((total_size % 1024) =3D=3D 0)= ? 0 : 1); > >> > + if ((*bpa_freekb - payload_sizekb) < MIN_FREE_MEM_KB) > >> > + return grub_error (GRUB_ERR_OUT_OF_MEMORY, "refusing to ins= tall" > >> > + "int13 handler, not enough free memory a= fter"); > >> > + grub_dprintf (MODNAME, "Payload is %u b long, reserving %u Kb= \n", > >> > + total_size, payload_sizekb); > >> > + *bpa_freekb -=3D payload_sizekb; > >> > + > >> > + /* Copy int13h handler chunk to reserved area. */ > >> > + grub_uint8_t *handler_base =3D (grub_uint8_t*)(*bpa_freekb <<= 10); > >> > + grub_dprintf (MODNAME, "Copying int13 handler to: %p\n", hand= ler_base); > >> > + grub_memcpy (handler_base, &grub_drivemap_int13_handler_base, > >> > + grub_drivemap_int13_size); > >> > + > >> > + /* Copy the mappings to the reserved area. */ > >> > + curentry =3D drivemap; > >> > + grub_size_t i; > >> > + int13map_node_t *handler_map =3D (int13map_node_t*) > >> > + INT13H_TONEWADDR (&grub_drivemap_int13_mapsta= rt); > >> > + grub_dprintf (MODNAME, "Target map at %p, copying mappings...= \n", handler_map); > >> > + for (i =3D 0; i < entries && curentry; i++, curentry =3D cure= ntry->next) > >> > + { > >> > + handler_map[i].disknum =3D curentry->newdrive; > >> > + handler_map[i].mapto =3D curentry->redirto; > >> > + grub_dprintf (MODNAME, "\t#%d: 0x%02x <- 0x%02x\n", i, > >> > + handler_map[i].disknum, handler_map[i].mapto); > >> > + } > >> > + /* Signal end-of-map. */ > >> > + handler_map[i].disknum =3D 0; > >> > + handler_map[i].mapto =3D 0; > >> > + grub_dprintf (MODNAME, "\t#%d: 0x%02x <- 0x%02x (end)\n", i, > >> > + handler_map[i].disknum, handler_map[i].mapto); > >> > + > >> > + /* Install our function as the int13h handler in the IVT. */ > >> > + grub_uint32_t ivtentry =3D ((grub_uint32_t)handler_base) << 1= 2; /* Segment address. */ > >> > + ivtentry |=3D (grub_uint16_t) INT13H_OFFSET(grub_drivemap_int= 13_handler); > >> > + grub_dprintf (MODNAME, "New int13 handler IVT pointer: %04x:%= 04x\n", > >> > + (ivtentry >> 16) & 0x0ffff, ivtentry & 0x0ffff); > >> > + *ivtslot =3D ivtentry; > >> > + =20 > >> > + return GRUB_ERR_NONE; > >> > + } > >> > +} > >> > + > >> > +GRUB_MOD_INIT (drivemap) > >> > +{ > >> > + (void) mod; /* Stop warning. */ > >> > + grub_register_command (MODNAME, grub_cmd_drivemap, > >> > + GRUB_COMMAND_FLAG_BOTH, > >> > + MODNAME " -s | -r | (hdX) newdrivenum", > >> > + "Manage the BIOS drive mappings", options)= ; > >> > + insthandler_hook =3D grub_loader_register_preboot (&install_int13= _handler, 1); > >> > +} > >> > + > >> > +GRUB_MOD_FINI (drivemap) > >> > +{ > >> > + grub_loader_unregister_preboot (insthandler_hook); > >> > + insthandler_hook =3D 0; > >> > + grub_unregister_command (MODNAME); > >> > +} > >> > + > >> > Index: commands/i386/pc/drivemap_int13h.S > >> > =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 > >> > --- commands/i386/pc/drivemap_int13h.S (revisi=C3=B3n: 0) > >> > +++ commands/i386/pc/drivemap_int13h.S (revisi=C3=B3n: 0) > >> > @@ -0,0 +1,118 @@ > >> > +/* > >> > + * GRUB -- GRand Unified Bootloader > >> > + * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008 Free= Software Foundation, Inc. > >> > + * > >> > + * GRUB is free software: you can redistribute it and/or modify > >> > + * it under the terms of the GNU General Public License as publish= ed by > >> > + * the Free Software Foundation, either version 3 of the License, = or > >> > + * (at your option) any later version. > >> > + * > >> > + * GRUB is distributed in the hope that it will be useful, > >> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > >> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > >> > + * GNU General Public License for more details. > >> > + * > >> > + * You should have received a copy of the GNU General Public Licen= se > >> > + * along with GRUB. If not, see . > >> > + */ > >> > + > >> > + > >> > +/* > >> > + * Note: These functions defined in this file may be called from C. > >> > + * Be careful of that you must not modify some registers. Quo= te > >> > + * from gcc-2.95.2/gcc/config/i386/i386.h: > >> > + > >> > + 1 for registers not available across function calls. > >> > + These must include the FIXED_REGISTERS and also any > >> > + registers that can be used without being saved. > >> > + The latter must include the registers where values are returned > >> > + and the register where structure-value addresses are passed. > >> > + Aside from that, you can include as many other registers as you = like. > >> > + > >> > + ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg > >> > +{ 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } > >> > + */ > >> > + > >> > +/* > >> > + * Note: GRUB is compiled with the options -mrtd and -mregparm=3D3. > >> > + * So the first three arguments are passed in %eax, %edx, and= %ecx, > >> > + * respectively, and if a function has a fixed number of argu= ments > >> > + * and the number if greater than three, the function must re= turn > >> > + * with "ret $N" where N is ((the number of arguments) - 3) *= 4. > >> > + */ > >> > + > >> > +#include > >> > + > >> > +#define GRUB_DRIVEMAP_INT13H_OFFSET(x) ((x) - grub_drivemap_int13_h= andler_base) > >> > + > >> > +/* Copy starts here. When deployed, this label must be segment-alig= ned */ > >> > +VARIABLE(grub_drivemap_int13_handler_base) > >> > + > >> > +VARIABLE(grub_drivemap_int13_oldhandler) > >> > + .word 0xdead, 0xbeef > >> > +/* Drivemap module - INT 13h handler - BIOS HD map */ > >> > +/* We need to use relative addressing, and with CS to top it all, s= ince we > >> > + must make as few changes to the registers as possible. IP-relat= ive > >> > + addressing like on amd64 would make life way easier here. */ > >> > +.code16 > >> > +FUNCTION(grub_drivemap_int13_handler) > >> > + push %bp > >> > + mov %sp, %bp > >> > + push %ax /* We'll need it later to determine the used BIOS funct= ion */ > >> > + > >> > + /* Map the drive number (always in DL?) */ > >> > + push %ax > >> > + push %bx > >> > + push %si > >> > + mov $GRUB_DRIVEMAP_INT13H_OFFSET(grub_drivemap_int13_mapstart), %= bx > >> > + xor %si, %si > >> > +1:movw %cs:(%bx,%si), %ax > >> > + cmp %ah, %al > >> > + jz 3f /* DRV=3DDST =3D> map end - drive not remapped, leave DL as= -is */ > >> > + cmp %dl, %al > >> > + jz 2f /* Found - drive remapped, modify DL */ > >> > + add $2, %si > >> > + jmp 1b /* Not found, but more remaining, loop */ > >> > +2:mov %ah, %dl > >> > +3:pop %si > >> > + pop %bx > >> > + xchgw %ax, -4(%bp) /* Recover the old AX and save the map entry f= or later */ > >> > + =20 > >> > + push %bp > >> > + /* Simulate interrupt call: push flags and do a far call in order= to set > >> > + the stack the way the old handler expects it so that its iret = works */ > >> > + push 6(%bp) > >> > + movw (%bp), %bp /* Restore the caller BP (is this needed and/or = sensible?) */ > >> > + lcall *%cs:GRUB_DRIVEMAP_INT13H_OFFSET(grub_drivemap_int13_oldhan= dler) > >> > + pop %bp /* The pushed flags were removed by iret */ > >> > + /* Set the saved flags to what the int13h handler returned */ > >> > + push %ax > >> > + pushf > >> > + pop %ax > >> > + movw %ax, 6(%bp) > >> > + pop %ax > >> > + > >> > + /* Reverse map any returned drive number if the data returned inc= ludes it. =20 > >> > + The only func that does this seems to be origAH =3D 0x08, but = many BIOS > >> > + refs say retDL =3D # of drives connected. However, the GRUB L= egacy code > >> > + treats this as the _drive number_ and "undoes" the remapping. = Thus, > >> > + this section has been disabled for testing if it's required */ > >> > +# cmpb $0x08, -1(%bp) /* Caller's AH */ > >> > +# jne 4f > >> > +# xchgw %ax, -4(%bp) /* Map entry used */ > >> > +# cmp %ah, %al /* DRV=3DDST =3D> drive not remapped */ > >> > +# je 4f > >> > +# mov %ah, %dl /* Undo remap */ > >> > + > >> > +4:mov %bp, %sp > >> > + pop %bp > >> > + iret > >> > +/* This label MUST be at the end of the copied block, since the ins= taller code > >> > + reserves additional space for mappings at runtime and copies the= m over it */ > >> > +.align 2 > >> > +VARIABLE(grub_drivemap_int13_mapstart) > >> > +/* Copy stops here */ > >> > +.code32 > >> > +VARIABLE(grub_drivemap_int13_size) > >> > + .word GRUB_DRIVEMAP_INT13H_OFFSET(grub_drivemap_int13_size) > >> > + > >> > Index: conf/i386-pc.rmk > >> > =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 > >> > --- conf/i386-pc.rmk (revisi=C3=B3n: 1766) > >> > +++ conf/i386-pc.rmk (copia de trabajo) > >> > @@ -158,7 +158,7 @@ > >> > vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \ > >> > videotest.mod play.mod bitmap.mod tga.mod cpuid.mod serial.mod \ > >> > ata.mod vga.mod memdisk.mod jpeg.mod png.mod pci.mod lspci.mod \ > >> > - aout.mod _bsd.mod bsd.mod > >> > + aout.mod _bsd.mod bsd.mod drivemap.mod > >> > =20 > >> > # For biosdisk.mod. > >> > biosdisk_mod_SOURCES =3D disk/i386/pc/biosdisk.c > >> > @@ -325,4 +325,11 @@ > >> > bsd_mod_CFLAGS =3D $(COMMON_CFLAGS) > >> > bsd_mod_LDFLAGS =3D $(COMMON_LDFLAGS) > >> > =20 > >> > +# For drivemap.mod. > >> > +drivemap_mod_SOURCES =3D commands/i386/pc/drivemap.c \ > >> > + commands/i386/pc/drivemap_int13h.S > >> > +drivemap_mod_ASFLAGS =3D $(COMMON_ASFLAGS) > >> > +drivemap_mod_CFLAGS =3D $(COMMON_CFLAGS) > >> > +drivemap_mod_LDFLAGS =3D $(COMMON_LDFLAGS) > >> > + > >> > include $(srcdir)/conf/common.mk > >> > Index: include/grub/loader.h > >> > =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 > >> > --- include/grub/loader.h (revisi=C3=B3n: 1766) > >> > +++ include/grub/loader.h (copia de trabajo) > >> > @@ -37,6 +37,22 @@ > >> > /* Unset current loader, if any. */ > >> > void EXPORT_FUNC(grub_loader_unset) (void); > >> > =20 > >> > +typedef struct hooklist_node *grub_preboot_hookid; > >> > + > >> > +/* Register a function to be called before the boot hook. Returns = an id that > >> > + can be later used to unregister the preboot (i.e. on module unlo= ad). If > >> > + abort_on_error is set, the boot sequence will abort if any of th= e registered > >> > + functions return anything else than GRUB_ERR_NONE. > >> > + On error, the return value will compare equal to 0 and the error= information > >> > + will be available in errno and errmsg. However, if the call is = successful > >> > + those variables are _not_ modified. */ > >>=20 > >> No need to mention errmsg, it's internal to GRUB. As for errno (which > >> is grub_errno, actually) it does not need to be mentioned, otherwise > >> we would have to do so everywhere. Please capitalize HOOK and > >> ABORT_ON_ERROR in the comments above. > > Done. "hook" removed because it referred to the loader module boot > > function. > >>=20 > >> > +grub_preboot_hookid EXPORT_FUNC(grub_loader_register_preboot) > >> > + (grub_err_t (*hook) (void), int abort_on_error); > >> > + > >> > +/* Unregister a preboot hook by the id returned by loader_register_= preboot. > >> > + This functions becomes a no-op if no such function is registered= */ > >> > +void EXPORT_FUNC(grub_loader_unregister_preboot) (grub_preboot_hook= id id); > >> > + > >> > /* Call the boot hook in current loader. This may or may not return= , > >> > depending on the setting by grub_loader_set. */ > >>=20 > >> Nitpick: "loader. This..." > > Are you a bot? =C2=AC=C2=AC Corrected >=20 > It would make like much simpler if I were ;-). What makes you think > so? Your ability to spot these kind of smallish things, like the "deltion" word= and the lack of a double space. You even write normal text with double spa= ces! >=20 > >> > grub_err_t EXPORT_FUNC(grub_loader_boot) (void); > >> > Index: kern/loader.c > >> > =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 > >> > --- kern/loader.c (revisi=C3=B3n: 1766) > >> > +++ kern/loader.c (copia de trabajo) > >> > @@ -61,11 +61,82 @@ > >> > grub_loader_loaded =3D 0; > >> > } > >> > =20 > >> > +struct hooklist_node > >> > +{ > >> > + grub_err_t (*hook) (void); > >> > + int abort_on_error; > >> > + struct hooklist_node *next; > >> > +}; > >> > + > >> > +static struct hooklist_node *preboot_hooks =3D 0; > >> > + > >> > +grub_preboot_hookid > >> > +grub_loader_register_preboot(grub_err_t (*hook) (void), int abort_o= n_error) > >> > +{ > >> > + if (!hook) > >> > + { > >> > + grub_error (GRUB_ERR_BAD_ARGUMENT, "preboot hook must not be = NULL"); > >> > + return 0; > >> > + } > >> > + grub_preboot_hookid newentry =3D grub_malloc (sizeof (struct hook= list_node)); > >>=20 > >> Mixed declarations/code. > > Oops, sorry. I put most of my attention on drivemap.c (and even then > > many comments slipped through). Corrected. >=20 > Please re-check them, I might have missed things this time... >=20 > >> > + if (!newentry) > >> > + { > >> > + grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot alloc a hookinfo = structure"); > >> > + return 0; > >> > + } > >> > + else > >> > + { > >> > + newentry->hook =3D hook; > >> > + newentry->abort_on_error =3D abort_on_error; > >> > + newentry->next =3D preboot_hooks; > >> > + preboot_hooks =3D newentry; > >> > + return newentry; > >> > + } > >> > +} > >> > + > >> > +void > >> > +grub_loader_unregister_preboot(grub_preboot_hookid id) > >>=20 > >> "preboot (grub" > > Corrected on both functions ;) > >>=20 > >> > +{ > >> > + grub_preboot_hookid entry =3D 0; > >> > + grub_preboot_hookid search =3D preboot_hooks; > >> > + grub_preboot_hookid previous =3D 0; > >> > + > >> > + if (0 =3D=3D id) > >> > + return; > >>=20 > >> ... > > ... xD > >>=20 > >> > + while (search) > >> > + { > >> > + if (search =3D=3D id) > >> > + { > >> > + entry =3D search; > >> > + break; > >> > + } > >> > + previous =3D search; > >> > + search =3D search->next; > >> > + } > >> > + if (entry) /* Found */ > >>=20 > >> ... > > Comment removed, was unnecessary. > >>=20 > >> > + { > >> > + if (previous) > >> > + previous->next =3D entry->next; > >> > + else preboot_hooks =3D entry->next; /* Entry was head of list= */ > >> > + grub_free (entry); > >> > + } > >> > +} > >> > + > >> > grub_err_t > >> > grub_loader_boot (void) > >> > { > >> > if (! grub_loader_loaded) > >> > return grub_error (GRUB_ERR_NO_KERNEL, "no loaded kernel"); > >> > + =20 > >> > + grub_preboot_hookid entry =3D preboot_hooks; > >>=20 > >> Mixed declarations/code. > > Moved the whole line up. > >>=20 > >> > + while (entry) > >> > + { > >> > + grub_err_t possible_error =3D entry->hook(); > >> > + if (possible_error !=3D GRUB_ERR_NONE && entry->abort_on_erro= r) > >> > + return possible_error; > >> > + entry =3D entry->next; > >> > + } > >> > =20 > >> > if (grub_loader_noreturn) > >> > grub_machine_fini (); >=20 >=20 >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel El mar, 05-08-2008 a las 13:28 +0200, Marco Gerards escribi=C3=B3: > Hi, >=20 > Javier Mart=C3=ADn writes: >=20 > >> > There is, however, one point in which I keep my objection: compariso= ns > >> > between a variable and a constant should be of the form CONSTANT =3D= =3D > >> > variable and not in the reverse order, since an erroneous but quite > >> > possible change of =3D=3D for =3D results in a compile-time error in= stead of a > >> > _extremely_ difficult to trace runtime bug. Such kind of bugs are qu= ite > >> > excruciating to find in userspace applications within an IDE, so I c= an't > >> > even consider the pain to debug them in a bootloader. > >>=20 > >> I understand your concern, nevertheless, can you please change it? > > You understand my concern, but seemingly do not understand that in orde= r > > to conform to the Holy Coding Style you are asking me to write code tha= t > > can become buggy (and with a very hard to trace bug) with a simple > > deltion! (point: did you notice that last word _without_ a spelling > > checker? Now try to do so in a multithousand-line program). >=20 > BTW, your patch still contains this, can you please change it before I > go over it again? >=20 > I know people who claim that this code will become buggy because we > write it in C. Should we start accepting patches to rewrite GRUB in > Haskell or whatever? :-) What about Ada? The stock GCC has Ada support ^^ >=20 > Really, as a maintainer I should set some standards and stick to it. > Of course not everyone will like me and sometimes I have to act like a > jerk. But I rather be a jerk, than committing code that do not meet > my expectations. But please understand, this contribution is highly > appreciated. However, we want to have something maintainable for the > far future as well :-) I understand these kind of concerns, particularly seeing how GRUB Legacy ended - tangled, unscalable spaghetti code. You're not a jerk, just a bit obsessive, but that's fine when trying to handle herds of us all-important devs which think all we do is The Right Thing (tm) and others are heretics to The Truth. >=20 > -- > Marco >=20 >=20 >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel Ok, so here is the new version of the patch, with a new drivemap.h header and the =3D=3D arguments put in the Holy Ordering ^^. I hope I didn'= t forget anything this time. Here is the new CL entry: =EF=BB=BF=EF=BB=BF2008-08-XX Javier Martin =EF=BB=BF* commands/i386/pc/drivemap.c: New file. * commands/i386/pc/drivemap_int13h.S: New file. =EF=BB=BF* conf/i386-pc.rmk (pkglib_MODULES): Added drivemap.mod. (drivemap_mod_SOURCES): New variable. (drivemap_mod_ASFLAGS): Likewise. =EF=BB=BF(drivemap_mod_CFLAGS): Likewise. =EF=BB=BF(drivemap_mod_LDFLAGS): Likewise. =EF=BB=BF* include/grub/loader.h (grub_loader_register_preboot): Ne= w function prototype. (grub_loader_unregister_preboot): Likewise. (grub_preboot_hookid): New typedef. =EF=BB=BF* kern/loader.c =EF=BB=BF(grub_loader_register_preboot): N= ew function. (grub_loader_unregister_preboot): Likewise. (preboot_hooks): New variable. (grub_loader_boot): Call the list of preboot-hooks before the actual loader. By the way, is there anything I can do to make `svn up' updates less traumatic? I don't want to search each "C" file for "<<<<<< mine" lines and correct them: is there any tool to do this with a workflow not unlike that of Gentoo's `etc-update'? Habbit --=-Zl4AbXwRtMXPWLC5S+/c Content-Disposition: attachment; filename=drivemap.patch.6 Content-Transfer-Encoding: base64 Content-Type: text/x-patch; name=drivemap.patch.6; charset=utf-8 SW5kZXg6IGNvbW1hbmRzL2kzODYvcGMvZHJpdmVtYXAuYw0KPT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KLS0tIGNvbW1h bmRzL2kzODYvcGMvZHJpdmVtYXAuYwkocmV2aXNpw7NuOiAwKQ0KKysrIGNvbW1hbmRzL2kzODYv cGMvZHJpdmVt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9SWSwNCisgICAgICAgICAgICAg ICAgICAgICAgICAgICAiY2Fubm90IGFsbG9jYXRlIG1hcCBlbnRyeSwgbm90IGVub3VnaCBtZW1v cnkiKTsNCisgICAgICBtYXBwaW5nLT5uZXdkcml2ZSA9IG5ld2RyaXZlOw0KKyAgICAgIG1hcHBp bmctPnJlZGlydG8gPSByZWRpcnRvOw0KKyAgICAgIG1hcHBpbmctPm5leHQgPSBkcml2ZW1hcDsN CisgICAgICBkcml2ZW1hcCA9IG1hcHBpbmc7DQorICAgIH0NCisgIHJldHVybiBHUlVCX0VSUl9O T05FOw0KK30NCisNCisvKiBSZW1vdmVzIHRoZSBtYXBwaW5nIGZvciBuZXdkcml2ZSBmcm9tIHRo ZSB0YWJsZS4gIElmIHRoZXJlIGlzIG5vIG1hcHBpbmcsDQorICAgdGhlbiB0aGlzIGZ1bmN0aW9u IGJlaGF2ZXMgbGlrZSBhIG5vLW9wIG9uIHRoZSBtYXAuICAqLw0KK3N0YXRpYyB2b2lkDQorZHJp dmVtYXBfcmVtb3ZlIChncnViX3VpbnQ4X3QgbmV3ZHJpdmUpDQorew0KKyAgZHJpdmVtYXBfbm9k ZV90ICptYXBwaW5nID0gMDsNCisgIGRyaXZlbWFwX25vZGVfdCAqc2VhcmNoID0gZHJpdmVtYXA7 DQorICBkcml2ZW1hcF9ub2RlX3QgKnByZXZpb3VzID0gMDsNCisNCisgIHdoaWxlIChzZWFyY2gp DQorICAgIHsNCisgICAgICBpZiAoc2VhcmNoLT5uZXdkcml2ZSA9PSBuZXdkcml2ZSkNCisgICAg ICAgIHsNCisgICAgICAgICAgbWFwcGluZyA9IHNlYXJjaDsNCisgICAgICAgICAgYnJlYWs7DQor ICAgICAgICB9DQorICAgICAgcHJldmlvdXMgPSBzZWFyY2g7DQorICAgICAgc2VhcmNoID0gc2Vh cmNoLT5uZXh0Ow0KKyAgICB9DQorDQorICBpZiAobWFwcGluZykNCisgICAgew0KKyAgICAgIGlm IChwcmV2aW91cykNCisgICAgIC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JkZXIgdG8gYWxsb3cg Ym90aCAoaGQwKSBhbmQgaGQwLiAgKi8NCisgIGlmICgqc3RyID09ICcoJykNCisgICAgc3RyKys7 DQorICBpZiAoKHN0clswXSA9PSAnZicgfHwgc3RyWzBdID09ICdoJykgJiYgc3RyWzFdID09ICdk JykNCisgICAgew0KKyAgICAgIGdydWJfdWludDhfdCBiaW9zX251bSA9IChzdHJbMF0gPT0gJ2gn KT8gMHg4MCA6IDB4MDA7DQorICAgICAgZ3J1Yl9lcnJubyA9IEdSVUJfRVJSX05PTkU7DQorICAg ICAgdW5zaWduZWQgbG9uZyBkcml2ZW51bSA9IGdydWJfc3RydG91bCAoc3RyICsgMiwgMCwgMCk7 DQorICAgICAgaWYgKGdydWJfZXJybm8gIT0gR1JVQl9FUlJfTk9ORSB8fCBkcml2ZW51bSA+IDEy NykNCisgICAgICAgIHsNCisgICAgICAgICAgLyogTiBub3QgYSBudW1iZXIgb3Igb3V0IG9mIHJh bmdlLiAgKi8NCisgICAgICAgICAgZ290byBmYWlsOw0KKyAgICAgICAgfQ0KKyAgICAgIGVsc2UN CisgICAgICAgIHsNCisgICAgICAgICAgYmlvc19udW0gfD0gZHJpdmVudW07DQorICAgICAgICAg IGlmIChvdXRwdXQpDQorICAgICAgICAgICAgKm91dHB1dCA9IGJpb3NfbnVtOw0KKyAgICAgICAg ICByZXR1cm4gR1JVQl9FUlJfTk9ORTsNCisgICAgICAgIH0NCisgICAgfQ0KKyAgZWxzZQ0KKyAg ICBnb3RvIGZhaWw7DQorDQorZmFpbDoNCisgIHJldHVybiBncnViX2Vycm9yIChHUlVCX0VSUl9C QURfQVJHVU1FTlQsICJkZXZpY2UgZm9ybWF0IFwiJXNcIiBpbnZhbGlkOiBtdXN0Ig0KKyAgICAg ICAgICAgICAgICAgICAgICJiZSAoZnxoKWROLCB3aXRoIDAgPD0gTiA8IDEyOCIsIHN0cik7DQor fQ0KKw0KK3N0YXRpYyBncnViX2Vycl90DQorZ3J1Yl9jbWRfZHJpdmVtYXAgKHN0cnVjdCBncnVi X2FyZ19saXN0ICpzdGF0ZSwgaW50IGFyZ2MsIGNoYXIgKiphcmdzKQ0KK3sNCisgIGlmIChzdGF0 ZVswXS5zZXQpDQorICAgIHsNCisgICAgICAvKiBTaG93OiBsaXN0IG1hcHBpbmdzLiAgKi8NCisg ICAgICBpZiAoIWRyaXZlbWFwKQ0KKyAgICAgICAgZ3J1Yl9wcmludGYgKCJObyBkcml2ZXMgaGF2 ZSBiZWVuIHJlbWFwcGVkIik7DQorICAgICAgZWxzZQ0KKyAgICAgICAgew0KKyAgICAgICAgICBn cnViX3ByaW50ZiAoIlNob3dpbmcgb25seSByZW1hcHBlZCBkcml2ZXMuXG4iKTsNCisgICAgICAg ICAgZ3J1Yl9wcmludGYgKCJNYXBwZWRcdEdSVUJcbiIpOw0KKyAgICAgICAgICBkcml2ZW1hcF9u b2RlX3QgKmN1cm5vZGUgPSBkcml2ZW1hcDsNCisgICAgICAgICAgd2hpbGUgKGN1cm5vZGUpDQor ICAgICAgICAgICAgew0KKyAgICAgICAgICAgICAgY29uc3QgY2hhciAqZG5hbWUgPSAwOw0KKyAg ICAgICAgICAgICAgZ3J1Yl9lcnJfdCBlcnIgPSByZXZwYXJzZV9iaW9zZGlzayAoY3Vybm9kZS0+ cmVkaXJ0bywgJmRuYW1lKTsNCisgICAgICAgICAgICAgIGlmIChlcnIgIT0gR1JVQl9FUlJfTk9O RSkNCisgICAgICAgICAgICAgICAgcmV0dXJuIGdydWJfZXJyb3IgKGVyciwgImludmFsaWQgbWFw cGluZzogbm9uLWV4aXN0ZW50IGRpc2siDQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICJvciBub3QgbWFuYWdlZCBieSB0aGUgQklPUyIpOw0KKyAgICAgICAgICAgICAg Z3J1Yl9wcmludGYoIjB4JTAyeFx0JTRzXG4iLCBjdXJub2RlLT5uZXdkcml2ZSwgZG5hbWUpOw0K KyAgICAgICAgICAgICAgY3Vybm9kZSA9IGN1cm5vZGUtPm5leHQ7DQorICAgICAgICAgICAgfQ0K KyAgICAgICAgfQ0KKyAgICB9DQorICBlbHNlIGlmIChzdGF0ZVsxXS5zZXQpDQorICAgIHsNCisg ICAgICAvKiBSZXNldDoganVzdCBkZWxldGUgYWxsIG1hcHBpbmdzLCBmcmVlaW5nIHRoZWlyIG1l bW9yeS4gICovDQorICAgICAgZHJpdmVtYXBfbm9kZV90ICpjdXJub2RlID0gZHJpdmVtYXA7DQor ICAgICAgZHJpdmVtYXBfbm9kZV90ICpwcmV2bm9kZSA9IDA7DQorICAgICAgd2hpbGUgKGN1cm5v ZGUpDQorICAgICAgICB7DQorICAgICAgICAgIHByZXZub2RlID0gY3Vybm9kZTsNCisgICAgICAg ICAgY3Vybm9kZSA9IGN1cm5vZGUtPm5leHQ7DQorICAgICAgICAgIGdydWJfZnJlZSAocHJldm5v ZGUpOw0KKyAgICAgICAgfQ0KKyAgICAgIGRyaXZlbWFwID0gMDsNCisgICAgfQ0KKyAgZWxzZQ0K KyAgICB7DQorICAgICAgLyogTmVpdGhlciBmbGFnOiBwdXQgbWFwcGluZy4gICovDQorICAgICAg Z3J1Yl91aW50OF90IG1hcGZyb20gPSAwOw0KKyAgICAgIGdydWJfdWludDhfdCBtYXB0byA9IDB4 RkY7DQorICAgICAgZ3J1Yl9lcnJfdCBlcnI7DQorICAgICAgDQorICAgICAgaWYgKGFyZ2MgIT0g MikNCisgICAgICAgIHJldHVybiBncnViX2Vycm9yIChHUlVCX0VSUl9CQURfQVJHVU1FTlQsICJ0 d28gYXJndW1lbnRzIHJlcXVpcmVkIik7DQorDQorICAgICAgZXJyID0gcGFyc2VfYmlvc2Rpc2sg KGFyZ3NbMF0sICZtYXBmcm9tKTsNCisgICAgICBpZiAoZXJyICE9IEdSVUJfRVJSX05PTkUpDQor ICAgICAgICByZXR1cm4gZXJyOw0KKw0KKyAgICAgIGVyciA9IHRyeXBhcnNlX2Rpc2tzdHJpbmcg KGFyZ3NbMV0sICZtYXB0byk7DQorICAgICAgLyogV2FzIHRoYXQgYSBkaXNrIHN0cmluZz8gSWYg bm90LCBtYXliZSBhIHJhdyBudW0gdGhlbj8gICovDQorICAgICAgaWYgKGVyciAhPSBHUlVCX0VS Ul9OT05FKQ0KKyAgICAgICAgeyAgICANCisgICAgICAgICAgZ3J1Yl9lcnJubyA9IEdSVUJfRVJS X05PTkU7DQorICAgICAgICAgIHVuc2lnbmVkIGxvbmcgbnVtID0gZ3J1Yl9zdHJ0b3VsIChhcmdz WzFdLCAwLCAwKTsNCisgICAgICAgICAgLyogVGhlIGlucHV0IGNvdWxkIGJlIG91dHNpZGUgcmFu Z2UsIG9yIG5vdCBhIG51bWJlciBhdCBhbGwuICAqLw0KKyAgICAgICAgICBpZiAoZ3J1Yl9lcnJu byAhPSBHUlVCX0VSUl9OT05FIHx8IG51bSA+IDB4RkYpDQorICAgICAgICAgICAgcmV0dXJuIGdy dWJfZXJyb3IgKGdydWJfZXJybm8sDQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIlRh cmdldCBzcGVjaWZpZXIgbXVzdCBiZSBvZiB0aGUgZm9ybSAoZmROKSBvciAiDQorICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIihoZE4pLCB3aXRoIDAgPD0gTiA8IDEyODsgb3IgYSBwbGFp biBkZWMvaGV4ICINCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAibnVtYmVyIGJldHdl ZW4gMCBhbmQgMjU1Iik7DQorICAgICAgICAgIGVsc2UgbWFwdG8gPSAoZ3J1Yl91aW50OF90KW51 bTsNCisgICAgICAgIH0NCisgICAgICANCisgICAgICBpZiAobWFwdG8gPT0gbWFwZnJvbSkNCisg ICAgICAgIHsNCisgICAgICAgICAgLyogUmVzZXQgdG8gZGVmYXVsdC4gICovDQorICAgICAgICAg IGdydWJfZHByaW50ZiAoTU9ETkFNRSwgIlJlbW92aW5nIHRoZSBtYXBwaW5nIGZvciAlcyAoJTAy eCkiLCBhcmdzWzBdL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W9yeTogJXUgS2lCXG4iLCAqYnBh X2ZyZWVrYik7DQorICAgICAgdG90YWxfc2l6ZSA9IGdydWJfZHJpdmVtYXBfaW50MTNfc2l6ZQ0K KyAgICAgICAgICAgICAgICAgICArIChlbnRyaWVzICsgMSkgKiBzaXplb2YoaW50MTNtYXBfbm9k ZV90KTsNCisgICAgICBwYXlsb2FkX3NpemVrYiA9ICh0b3RhbF9zaXplID4+IDEwKSArDQorICAg ICAgICAgICAgICAgICAgICAgICAoKCh0b3RhbF9zaXplICUgMTAyNCkgPT0gMCkgPyAwIDogMSk7 DQorICAgICAgaWYgKCgqYnBhX2ZyZWVrYiAtIHBheWxvYWRfc2l6ZWtiKSA8IE1JTl9GUkVFX01F TV9LQikNCisgICAgICAgIHJldHVybiBncnViX2Vycm9yIChHUlVCX0VSUl9PVVRfT0ZfTUVNT1JZ LCAicmVmdXNpbmcgdG8gaW5zdGFsbCINCisgICAgICAgICAgICAgICAgICAgICAgICAgICAiaW50 MTMgaGFuZGxlciwgbm90IGVub3VnaCBmcmVlIG1lbW9yeSBhZnRlciIpOw0KKyAgICAgIGdydWJf ZHByaW50ZiAoTU9ETkFNRSwgIlBheWxvYWQgaXMgJXUgYiBsb25nLCByZXNlcnZpbmcgJXUgS2Jc biIsDQorCQkJCQl0b3RhbF9zaXplLCBwYXlsb2FkX3NpemVrYik7DQorICAgICAgKmJwYV9mcmVl a2IgLT0gcGF5bG9hZF9zaXpla2I7DQorDQorICAgICAgLyogQ29weSBpbnQxM2ggaGFuZGxlciBi dW5kbGUgdG8gcmVzZXJ2ZWQgYXJlYS4gICovDQorICAgICAgaGFuZGxlcl9iYXNlID0gKGdydWJf dWludDhfdCopKCpicGFfZnJlZWtiIDw8IDEwKTsNCisgICAgICBncnViX2RwcmludGYgKE1PRE5B TUUsICJDb3B5aW5nIGludDEzIGhhbmRsZXIgdG86ICVwXG4iLCBoYW5kbGVyX2Jhc2UpOw0KKyAg ICAgIGdydWJfbWVtY3B5IChoYW5kbGVy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aW9uIHRvIHJlcGxhY2UgdGhlIG9sZCBJTlQxM2ggaGFuZGxlci4gSXQg c2hvdWxkIG5vdCBiZQ0KKyAgIGNhbGxlZCBiZWNhdXNlIGl0IGRvZXMgbm90IGZvbGxvdyBhbnkg QyBjYWxsc3BlY3MgYW5kIHJldHVybnMgd2l0aCBJUkVULiAgKi8NCitleHRlcm4gZ3J1Yl9zeW1i b2xfdCBncnViX2RyaXZlbWFwX2ludDEzX2hhbmRsZXI7DQpJbmRleDoga2Vybi9sb2FkZXIuYw0K PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PQ0KLS0tIGtlcm4vbG9hZGVyLmMJKHJldmlzacOzbjogMTc3OSkNCisrKyBrZXJu L2xvYWRlci5jCShjb3BpYSBkZSB0cmFiYWpvKQ0KQEAgLTYxLDExICs2MSw4NSBAQA0KICAgZ3J1 Yl9sb2FkZXJfbG9hZGVkID0gMDsNCiB9DQogDQorc3RydWN0IGhvb2tsaXN0X25vZGUNCit7DQor ICBncnViX2Vycl90ICgqaG9vaykgKHZvaWQpOw0KKyAgaW50IGFib3J0X29uX2Vycm9yOw0KKyAg c3RydWN0IGhvb2tsaXN0X25vZGUgKm5leHQ7DQorfTsNCisNCitzdGF0aWMgc3RydWN0IGhvb2ts aXN0X25vZGUgKnByZWJvb3RfaG9va3MgPSAwOw0KKw0KK2dydWJfcHJlYm9vdF9ob29raWQNCitn cnViX2xvYWRlcl9yZWdpc3Rlcl9wcmVib290IChncnViX2Vycl90ICgqaG9vaykgKHZvaWQpLCBp bnQgYWJvcnRfb25fZXJyb3IpDQorew0KKyAgZ3J1Yl9wcmVib290X2hvb2tpZCBuZXdlbnRyeTsN CisgIGlmICghaG9vaykNCisgICAgew0KKyAgICAgIGdydWJfZXJyb3IgKEdSVUJfRVJSX0JBRF9B UkdVTUVOVCwgInByZWJvb3QgaG9vayBtdXN0IG5vdCBiZSBOVUxMIik7DQorICAgICAgcmV0dXJu IDA7DQorICAgIH0NCisgIG5ld2VudHJ5ID0gZ3J1Yl9tYWxsb2MgKHNpemVvZiAoc3RydWN0IGhv b2tsaXN0X25vZGUpKTsNCisgIGlmICghbmV3ZW50cnkpDQorICAgIHsNCisgICAgICBncnViX2Vy cm9yIChHUlVCX0VSUl9PVVRfT0ZfTUVNT1JZLCAiY2Fubm90IGFsbG9jIGEgaG9va2luZm8gc3Ry dWN0dXJlIik7DQorICAgICAgcmV0dXJuIDA7DQorICAgIH0NCisgIGVsc2UNCisgICAgew0KKyAg ICAgIG5ld2VudHJ5LT5ob29rID0gaG9vazsNCisgICAgICBuZXdlbnRyeS0+YWJvcnRfb25fZXJy b3IgPSBhYm9ydF9vbl9lcnJvcjsNCisgICAgICBuZXdlbnRyeS0+bmV4dCA9IHByZWJvb3RfaG9v a3M7DQorICAgICAgcHJlYm9vdF9ob29rcyA9IG5ld2VudHJ5Ow0KKyAgICAgIHJldHVybiBuZXdl bnRyeTsNCisgICAgfQ0KK30NCisNCit2b2lkDQorZ3J1Yl9sb2FkZXJfdW5yZWdpc3Rlcl9wcmVi b290IChncnViX3ByZWJvb3RfaG9va2lkIGlkKQ0KK3sNCisgIGdydWJfcHJlYm9vdF9ob29raWQg ZW50cnkgPSAwOw0KKyAgZ3J1Yl9wcmVib290X2hvb2tpZCBzZWFyY2ggPSBwcmVib290X2hvb2tz Ow0KKyAgZ3J1Yl9wcmVib290X2hvb2tpZCBwcmV2aW91cyA9IDA7DQorDQorICBpZiAoaWQgPT0g MCkNCisgICAgcmV0dXJuOw0KKw0KKyAgd2hpbGUgKHNlYXJjaCkNCisgICAgew0KKyAgICAgIGlm IChzZWFyY2ggPT0gaWQpDQorICAgICAgICB7DQorICAgICAgICAgIGVudHJ5ID0gc2VhcmNoOw0K KyAgICAgICAgICBicmVhazsNCisgICAgICAgIH0NCisgICAgICBwcmV2aW91cyA9IHNlYXJjaDsN CisgICAgICBzZWFyY2ggPSBzZWFyY2gtPm5leHQ7DQorICAgIH0NCisNCisgIGlmIChlbnRyeSkN CisgICAgew0KKyAgICAgIGlmIChwcmV2aW91cykNCisgICAgICAgIHByZXZpb3VzLT5uZXh0ID0g ZW50cnktPm5leHQ7DQorICAgICAgZWxzZSBwcmVib290X2hvb2tzID0gZW50cnktPm5leHQ7IC8q IEVudHJ5IHdhcyBoZWFkIG9mIGxpc3QgKi8NCisgICAgICBncnViX2ZyZWUgKGVudHJ5KTsNCisg ICAgfQ0KK30NCisNCiBncnViX2Vycl90DQogZ3J1Yl9sb2FkZXJfYm9vdCAodm9pZCkNCiB7DQor ICBncnViX3ByZWJvb3RfaG9va2lkIGVudHJ5ID0gcHJlYm9vdF9ob29rczsNCisNCiAgIGlmICgh IGdydWJfbG9hZGVyX2xvYWRlZCkNCiAgICAgcmV0dXJuIGdydWJfZXJyb3IgKEdSVUJfRVJSX05P X0tFUk5FTCwgIm5vIGxvYWRlZCBrZXJuZWwiKTsNCisgIA0KKyAgd2hpbGUgKGVudHJ5KQ0KKyAg ICB7DQorICAgICAgZ3J1Yl9lcnJfdCBwb3NzaWJsZV9lcnJvciA9IGVudHJ5LT5ob29rKCk7DQor ICAgICAgaWYgKHBvc3NpYmxlX2Vycm9yICE9IEdSVUJfRVJSX05PTkUgJiYgZW50cnktPmFib3J0 X29uX2Vycm9yKQ0KKyAgICAgICAgcmV0dXJuIHBvc3NpYmxlX2Vycm9yOw0KKyAgICAgIGVudHJ5 ID0gZW50cnktPm5leHQ7DQorICAgIH0NCiANCiAgIGlmIChncnViX2xvYWRlcl9ub3JldHVybikN CiAgICAgZ3J1Yl9tYWNoaW5lX2ZpbmkgKCk7DQo= --=-Zl4AbXwRtMXPWLC5S+/c-- --=-TDl1TDumuDD/eOqaK2qY Content-Type: application/pgp-signature; name=signature.asc Content-Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada digitalmente -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iQIVAwUASJiCTaSl+Fbdeo72AQIR6Q//bhy4HeEHY4QuldNOGA3KHhwR3WXBMpGd vCCKN039d8em4xM3pFlbvYYzc5oL3tJzqCLsh9JflPk5/HZv5H+KK4jJ117a9/bf hFg4cXX+ezhCjY7cGZqj2w/ndZ4eQaiF77J5Lmsd2ExJDo+JuMrqQTygbHtIOZM/ 60X+99VJY5C+gL2wV0gFQlHGzKS+zxBT4UZDZJoQmiJwSOwxrlqAeMp8f0emWaCb TBxkgB3DIU6kJPSwou4UyqDA7yxl4pdYtMQFmqCmDbAGUH5lbtLi4EbIleLzaxyl mMWr7Bz7jL+zgYymTBYvkteT1Cl6yArCGXEUTF9Z0vRPphwUo8R52B8OSVOR88O/ hNJ2oVYlOY4wWr5D6MAqCEt12cjlG9Sz5mTBNpVqntqNluKN85K1cJ/VHFR18kln +PTXCMHVqfaA80KxKaXmCIis9UPLXUnNwpHAgtmDeSBXog7XOSvyhxSWzjk4Qtks 97a4XyKlNSO7q7w2e17qMVEnfp5oW5iHUmBorSjoWxhrriveppbaK4U9oCwgt+D1 1GyNmmHLBG0sRwiPzC5iT8Nj1sA2JPZOxfAYfbRWekv0AbtYRMfCw2+d6o95VuGE K80zbGok5dCeN+9lNUTQKPZzG1WvHpvEDU4uIfty96KAt1cSEKklIbJwsNXxGLj0 eFh+QyL/8lo= =6mfx -----END PGP SIGNATURE----- --=-TDl1TDumuDD/eOqaK2qY--