Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ffQCB-0004Vs-V6 for mharc-grub-devel@gnu.org; Tue, 17 Jul 2018 09:39:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffQC5-0004Sh-OZ for grub-devel@gnu.org; Tue, 17 Jul 2018 09:39:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffQC0-0004mi-MH for grub-devel@gnu.org; Tue, 17 Jul 2018 09:39:09 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:50800) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffQC0-0004lk-AK for grub-devel@gnu.org; Tue, 17 Jul 2018 09:39:04 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w6HDcnWs038659; Tue, 17 Jul 2018 13:39:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : content-transfer-encoding : in-reply-to; s=corp-2018-07-02; bh=3sITxt4DE8QMtAxviPTeUkDzXEtP9h9RUv99zIpXvlc=; b=PrjoPrmipIhfcRiVof4doSnf+v8M6bXReVHQgHjDwsE4W7rjd4O7L0DJOUORvA4cBwDj JaWJVuif3k0lk3jIMFyEJXe+PykC2cqjkY5Q5D+Myj5rFYSZzCeS8D+Bdwo+GGl8bxo5 dBI6K85MhPZfOl09aueFPwaBsCW46VUhRaLbaZhI0WrBWp7unQAnXrQIyu/tqowAv5d2 CZ8VQCLIkHOPs6jyniBTzXbIOcWWHB0UuD2+5XnKFeIphwEaPUmNH8lrUcczug0Cxums k/rHp5kjGbLWjpwUutzH1yeCn7a0rKb58SA0KH/EwvACjCyv1JiUM9/SfFvrRpjZgoYs 5g== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2k7a3t0r0x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Jul 2018 13:39:02 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w6HDd2HV009336 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Jul 2018 13:39:02 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w6HDd1Mf001223; Tue, 17 Jul 2018 13:39:01 GMT Received: from olila.local.net-space.pl (/10.175.168.136) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 17 Jul 2018 06:39:00 -0700 Date: Tue, 17 Jul 2018 15:38:57 +0200 From: Daniel Kiper To: Eric Snowberg Cc: The development of GNU GRUB , John Paul Adrian Glaubitz Subject: Re: [PATCH v2] ieee1275: obdisk driver Message-ID: <20180717133857.GI26572@olila.local.net-space.pl> References: <1527724522-32305-1-git-send-email-eric.snowberg@oracle.com> <20180615120218.GO20016@olila.local.net-space.pl> <3C2AB209-D05C-4C0C-B2D9-FF3C0AD7B2E7@oracle.com> <20180621165822.GA20016@olila.local.net-space.pl> <20180716135117.GF26572@olila.local.net-space.pl> <0F674D8E-77C2-4208-8C50-1B5D0A0C4866@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <0F674D8E-77C2-4208-8C50-1B5D0A0C4866@oracle.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8956 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807170144 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by aserp2130.oracle.com id w6HDcnWs038659 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.79 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jul 2018 13:39:14 -0000 On Mon, Jul 16, 2018 at 09:33:17AM -0600, Eric Snowberg wrote: > > On Jul 16, 2018, at 7:51 AM, Daniel Kiper w= rote: > > > > Sorry for late reply but I was busy with other stuff. > > > > On Thu, Jun 21, 2018 at 01:46:46PM -0600, Eric Snowberg wrote: > >>> On Jun 21, 2018, at 10:58 AM, Daniel Kiper wrote: > >>> On Fri, Jun 15, 2018 at 09:58:56AM -0600, Eric Snowberg wrote: > >>>>> On Jun 15, 2018, at 6:02 AM, Daniel Kiper wrote: > >>>>> On Wed, May 30, 2018 at 04:55:22PM -0700, Eric Snowberg wrote: > > > > [...] > > > >>>>>> +static char * > >>>>>> +replace_escaped_commas (char *src) > >>>>>> +{ > >>>>>> + char *iptr; > >>>>>> + > >>>>>> + if (src =3D=3D NULL) > >>>>>> + return NULL; > >>>>>> + for (iptr =3D src; *iptr; ) > >>>>>> + { > >>>>>> + if ((*iptr =3D=3D '\\') && (*(iptr + 1) =3D=3D ',')) > >>>>>> + { > >>>>>> + *iptr++ =3D '_'; > >>>>>> + *iptr++ =3D '_'; > >>>>>> + } > >>>>>> + iptr++; > >>>>>> + } > >>>>>> + > >>>>>> + return src; > >>>>>> +} > >>>>>> + > >>>>>> +static int > >>>>>> +count_commas (const char *src) > >>>>>> +{ > >>>>>> + int count =3D 0; > >>>>>> + > >>>>>> + for ( ; *src; src++) > >>>>>> + if (*src =3D=3D ',') > >>>>>> + count++; > >>>>>> + > >>>>>> + return count; > >>>>>> +} > >>>>>> + > >>>>>> +static void > >>>>>> +escape_commas (const char *src, char *dest) > >>>>> > >>>>> I am confused by this play with commas. Could explain somewhere > >>>>> where this commas are needed unescaped, escaped, replaced, etc. > >>>>> Could not we simplify this somehow? > >>>> > >>>> I=E2=80=99m open for recommendations. > >>> > >>> Great! However, I need more info which layer need what WRT ",=E2=80= =9D, > >> > >> AFAIK all layers above expect it: > >> https://www.gnu.org/software/grub/manual/grub/grub.html#Device-synta= x > >> > >> Everything above this driver expects it to be escaped. Obviously wh= en > > > > Do you mean from the command line? > > This goes much further than the command line. For example, it is > built right into the disk driver. Look at grub-core/kern/disk.c: 544 This is the last line of the file. So, I am not sure what exactly you mea= n. > /* Return the location of the first ',', if any, which is not > escaped by a '\'. */ > static const char * > find_part_sep (const char *name) > { > const char *p =3D name; > char c; > > while ((c =3D *p++) !=3D '\0') > { > if (c =3D=3D '\\' && *p =3D=3D ',') > p++; > else if (c =3D=3D ',') > return p - 1; > } > return NULL; > } OK, this one. > When the obdisk driver discovers a disk, it must put the disk name in > the proper format. Otherwise when grub_disk_open takes place later > on, the wrong disk name will eventually get sent back to the obdisk > driver. Then we need proper escaping. And AIUI your driver does that. > > If yes could you give an example with > > proper escaping? > > > >> the driver talks to the actual hardware these devices can not have t= he > >> escaped names. > > > > OK but this is not clear. So, please add a comment explaining it in > > the code somewhere. > > Ok > > > > >>> how often this conversions must be done, why you have chosen that > >>> solution, etc. Then I will try to optimize solution a bit. > >> > >> Under normal circumstances it only takes place once per disk as they > >> are enumerated. All disks are cached within this driver so it shou= ld > >> not happen often. That is why I store both versions so I don=E2=80=99= t have > >> to go back and forth. Look at the current driver ofdisk. It has a > >> function called compute_dev_path which does this conversion on every > >> single open (grub_ofdisk_open). That does not happen with this new > >> driver. IMHO this is a much more optimized solution than the curren= t > >> driver. > > > > Then OK. However, this have to be explained somewhere in the code. > > Additionally, I think that proper variable naming would help too, > > e.g. name and name_esc. And I would do this: > > - s/decode_grub_devname/unescape_grub_devnam/, > > - s/encode_grub_devname/escape_grub_devname/, > > > - extract unscaping code to the unescape_commas() function; > > even if it is called once; just for the completeness. > > Ok > > > > > What is replace_escaped_commas()? Why do we need that function? > > It is a convenience function for the end-user, so they can access a > disk without having to understand all this escaping when they want to > use one thru the shell. I think that this will introduce more confusion. I would like that escaping of drive paths should be properly explained in GRUB docs. Including why it is needed. And replace_escaped_commas() should be dropped. Daniel