[syslinux:master] com32/chain: always report detected BPB

syslinux-bot for Michal Soltys soltys at ziu.info
Mon Mar 26 15:03:29 PDT 2012


Commit-ID:  bd4667bdf971bac20bf5cf8837c16301509e5f21
Gitweb:     http://www.syslinux.org/commit/bd4667bdf971bac20bf5cf8837c16301509e5f21
Author:     Michal Soltys <soltys at ziu.info>
AuthorDate: Tue, 8 Mar 2011 20:18:50 +0100
Committer:  Michal Soltys <soltys at ziu.info>
CommitDate: Tue, 8 Mar 2011 20:18:50 +0100

com32/chain: always report detected BPB

Signed-off-by: Michal Soltys <soltys at ziu.info>

---
 com32/chain/mangle.c  |   12 ++++++------
 com32/chain/utility.c |   25 ++++++++++---------------
 com32/chain/utility.h |    2 +-
 3 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/com32/chain/mangle.c b/com32/chain/mangle.c
index 0aece16..1525047 100644
--- a/com32/chain/mangle.c
+++ b/com32/chain/mangle.c
@@ -243,10 +243,10 @@ bail:
 }
 #endif
 /* Adjust BPB common function */
-static int mangle_bpb(const struct part_iter *iter, struct data_area *data)
+static int mangle_bpb(const struct part_iter *iter, struct data_area *data, const char *tag)
 {
     unsigned int off;
-    int type = bpb_detect(data->data);
+    int type = bpb_detect(data->data, tag);
 
     /* BPB: hidden sectors 32bit*/
     if (type >= bpbV34) {
@@ -292,7 +292,7 @@ int manglef_bpb(const struct part_iter *iter, struct data_area *data)
     if (!(opt.file && opt.filebpb))
 	return 0;
 
-    return mangle_bpb(iter, data);
+    return mangle_bpb(iter, data, "file");
 }
 
 /*
@@ -303,7 +303,7 @@ int mangles_bpb(const struct part_iter *iter, struct data_area *data)
     if (!(opt.sect && opt.setbpb))
 	return 0;
 
-    return mangle_bpb(iter, data);
+    return mangle_bpb(iter, data, "sect");
 }
 
 /*
@@ -318,8 +318,8 @@ int manglesf_bss(struct data_area *sec, struct data_area *fil)
     if (!(opt.sect && opt.file && opt.bss))
 	return 0;
 
-    type1 = bpb_detect(fil->data);
-    type2 = bpb_detect(sec->data);
+    type1 = bpb_detect(fil->data, "bss/file");
+    type2 = bpb_detect(sec->data, "bss/sect");
 
     if (!type1 || !type2) {
 	error("Couldn't determine the BPB type for option 'bss'.\n");
diff --git a/com32/chain/utility.c b/com32/chain/utility.c
index b30042b..f0bfd8f 100644
--- a/com32/chain/utility.c
+++ b/com32/chain/utility.c
@@ -7,18 +7,16 @@
 #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",
+    [0] =  "unknown",
+    [1] =  "2.0",
+    [2] =  "3.0",
+    [3] =  "3.2",
+    [4] =  "3.4",
+    [5] =  "4.0",
+    [6] =  "8.0 (NT+)",
+    [7] =  "7.0",
 };
-#endif
 
 void error(const char *msg)
 {
@@ -148,7 +146,7 @@ int drvoff_detect(int type, unsigned int *off)
 /*
  * heuristics could certainly be improved
  */
-int bpb_detect(const uint8_t *sec)
+int bpb_detect(const uint8_t *sec, const char *tag)
 {
     int a, b, c, jmp = -1, rev = 0;
 
@@ -207,11 +205,8 @@ nocode:
     }
 
 out:
-#ifdef DEBUG
-    printf("INFO: BPB detection: %s\n", bpbtypes[rev]);
-#endif
+    printf("BPB detection (%s): %s\n", tag, bpbtypes[rev]);
     return rev;
 }
 
-
 /* vim: set ts=8 sts=4 sw=4 noet: */
diff --git a/com32/chain/utility.h b/com32/chain/utility.h
index db55bc7..9a40bc6 100644
--- a/com32/chain/utility.h
+++ b/com32/chain/utility.h
@@ -23,7 +23,7 @@ void wait_key(void);
 uint32_t lba2chs(const struct disk_info *di, uint64_t lba, uint32_t mode);
 uint32_t get_file_lba(const char *filename);
 int drvoff_detect(int type, unsigned int *off);
-int bpb_detect(const uint8_t *bpb);
+int bpb_detect(const uint8_t *bpb, const char *tag);
 
 #endif
 


More information about the Syslinux-commits mailing list