From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vej4p-0007tB-O5 for barebox@lists.infradead.org; Fri, 08 Nov 2013 10:14:08 +0000 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Fri, 8 Nov 2013 11:13:41 +0100 Message-Id: <1383905621-29034-1-git-send-email-u.kleine-koenig@pengutronix.de> In-Reply-To: <20131108005153.GA14892@pengutronix.de> References: <20131108005153.GA14892@pengutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v2] partitions: dos: parse extended partition To: barebox@lists.infradead.org RE9TIE1CUnMgbWlnaHQgY29udGFpbiBhbiBleHRlbmRlZCBwYXJ0aXRpb24gdGhhdCBob2xkcyBz ZXZlcmFsIGxvZ2ljYWwKcGFydGl0aW9ucy4gQWRkIHRoZXNlIHRvIHRoZSBwYXJ0aXRpb25zIG9m IHRoZSBibG9jayBkZXZpY2UuCgpTaWduZWQtb2ZmLWJ5OiBVd2UgS2xlaW5lLUvDtm5pZyA8dS5r bGVpbmUta29lbmlnQHBlbmd1dHJvbml4LmRlPgotLS0KIGNvbW1vbi9wYXJ0aXRpb25zL2Rvcy5j IHwgNzYgKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrLQog MSBmaWxlIGNoYW5nZWQsIDc1IGluc2VydGlvbnMoKyksIDEgZGVsZXRpb24oLSkKCmRpZmYgLS1n aXQgYS9jb21tb24vcGFydGl0aW9ucy9kb3MuYyBiL2NvbW1vbi9wYXJ0aXRpb25zL2Rvcy5jCmlu ZGV4IDY0MzE0YTguLjM3Y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