From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZwZFf-0003jY-1h for mharc-grub-devel@gnu.org; Wed, 11 Nov 2015 12:32:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwZDb-0002OA-N7 for grub-devel@gnu.org; Wed, 11 Nov 2015 12:32:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwZBm-0003uJ-QW for grub-devel@gnu.org; Wed, 11 Nov 2015 12:29:59 -0500 Received: from mail-lf0-x22b.google.com ([2a00:1450:4010:c07::22b]:34930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwZBm-0003uB-JR for grub-devel@gnu.org; Wed, 11 Nov 2015 12:28:06 -0500 Received: by lfdo63 with SMTP id o63so20040485lfd.2 for ; Wed, 11 Nov 2015 09:28:05 -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=c2f9kgttgNhloOkr/rqB7J/eaSAFUZCY3f0Hr4Mr2Zc=; b=FBwbPs7aVbcNQWPz929r0dqVnxEV3d7CKBUyuYfNo1Bqg0Lc3kW8Ox4qQTeNsY5xV0 oQn+l9zgP7SIS0QrySbZvb1zddyTz/GF1Glm4hxCu2304CCIRH1+T7bSvGI+cQyIM08z eypMPmhGc4lztOLf6lg6S7GArtLD38B+ZMSU0vJEE0o6QywE98YMTUqQ8Sp33ogMBYMC NMeZwc6nqmv6wCFdckSTyAlJOlKV2Dn+J0REGI+Jck15QGASl9mJ8sXP0ZHhxVmpwOnk quOGy4MsHAgAJhDpaUBNFMSzrZm3nzGKutjvcwAdJtsuuzvrlrbTCfEZMMK3J65S2r2z HvSg== X-Received: by 10.25.33.85 with SMTP id h82mr5070962lfh.16.1447262885755; Wed, 11 Nov 2015 09:28:05 -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 kk6sm1602147lbc.48.2015.11.11.09.28.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2015 09:28:04 -0800 (PST) Subject: Re: [PATCH v4] ofdisk: add sas disks to the device list To: grub-devel@gnu.org References: <1447247672-20823-1-git-send-email-pfsmorigo@linux.vnet.ibm.com> From: Andrei Borzenkov Message-ID: <56437AA3.6060102@gmail.com> Date: Wed, 11 Nov 2015 20:28:03 +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: <1447247672-20823-1-git-send-email-pfsmorigo@linux.vnet.ibm.com> Content-Type: text/plain; charset=UTF-8; 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::22b 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: Wed, 11 Nov 2015 17:32:05 -0000 11.11.2015 16:14, Paulo Flabiano Smorigo пишет: > Same patch with the fix. > --- > grub-core/disk/ieee1275/ofdisk.c | 75 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 75 insertions(+) > > diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c > index 297f058..ef290bc 100644 > --- a/grub-core/disk/ieee1275/ofdisk.c > +++ b/grub-core/disk/ieee1275/ofdisk.c > @@ -260,6 +260,81 @@ 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 */ > + > + 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_uint16_t table_size; > + grub_ieee1275_ihandle_t ihandle; > + > + buf = grub_malloc (grub_strlen (alias->path) + 32); Actually I liked previous version more :) Magic hidden constants are always error prone. > + if (!buf) > + return; > + bufptr = grub_stpcpy (buf, alias->path); > + > + /* Power machines documentation specify 672 as maximum SAS disks in > + one system. Using a slightly larger value to be safe. */ > + table_size = 768; > + table = grub_malloc (table_size * sizeof (grub_uint64_t)); > + > + if (!table) > + { > + grub_free (buf); > + return; > + } > + > + 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); What about grub_snprintf (bufptr, sizeof ("/disk@7766554433221100"), ... ) > + 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) >