From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zvdv1-0006W3-5S for mharc-grub-devel@gnu.org; Sun, 08 Nov 2015 23:18:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zvdux-0006RY-WE for grub-devel@gnu.org; Sun, 08 Nov 2015 23:18:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zvduu-0005zK-QB for grub-devel@gnu.org; Sun, 08 Nov 2015 23:18:55 -0500 Received: from mail-lf0-x22f.google.com ([2a00:1450:4010:c07::22f]:36816) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zvduu-0005zG-Ig for grub-devel@gnu.org; Sun, 08 Nov 2015 23:18:52 -0500 Received: by lfs39 with SMTP id 39so63160472lfs.3 for ; Sun, 08 Nov 2015 20:18:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=DHHTGUvDd9ZFoFO1FDrzhTuxfHTHiV28nhnwP4s/dZA=; b=CpAAba1/A5stY0NLs2j9hQF/HoVS/UzXNMrWvd7YnXORcdK692bwKAdtGh/5RbSpmD YeIbEBgt07Mu+WVOrZ5z9SE5nBzKhtuqLyEGxNmSto2JmhmPQWkEgCYS/FrNDlDqbp2t KYAxg2cB3pwipPFtHS57vZKM4HGHoxiyjY5XXZbiIUkte0+opcmZjKcKKNEDt/udguua sN+KEuk2hAxuqpYJKETWro9iRX7+CFqKdaDtocMEHms5BoF08xkAg2VAiBx8SrHGtmJH v44Jy4BopxgSpVueKF0wZwo9STdthMhborFzqpgI7GYSe+ZaPOEk4B2tbqo0hUDDaXgm A0mg== X-Received: by 10.25.7.4 with SMTP id 4mr884556lfh.107.1447042731679; Sun, 08 Nov 2015 20:18:51 -0800 (PST) Received: from [192.168.1.41] (ppp91-76-25-247.pppoe.mtu-net.ru. [91.76.25.247]) by smtp.gmail.com with ESMTPSA id pm6sm2018956lbc.1.2015.11.08.20.18.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Nov 2015 20:18:50 -0800 (PST) Subject: Re: [PATCH v2] ofdisk: add sas disks to the device list To: Paulo Flabiano Smorigo , The development of GNU GRUB References: <1447032550-8854-1-git-send-email-pfsmorigo@linux.vnet.ibm.com> From: Andrei Borzenkov Message-ID: <56401EA9.1070203@gmail.com> Date: Mon, 9 Nov 2015 07:18:49 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1447032550-8854-1-git-send-email-pfsmorigo@linux.vnet.ibm.com> Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c07::22f X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Nov 2015 04:18:57 -0000 09.11.2015 04:29, Paulo Flabiano Smorigo пишет: > All SAS disks attached will be added to the device list. This is the second > version of a patch that I send a while ago [1]. > > [1] https://lists.gnu.org/archive/html/grub-devel/2015-08/msg00000.html > > --- > grub-core/disk/ieee1275/ofdisk.c | 76 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 76 insertions(+) > > diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c > index 297f058..afec9ba 100644 > --- a/grub-core/disk/ieee1275/ofdisk.c > +++ b/grub-core/disk/ieee1275/ofdisk.c > @@ -260,6 +260,82 @@ dev_iterate (const struct grub_ieee1275_devalias *alias) > grub_free (buf); > return; > } > + else if (grub_strcmp (alias->type, "sas_ioa") == 0) > + { > + /* The method returns the number of disks and a table where > + * each ID is 64-bit long. Example of sas paths: > + * /pci@80000002000001f/pci1014,034A@0/sas/disk@c05db70800 > + * /pci@80000002000001f/pci1014,034A@0/sas/disk@a05db70800 > + * /pci@80000002000001f/pci1014,034A@0/sas/disk@805db70800 */ Did you omit last 3 bytes on purpose? Out of curiosity - is it really true that SAS address is written backwards (at least, I assume this is SAS address)? > + > + struct sas_children > + { > + struct grub_ieee1275_common_hdr common; > + grub_ieee1275_cell_t method; > + grub_ieee1275_cell_t ihandle; > + grub_ieee1275_cell_t max; > + grub_ieee1275_cell_t table; > + grub_ieee1275_cell_t catch_result; > + grub_ieee1275_cell_t nentries; > + } > + args; > + char *buf, *bufptr, *table; > + unsigned i; > + grub_uint32_t table_size; > + grub_ieee1275_ihandle_t ihandle; > + > + buf = grub_malloc (grub_strlen (alias->path) > + + sizeof ("/disk@7766554433221100")); > + if (!buf) > + return; > + > + /* 64 entries should be enough */ > + table_size = sizeof (grub_uint64_t) * 64; > + table = grub_malloc (table_size); > + > + if (!table) > + { > + grub_free (buf); > + return; > + } > + > + bufptr = grub_stpcpy (buf, alias->path); > + > + if (grub_ieee1275_open (alias->path, &ihandle)) > + { > + grub_free (buf); > + grub_free (table); > + return; > + } > + > + INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 2); > + args.method = (grub_ieee1275_cell_t) "get-sas-children"; > + args.ihandle = ihandle; > + args.max = table_size; > + args.table = (grub_ieee1275_cell_t) table; > + args.catch_result = 0; > + args.nentries = 0; > + > + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) > + { > + grub_ieee1275_close (ihandle); > + grub_free (table); > + grub_free (buf); > + return; > + } > + > + grub_uint64_t *ptr; > + for (i = 0; i < args.nentries; i++) > + { > + ptr = (grub_uint64_t *) (table + sizeof (grub_uint64_t) * i); > + grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, *ptr); > + dev_iterate_real (buf, buf); > + } > + > + grub_ieee1275_close (ihandle); > + grub_free (table); > + grub_free (buf); > + } > > if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS) > && grub_strcmp (alias->type, "block") == 0) >