summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2011-05-31 17:36:51 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2011-05-31 17:36:53 +0200
commit591ac4ebcf7fb4f474c2dadde1f5f0a9d8d48676 (patch)
tree9749c55292787e1181ce2271f19854e968aa756a
parent3397f26759acf34fe0433a8833e4e0101d3d7b20 (diff)
downloadptxdist-591ac4ebcf7fb4f474c2dadde1f5f0a9d8d48676.tar.gz
ptxdist-591ac4ebcf7fb4f474c2dadde1f5f0a9d8d48676.tar.xz
genpart: add patch to set heads cylinders and sectors
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r--patches/genpart-1.0.2/0001-setup-heads-cylinders-and-sectors.patch76
-rw-r--r--patches/genpart-1.0.2/series3
2 files changed, 79 insertions, 0 deletions
diff --git a/patches/genpart-1.0.2/0001-setup-heads-cylinders-and-sectors.patch b/patches/genpart-1.0.2/0001-setup-heads-cylinders-and-sectors.patch
new file mode 100644
index 000000000..f1583cdeb
--- /dev/null
+++ b/patches/genpart-1.0.2/0001-setup-heads-cylinders-and-sectors.patch
@@ -0,0 +1,76 @@
+From: Michael Olbrich <m.olbrich@pengutronix.de>
+Date: Tue, 31 May 2011 16:11:10 +0200
+Subject: [PATCH] setup heads, cylinders and sectors
+
+"heads per cylinder" and "sectors per track" are just a guess.
+It seems to work with typical SD-Cards. And unused partitions
+are shown as such now.
+
+Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
+---
+ src/genpart.c | 24 ++++++++++++++++++------
+ 1 files changed, 18 insertions(+), 6 deletions(-)
+
+diff --git a/src/genpart.c b/src/genpart.c
+index 6c11b91..49be9d7 100644
+--- a/src/genpart.c
++++ b/src/genpart.c
+@@ -7,12 +7,12 @@ struct partition_entry {
+ unsigned char boot;
+
+ unsigned char start_head;
+- unsigned short start_cyl_sec;
++ unsigned char start_cyl_sec[2];
+
+ unsigned char part_type;
+
+ unsigned char end_head;
+- unsigned short end_cyl_sec;
++ unsigned char end_cyl_sec[2];
+
+ unsigned int relative_sectors;
+ unsigned int total_sectors;
+@@ -35,6 +35,19 @@ void print_usage(void)
+ );
+ }
+
++void setup_head_cyl_sec(unsigned int lba, unsigned char *head, unsigned char *cyl_sec)
++{
++ const unsigned int hpc = 255;
++ const unsigned int spt = 63;
++ unsigned int s, c;
++
++ *head = (lba/spt)%hpc;
++ c = (lba/(spt * hpc));
++ s = (lba > 0) ?(lba%spt + 1) : 0;
++ cyl_sec[0] = ((c & 0x300) >> 2) | (s & 0xff);
++ cyl_sec[1] = (c & 0xff);
++}
++
+ int main(int argc, char *argv[])
+ {
+ struct partition_entry entry;
+@@ -60,10 +73,6 @@ int main(int argc, char *argv[])
+ memset(&entry, 0, sizeof(struct partition_entry));
+
+ entry.part_type = 0x83; /* default to linux */
+- entry.start_head = 0xff;
+- entry.start_cyl_sec = 0xffff;
+- entry.end_head = 0xff;
+- entry.end_cyl_sec = 0xffff;
+
+ while ((opt = getopt_long(argc, argv, "hb:s:ct:m", long_options, NULL)) != -1) {
+ switch (opt) {
+@@ -87,6 +96,9 @@ int main(int argc, char *argv[])
+ break;
+ }
+ }
++ setup_head_cyl_sec(entry.relative_sectors, &entry.start_head, entry.start_cyl_sec);
++ setup_head_cyl_sec((entry.total_sectors > 0) ? (entry.relative_sectors + entry.total_sectors - 1) : 0,
++ &entry.end_head, entry.end_cyl_sec);
+
+ if (fwrite(&entry, sizeof(struct partition_entry), 1, stdout) > 0) {
+ if (do_magic) {
+--
+1.7.5.3
+
diff --git a/patches/genpart-1.0.2/series b/patches/genpart-1.0.2/series
new file mode 100644
index 000000000..91b5bfe2d
--- /dev/null
+++ b/patches/genpart-1.0.2/series
@@ -0,0 +1,3 @@
+# generated by git-ptx-patches
+0001-setup-heads-cylinders-and-sectors.patch
+# 4991f55ab2436333443eb4a18b740510 - git-ptx-patches magic