From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1OSEmQ-0002O7-FA for mharc-grub-devel@gnu.org; Fri, 25 Jun 2010 15:41:38 -0400 Received: from [140.186.70.92] (port=45137 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OSEmL-0002LA-FD for grub-devel@gnu.org; Fri, 25 Jun 2010 15:41:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OSEmK-0005sm-3p for grub-devel@gnu.org; Fri, 25 Jun 2010 15:41:33 -0400 Received: from mail-bw0-f41.google.com ([209.85.214.41]:37382) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OSEmJ-0005sc-Ul for grub-devel@gnu.org; Fri, 25 Jun 2010 15:41:32 -0400 Received: by bwz4 with SMTP id 4so3515640bwz.0 for ; Fri, 25 Jun 2010 12:41:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :x-enigmail-version:content-type; bh=ICOD9qj41AHhqLr4LNLO8YVIZxBrzjy6r88LVA4wFzo=; b=uyuEj+bSh6G9vrK0L3JffDzji9Np/ffvQeYPeebl0qwVUNdgzcxgQkxf9cNLAxalf2 KeRczV3QZfgqLVtaOyHCBgoG25wP4WRCAHNoaAf0N+2js6IUMJMZo4tG3YDjnnDR7GM2 PWniNsneksjtMdlFQ1uPVDVWH0CLcHmXfdqUc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type; b=dbDYPVkslnNBICm95qJYTXyBySwoLQhfHpXLBiXRsFryjvUVYF6ByCHfeciDIA8Vug /rhP7XJbz5bunfbdeVqa4DOy7uteX3YsubVP61ApsKxbZbchCfUZo3NTRKv7Q+rZ2Fve jVMovsznaV7366mwNHOAkb/+xfSFXgHRXp2L0= Received: by 10.204.160.145 with SMTP id n17mr856203bkx.67.1277494890806; Fri, 25 Jun 2010 12:41:30 -0700 (PDT) Received: from debian.bg45.phnet ([81.62.156.217]) by mx.google.com with ESMTPS id u3sm5347494bkz.12.2010.06.25.12.41.29 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 25 Jun 2010 12:41:29 -0700 (PDT) Message-ID: <4C24F998.2010706@gmail.com> Date: Fri, 25 Jun 2010 20:46:48 +0200 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100515 Icedove/3.0.4 MIME-Version: 1.0 To: grub-devel@gnu.org References: <20100621093430.GM21862@riva.ucam.org> In-Reply-To: <20100621093430.GM21862@riva.ucam.org> X-Enigmail-Version: 1.0.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enigC3860EB1F44FA38697BFF57B" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [RFC] [PATCH] Generate stable device names in device.map on Linux X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 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: Fri, 25 Jun 2010 19:41:34 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigC3860EB1F44FA38697BFF57B Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > > =3D=3D=3D modified file 'util/deviceiter.c' > --- util/deviceiter.c 2010-06-11 20:31:16 +0000 > +++ util/deviceiter.c 2010-06-21 08:54:07 +0000 > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > =20 > #include > #include > @@ -345,18 +346,37 @@ get_xvd_disk_name (char *name, int unit) > } > #endif > =20 > +static struct seen_device > +{ > + struct seen_device *next; > + const char *name; > +} *seen; > + > /* Check if DEVICE can be read. If an error occurs, return zero, > otherwise return non-zero. */ > static int > check_device (const char *device) > { > =20 This patch subtly changes the semantics of this function. It's a static one so the ramifications are relatively small. But you need at very least to resync the comment and changing name when changing semantics is recommended. > @@ -441,6 +483,8 @@ grub_util_iterate_devices (int NESTED_FU > { > int i; > =20 > + clear_seen_devices (); > + > /* Floppies. */ > for (i =3D 0; i < floppy_disks; i++) > { > @@ -453,10 +497,56 @@ grub_util_iterate_devices (int NESTED_FU > /* In floppies, write the map, whether check_device succeeds > or not, because the user just may not insert floppies. */ > if (hook (name, 1)) > - return; > + goto out; > } > =20 > #ifdef __linux__ > + { > + DIR *dir =3D opendir ("/dev/disk/by-id"); > + > + if (dir) > + { > + struct dirent *entry; > + char **names; > + size_t names_len =3D 0, names_max =3D 1024, i; > + > + names =3D xmalloc (names_max * sizeof *names); > + > =20 Please use parentheses for sizeof > + qsort (names, names_len, sizeof *names, &compare_file_names); > + > =20 Which part of code uses that array is sorted? > + closedir (dir); > + > + /* Now add all the devices in sorted order. */ > + for (i =3D 0; i < names_len; ++i) > + { > + char *path =3D xasprintf ("/dev/disk/by-id/%s", names[i]); > + if (check_device (path)) > + { > + if (hook (path, 0)) > + goto out; > + } > + free (path); > + free (names[i]); > + } > + free (names); > + } > + } > + > if (have_devfs ()) > { > i =3D 0; > =20 --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------enigC3860EB1F44FA38697BFF57B Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREKAAYFAkwk+ZgACgkQNak7dOguQglbZAD/VwGqzjz5u2cjPeQ155QSJ/l2 Z2FF4+ffgRsJsin+VDAA/Rpsk2v7jcbvB0Hl+66rJTNF4uEyHjUYw8T+1n4JzPnj =no67 -----END PGP SIGNATURE----- --------------enigC3860EB1F44FA38697BFF57B--