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 1VeZlu-0006om-5p for barebox@lists.infradead.org; Fri, 08 Nov 2013 00:17:59 +0000 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Fri, 8 Nov 2013 01:17:26 +0100 Message-Id: <1383869846-26033-1-git-send-email-u.kleine-koenig@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] partitions: dos: parse extended partition To: barebox@lists.infradead.org Cc: jbe@pengutronix.de RE9TIE1CUnMgbWlnaHQgY29udGFpbiBhbiBleHRlbmRlZCBwYXJ0aXRpb24gdGhhdCBob2xkcyBz ZXZlcmFsIGxvZ2ljYWwKcGFydGl0aW9ucy4gQWRkIHRoZXNlIHRvIHRoZSBwYXJ0aXRpb25zIG9m IHRoZSBibG9jayBkZXZpY2UuCgpTaWduZWQtb2ZmLWJ5OiBVd2UgS2xlaW5lLUvDtm5pZyA8dS5r bGVpbmUta29lbmlnQHBlbmd1dHJvbml4LmRlPgotLS0KIGNvbW1vbi9wYXJ0aXRpb25zL2Rvcy5j IHwgNzYgKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrLQog MSBmaWxlIGNoYW5nZWQsIDc1IGluc2VydGlvbnMoKyksIDEgZGVsZXRpb24oLSkKCmRpZmYgLS1n aXQgYS9jb21tb24vcGFydGl0aW9ucy9kb3MuYyBiL2NvbW1vbi9wYXJ0aXRpb25zL2Rvcy5jCmlu ZGV4IDFkODIxM2IuLmY5MDdhYmMgMTAwNjQ0Ci0tLSBhL2NvbW1vbi9wYX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