Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ffSOB-0001mk-RL for mharc-grub-devel@gnu.org; Tue, 17 Jul 2018 11:59:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffSO8-0001l2-U4 for grub-devel@gnu.org; Tue, 17 Jul 2018 11:59:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffSO5-0003SL-Po for grub-devel@gnu.org; Tue, 17 Jul 2018 11:59:45 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:36382) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffSO5-0003R3-HZ for grub-devel@gnu.org; Tue, 17 Jul 2018 11:59:41 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w6HFrvUj162329; Tue, 17 Jul 2018 15:59:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=content-type : mime-version : subject : from : in-reply-to : date : cc : content-transfer-encoding : message-id : references : to; s=corp-2018-07-02; bh=tuj856FZ1sJkFczAsF/vUxQAzI9YVsLqwFM56d8FNKc=; b=xWJIOFCTMwT1X4kemIvpKIBGWMXUmE1wyTfObkL994jpxMdNN+m8yi46AvAAVgn6aMs8 ifSuDOo0gWZjhvx56IgAIsLW6D4xSvVLGBHxh7g63qWaDxEO8a6ol/I7LRMMO1cfN4oz Gsqjy4HD+3AjUGOKCKGEf//Hz0rcle2FhZJ7r9uB3ghCtuCC0ga33a+jDwlK24VWiTL9 AZp2rqpEJUvxvlFglF8Bood456h2QgIRJLtjOKewNnFaU+kFQuvUtzgTXsRwhIzu0McF Y+PNsKabVIOTscKGbYl1L8pPjohRj3BsAA6+QOykW10bF6a5+nImyBfCVFy/svlawQbW oA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2k7a341d7p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Jul 2018 15:59:38 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w6HFxamg000629 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Jul 2018 15:59:37 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w6HFxalG031175; Tue, 17 Jul 2018 15:59:36 GMT Received: from [10.39.239.156] (/10.39.239.156) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 17 Jul 2018 08:59:36 -0700 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH v2] ieee1275: obdisk driver From: Eric Snowberg In-Reply-To: <20180717133857.GI26572@olila.local.net-space.pl> Date: Tue, 17 Jul 2018 09:59:33 -0600 Cc: John Paul Adrian Glaubitz , Daniel Kiper Content-Transfer-Encoding: quoted-printable Message-Id: <465A56C4-8481-4DEC-9367-A64CB7A82B31@oracle.com> 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> <20180717133857.GI26572@olila.local.net-space.pl> To: The development of GNU GRUB X-Mailer: Apple Mail (2.3273) 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-1807170167 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 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 15:59:46 -0000 > On Jul 17, 2018, at 7:38 AM, Daniel Kiper = wrote: >=20 > On Mon, Jul 16, 2018 at 09:33:17AM -0600, Eric Snowberg wrote: >>> On Jul 16, 2018, at 7:51 AM, Daniel Kiper = wrote: >>>=20 >>> Sorry for late reply but I was busy with other stuff. >>>=20 >>> 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: >>>=20 >>> [...] >>>=20 >>>>>>>> +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) >>>>>>>=20 >>>>>>> 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? >>>>>>=20 >>>>>> I=E2=80=99m open for recommendations. >>>>>=20 >>>>> Great! However, I need more info which layer need what WRT ",=E2=80=9D= , >>>>=20 >>>> AFAIK all layers above expect it: >>>> = https://www.gnu.org/software/grub/manual/grub/grub.html#Device-syntax >>>>=20 >>>> Everything above this driver expects it to be escaped. Obviously = when >>>=20 >>> Do you mean from the command line? >>=20 >> 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 >=20 > This is the last line of the file. So, I am not sure what exactly you = mean. >=20 >> /* 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; >>=20 >> while ((c =3D *p++) !=3D '\0') >> { >> if (c =3D=3D '\\' && *p =3D=3D ',') >> p++; >> else if (c =3D=3D ',') >> return p - 1; >> } >> return NULL; >> } >=20 > OK, this one. >=20 >> 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. >=20 > Then we need proper escaping. And AIUI your driver does that. >=20 >>> If yes could you give an example with >>> proper escaping? >>>=20 >>>> the driver talks to the actual hardware these devices can not have = the >>>> escaped names. >>>=20 >>> OK but this is not clear. So, please add a comment explaining it in >>> the code somewhere. >>=20 >> Ok >>=20 >>>=20 >>>>> how often this conversions must be done, why you have chosen that >>>>> solution, etc. Then I will try to optimize solution a bit. >>>>=20 >>>> Under normal circumstances it only takes place once per disk as = they >>>> are enumerated. All disks are cached within this driver so it = should >>>> 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 = current >>>> driver. >>>=20 >>> 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/, >>=20 >>> - extract unscaping code to the unescape_commas() function; >>> even if it is called once; just for the completeness. >>=20 >> Ok >>=20 >>>=20 >>> What is replace_escaped_commas()? Why do we need that function? >>=20 >> 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. >=20 > 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. The confusion seems to be around what needs to be escaped and what = doesn=E2=80=99t, as can be seen from the discussion within this email. = This change makes it convenient for the end-user, since they will not = need to understand any of this.=20 When function grub_obdisk_iterate (defined as .iterate within = grub_disk_dev) gets called, it returns the disks the driver controls. = As explained within the description of this patch, a single IEEE1275 = disk can have over 6 names. When the .iterate function is called, only = a single drive can be returned. If the disk that is to be returned = contains \\, within the name, they are replaced with __. Then for = example, the end-user will see something like this following a ls: grub> ls (ieee1275//pci@308/pci@1/usb@0/hub@1/storage@3/disk@0__0) = (ieee1275//pci@308/pc i@1/usb@0/hub@1/storage@3/disk@0__0,gpt1) = (ieee1275//pci@306/pci@1/LSI__mrsas@0 /disk@0__0) (ieee1275//pci@306/pci@1/LSI__mrsas@0/disk@0__0,gpt3) = (ieee1275//pc i@306/pci@1/LSI__mrsas@0/disk@0__0,gpt2) = (ieee1275//pci@306/pci@1/LSI__mrsas@0/ disk@0__0,gpt1) The end-user can now type the disk name exactly as it is returned on the = screen. Or they can escape any of the real disk names properly and the = driver will understand it is the same disk. Do you really want this = removed?