aboutsummaryrefslogtreecommitdiffstats
path: root/com32/chain/utility.c
diff options
context:
space:
mode:
authorMichal Soltys <soltys@ziu.info>2010-08-28 13:20:31 +0200
committerMichal Soltys <soltys@ziu.info>2010-09-28 09:32:52 +0200
commitd4cbb325b3ef7e999ccf8ed9ac5fe8da102ab5f4 (patch)
tree139ee57fd29466b04bba7b0899657693d0dd71d3 /com32/chain/utility.c
parent0d591b9348e43cf59cd4857dcc0e9029566d96e5 (diff)
downloadsyslinux-d4cbb325b3ef7e999ccf8ed9ac5fe8da102ab5f4.tar.gz
syslinux-d4cbb325b3ef7e999ccf8ed9ac5fe8da102ab5f4.tar.xz
syslinux-d4cbb325b3ef7e999ccf8ed9ac5fe8da102ab5f4.zip
chain module: bugfixing and cosmetics
Bugs: - one introduced ages ago - find_by_* functions should be tested vs. <0 for failure - one introduced by 579f15c7c456c - it accidentally blocked too much when testing for ',' in drive/partition option parsing - one introduced by d4d713c9ccfe0 - sone machines / VMs seem to set @40:75 just 1, regardless of amount of fixed disks available Signed-off-by: Michal Soltys <soltys@ziu.info>
Diffstat (limited to 'com32/chain/utility.c')
-rw-r--r--com32/chain/utility.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/com32/chain/utility.c b/com32/chain/utility.c
index 6894305f..828c85e2 100644
--- a/com32/chain/utility.c
+++ b/com32/chain/utility.c
@@ -7,6 +7,19 @@
#include <syslinux/disk.h>
#include "utility.h"
+#ifdef DEBUG
+static const char *bpbtypes[] = {
+ [0] = "BPB unknown",
+ [1] = "BPB v.2.0",
+ [2] = "BPB v.3.0",
+ [3] = "BPB v.3.2",
+ [4] = "BPB v.3.4",
+ [5] = "BPB v.4.0",
+ [6] = "BPB v.NT+",
+ [7] = "BPB v.7.0",
+};
+#endif
+
void error(const char *msg)
{
fputs(msg, stderr);
@@ -130,11 +143,11 @@ int drvoff_detect(int type, unsigned int *off)
*/
int bpb_detect(const uint8_t *sec)
{
- int a, b, c, jmp = -1, rev = -1;
+ int a, b, c, jmp = -1, rev = 0;
/* media descriptor check */
if ((sec[0x15] & 0xF0) != 0xF0)
- return -1;
+ goto out;
if (sec[0] == 0xEB) /* jump short */
jmp = 2 + *(int8_t *)(sec + 1);
@@ -146,7 +159,7 @@ int bpb_detect(const uint8_t *sec)
/* sanity */
if (jmp < 0x18 || jmp > 0x1F0)
- return -1;
+ goto out;
/* detect by jump */
if (jmp >= 0x18 && jmp < 0x1E)
@@ -160,8 +173,18 @@ int bpb_detect(const uint8_t *sec)
/* TODO: some better V2 - V3.4 checks ? */
- if (rev >= 0)
- return rev;
+ if (rev)
+ goto out;
+ /*
+ * BPB info:
+ * 2.0 == 0x0B - 0x17
+ * 3.0 == 2.0 + 0x18 - 0x1D
+ * 3.2 == 3.0 + 0x1E - 0x1F
+ * 3.4 ==!2.0 + 0x18 - 0x23
+ * 4.0 == 3.4 + 0x24 - 0x45
+ * NT ==~3.4 + 0x24 - 0x53
+ * 7.0 == 3.4 + 0x24 - 0x59
+ */
nocode:
a = memcmp(sec + 0x03, "NTFS", 4);
@@ -176,6 +199,10 @@ nocode:
rev = bpbV70;
}
+out:
+#ifdef DEBUG
+ printf("INFO: BPB detection: %s\n", bpbtypes[rev]);
+#endif
return rev;
}