aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/partitions/ldm.c267
1 files changed, 131 insertions, 136 deletions
diff --git a/fs/partitions/ldm.c b/fs/partitions/ldm.c
index 7ab1c11dca4e..1a60926a4ccd 100644
--- a/fs/partitions/ldm.c
+++ b/fs/partitions/ldm.c
@@ -30,11 +30,6 @@
30#include "check.h" 30#include "check.h"
31#include "msdos.h" 31#include "msdos.h"
32 32
33typedef enum {
34 FALSE = 0,
35 TRUE = 1
36} BOOL;
37
38/** 33/**
39 * ldm_debug/info/error/crit - Output an error message 34 * ldm_debug/info/error/crit - Output an error message
40 * @f: A printf format string containing the message 35 * @f: A printf format string containing the message
@@ -103,24 +98,24 @@ static int ldm_parse_hexbyte (const u8 *src)
103 * 98 *
104 * N.B. The GUID need not be NULL terminated. 99 * N.B. The GUID need not be NULL terminated.
105 * 100 *
106 * Return: TRUE @dest contains binary GUID 101 * Return: 'true' @dest contains binary GUID
107 * FALSE @dest contents are undefined 102 * 'false' @dest contents are undefined
108 */ 103 */
109static BOOL ldm_parse_guid (const u8 *src, u8 *dest) 104static bool ldm_parse_guid (const u8 *src, u8 *dest)
110{ 105{
111 static const int size[] = { 4, 2, 2, 2, 6 }; 106 static const int size[] = { 4, 2, 2, 2, 6 };
112 int i, j, v; 107 int i, j, v;
113 108
114 if (src[8] != '-' || src[13] != '-' || 109 if (src[8] != '-' || src[13] != '-' ||
115 src[18] != '-' || src[23] != '-') 110 src[18] != '-' || src[23] != '-')
116 return FALSE; 111 return false;
117 112
118 for (j = 0; j < 5; j++, src++) 113 for (j = 0; j < 5; j++, src++)
119 for (i = 0; i < size[j]; i++, src+=2, *dest++ = v) 114 for (i = 0; i < size[j]; i++, src+=2, *dest++ = v)
120 if ((v = ldm_parse_hexbyte (src)) < 0) 115 if ((v = ldm_parse_hexbyte (src)) < 0)
121 return FALSE; 116 return false;
122 117
123 return TRUE; 118 return true;
124} 119}
125 120
126 121
@@ -132,17 +127,17 @@ static BOOL ldm_parse_guid (const u8 *src, u8 *dest)
132 * This parses the LDM database PRIVHEAD structure supplied in @data and 127 * This parses the LDM database PRIVHEAD structure supplied in @data and
133 * sets up the in-memory privhead structure @ph with the obtained information. 128 * sets up the in-memory privhead structure @ph with the obtained information.
134 * 129 *
135 * Return: TRUE @ph contains the PRIVHEAD data 130 * Return: 'true' @ph contains the PRIVHEAD data
136 * FALSE @ph contents are undefined 131 * 'false' @ph contents are undefined
137 */ 132 */
138static BOOL ldm_parse_privhead (const u8 *data, struct privhead *ph) 133static bool ldm_parse_privhead (const u8 *data, struct privhead *ph)
139{ 134{
140 BUG_ON (!data || !ph); 135 BUG_ON (!data || !ph);
141 136
142 if (MAGIC_PRIVHEAD != BE64 (data)) { 137 if (MAGIC_PRIVHEAD != BE64 (data)) {
143 ldm_error ("Cannot find PRIVHEAD structure. LDM database is" 138 ldm_error ("Cannot find PRIVHEAD structure. LDM database is"
144 " corrupt. Aborting."); 139 " corrupt. Aborting.");
145 return FALSE; 140 return false;
146 } 141 }
147 142
148 ph->ver_major = BE16 (data + 0x000C); 143 ph->ver_major = BE16 (data + 0x000C);
@@ -155,7 +150,7 @@ static BOOL ldm_parse_privhead (const u8 *data, struct privhead *ph)
155 if ((ph->ver_major != 2) || (ph->ver_minor != 11)) { 150 if ((ph->ver_major != 2) || (ph->ver_minor != 11)) {
156 ldm_error ("Expected PRIVHEAD version %d.%d, got %d.%d." 151 ldm_error ("Expected PRIVHEAD version %d.%d, got %d.%d."
157 " Aborting.", 2, 11, ph->ver_major, ph->ver_minor); 152 " Aborting.", 2, 11, ph->ver_major, ph->ver_minor);
158 return FALSE; 153 return false;
159 } 154 }
160 if (ph->config_size != LDM_DB_SIZE) { /* 1 MiB in sectors. */ 155 if (ph->config_size != LDM_DB_SIZE) { /* 1 MiB in sectors. */
161 /* Warn the user and continue, carefully */ 156 /* Warn the user and continue, carefully */
@@ -166,16 +161,16 @@ static BOOL ldm_parse_privhead (const u8 *data, struct privhead *ph)
166 if ((ph->logical_disk_size == 0) || 161 if ((ph->logical_disk_size == 0) ||
167 (ph->logical_disk_start + ph->logical_disk_size > ph->config_start)) { 162 (ph->logical_disk_start + ph->logical_disk_size > ph->config_start)) {
168 ldm_error ("PRIVHEAD disk size doesn't match real disk size"); 163 ldm_error ("PRIVHEAD disk size doesn't match real disk size");
169 return FALSE; 164 return false;
170 } 165 }
171 166
172 if (!ldm_parse_guid (data + 0x0030, ph->disk_id)) { 167 if (!ldm_parse_guid (data + 0x0030, ph->disk_id)) {
173 ldm_error ("PRIVHEAD contains an invalid GUID."); 168 ldm_error ("PRIVHEAD contains an invalid GUID.");
174 return FALSE; 169 return false;
175 } 170 }
176 171
177 ldm_debug ("Parsed PRIVHEAD successfully."); 172 ldm_debug ("Parsed PRIVHEAD successfully.");
178 return TRUE; 173 return true;
179} 174}
180 175
181/** 176/**
@@ -189,16 +184,16 @@ static BOOL ldm_parse_privhead (const u8 *data, struct privhead *ph)
189 * 184 *
190 * N.B. The *_start and *_size values returned in @toc are not range-checked. 185 * N.B. The *_start and *_size values returned in @toc are not range-checked.
191 * 186 *
192 * Return: TRUE @toc contains the TOCBLOCK data 187 * Return: 'true' @toc contains the TOCBLOCK data
193 * FALSE @toc contents are undefined 188 * 'false' @toc contents are undefined
194 */ 189 */
195static BOOL ldm_parse_tocblock (const u8 *data, struct tocblock *toc) 190static bool ldm_parse_tocblock (const u8 *data, struct tocblock *toc)
196{ 191{
197 BUG_ON (!data || !toc); 192 BUG_ON (!data || !toc);
198 193
199 if (MAGIC_TOCBLOCK != BE64 (data)) { 194 if (MAGIC_TOCBLOCK != BE64 (data)) {
200 ldm_crit ("Cannot find TOCBLOCK, database may be corrupt."); 195 ldm_crit ("Cannot find TOCBLOCK, database may be corrupt.");
201 return FALSE; 196 return false;
202 } 197 }
203 strncpy (toc->bitmap1_name, data + 0x24, sizeof (toc->bitmap1_name)); 198 strncpy (toc->bitmap1_name, data + 0x24, sizeof (toc->bitmap1_name));
204 toc->bitmap1_name[sizeof (toc->bitmap1_name) - 1] = 0; 199 toc->bitmap1_name[sizeof (toc->bitmap1_name) - 1] = 0;
@@ -209,7 +204,7 @@ static BOOL ldm_parse_tocblock (const u8 *data, struct tocblock *toc)
209 sizeof (toc->bitmap1_name)) != 0) { 204 sizeof (toc->bitmap1_name)) != 0) {
210 ldm_crit ("TOCBLOCK's first bitmap is '%s', should be '%s'.", 205 ldm_crit ("TOCBLOCK's first bitmap is '%s', should be '%s'.",
211 TOC_BITMAP1, toc->bitmap1_name); 206 TOC_BITMAP1, toc->bitmap1_name);
212 return FALSE; 207 return false;
213 } 208 }
214 strncpy (toc->bitmap2_name, data + 0x46, sizeof (toc->bitmap2_name)); 209 strncpy (toc->bitmap2_name, data + 0x46, sizeof (toc->bitmap2_name));
215 toc->bitmap2_name[sizeof (toc->bitmap2_name) - 1] = 0; 210 toc->bitmap2_name[sizeof (toc->bitmap2_name) - 1] = 0;
@@ -219,10 +214,10 @@ static BOOL ldm_parse_tocblock (const u8 *data, struct tocblock *toc)
219 sizeof (toc->bitmap2_name)) != 0) { 214 sizeof (toc->bitmap2_name)) != 0) {
220 ldm_crit ("TOCBLOCK's second bitmap is '%s', should be '%s'.", 215 ldm_crit ("TOCBLOCK's second bitmap is '%s', should be '%s'.",
221 TOC_BITMAP2, toc->bitmap2_name); 216 TOC_BITMAP2, toc->bitmap2_name);
222 return FALSE; 217 return false;
223 } 218 }
224 ldm_debug ("Parsed TOCBLOCK successfully."); 219 ldm_debug ("Parsed TOCBLOCK successfully.");
225 return TRUE; 220 return true;
226} 221}
227 222
228/** 223/**
@@ -235,16 +230,16 @@ static BOOL ldm_parse_tocblock (const u8 *data, struct tocblock *toc)
235 * 230 *
236 * N.B. The *_start, *_size and *_seq values will be range-checked later. 231 * N.B. The *_start, *_size and *_seq values will be range-checked later.
237 * 232 *
238 * Return: TRUE @vm contains VMDB info 233 * Return: 'true' @vm contains VMDB info
239 * FALSE @vm contents are undefined 234 * 'false' @vm contents are undefined
240 */ 235 */
241static BOOL ldm_parse_vmdb (const u8 *data, struct vmdb *vm) 236static bool ldm_parse_vmdb (const u8 *data, struct vmdb *vm)
242{ 237{
243 BUG_ON (!data || !vm); 238 BUG_ON (!data || !vm);
244 239
245 if (MAGIC_VMDB != BE32 (data)) { 240 if (MAGIC_VMDB != BE32 (data)) {
246 ldm_crit ("Cannot find the VMDB, database may be corrupt."); 241 ldm_crit ("Cannot find the VMDB, database may be corrupt.");
247 return FALSE; 242 return false;
248 } 243 }
249 244
250 vm->ver_major = BE16 (data + 0x12); 245 vm->ver_major = BE16 (data + 0x12);
@@ -252,7 +247,7 @@ static BOOL ldm_parse_vmdb (const u8 *data, struct vmdb *vm)
252 if ((vm->ver_major != 4) || (vm->ver_minor != 10)) { 247 if ((vm->ver_major != 4) || (vm->ver_minor != 10)) {
253 ldm_error ("Expected VMDB version %d.%d, got %d.%d. " 248 ldm_error ("Expected VMDB version %d.%d, got %d.%d. "
254 "Aborting.", 4, 10, vm->ver_major, vm->ver_minor); 249 "Aborting.", 4, 10, vm->ver_major, vm->ver_minor);
255 return FALSE; 250 return false;
256 } 251 }
257 252
258 vm->vblk_size = BE32 (data + 0x08); 253 vm->vblk_size = BE32 (data + 0x08);
@@ -260,7 +255,7 @@ static BOOL ldm_parse_vmdb (const u8 *data, struct vmdb *vm)
260 vm->last_vblk_seq = BE32 (data + 0x04); 255 vm->last_vblk_seq = BE32 (data + 0x04);
261 256
262 ldm_debug ("Parsed VMDB successfully."); 257 ldm_debug ("Parsed VMDB successfully.");
263 return TRUE; 258 return true;
264} 259}
265 260
266/** 261/**
@@ -270,10 +265,10 @@ static BOOL ldm_parse_vmdb (const u8 *data, struct vmdb *vm)
270 * 265 *
271 * This compares the two privhead structures @ph1 and @ph2. 266 * This compares the two privhead structures @ph1 and @ph2.
272 * 267 *
273 * Return: TRUE Identical 268 * Return: 'true' Identical
274 * FALSE Different 269 * 'false' Different
275 */ 270 */
276static BOOL ldm_compare_privheads (const struct privhead *ph1, 271static bool ldm_compare_privheads (const struct privhead *ph1,
277 const struct privhead *ph2) 272 const struct privhead *ph2)
278{ 273{
279 BUG_ON (!ph1 || !ph2); 274 BUG_ON (!ph1 || !ph2);
@@ -294,10 +289,10 @@ static BOOL ldm_compare_privheads (const struct privhead *ph1,
294 * 289 *
295 * This compares the two tocblock structures @toc1 and @toc2. 290 * This compares the two tocblock structures @toc1 and @toc2.
296 * 291 *
297 * Return: TRUE Identical 292 * Return: 'true' Identical
298 * FALSE Different 293 * 'false' Different
299 */ 294 */
300static BOOL ldm_compare_tocblocks (const struct tocblock *toc1, 295static bool ldm_compare_tocblocks (const struct tocblock *toc1,
301 const struct tocblock *toc2) 296 const struct tocblock *toc2)
302{ 297{
303 BUG_ON (!toc1 || !toc2); 298 BUG_ON (!toc1 || !toc2);
@@ -323,17 +318,17 @@ static BOOL ldm_compare_tocblocks (const struct tocblock *toc1,
323 * the configuration area (the database). The values are range-checked against 318 * the configuration area (the database). The values are range-checked against
324 * @hd, which contains the real size of the disk. 319 * @hd, which contains the real size of the disk.
325 * 320 *
326 * Return: TRUE Success 321 * Return: 'true' Success
327 * FALSE Error 322 * 'false' Error
328 */ 323 */
329static BOOL ldm_validate_privheads (struct block_device *bdev, 324static bool ldm_validate_privheads (struct block_device *bdev,
330 struct privhead *ph1) 325 struct privhead *ph1)
331{ 326{
332 static const int off[3] = { OFF_PRIV1, OFF_PRIV2, OFF_PRIV3 }; 327 static const int off[3] = { OFF_PRIV1, OFF_PRIV2, OFF_PRIV3 };
333 struct privhead *ph[3] = { ph1 }; 328 struct privhead *ph[3] = { ph1 };
334 Sector sect; 329 Sector sect;
335 u8 *data; 330 u8 *data;
336 BOOL result = FALSE; 331 bool result = false;
337 long num_sects; 332 long num_sects;
338 int i; 333 int i;
339 334
@@ -393,7 +388,7 @@ static BOOL ldm_validate_privheads (struct block_device *bdev,
393 goto out; 388 goto out;
394 }*/ 389 }*/
395 ldm_debug ("Validated PRIVHEADs successfully."); 390 ldm_debug ("Validated PRIVHEADs successfully.");
396 result = TRUE; 391 result = true;
397out: 392out:
398 kfree (ph[1]); 393 kfree (ph[1]);
399 kfree (ph[2]); 394 kfree (ph[2]);
@@ -411,10 +406,10 @@ out:
411 * 406 *
412 * The offsets and sizes of the configs are range-checked against a privhead. 407 * The offsets and sizes of the configs are range-checked against a privhead.
413 * 408 *
414 * Return: TRUE @toc1 contains validated TOCBLOCK info 409 * Return: 'true' @toc1 contains validated TOCBLOCK info
415 * FALSE @toc1 contents are undefined 410 * 'false' @toc1 contents are undefined
416 */ 411 */
417static BOOL ldm_validate_tocblocks (struct block_device *bdev, 412static bool ldm_validate_tocblocks (struct block_device *bdev,
418 unsigned long base, struct ldmdb *ldb) 413 unsigned long base, struct ldmdb *ldb)
419{ 414{
420 static const int off[4] = { OFF_TOCB1, OFF_TOCB2, OFF_TOCB3, OFF_TOCB4}; 415 static const int off[4] = { OFF_TOCB1, OFF_TOCB2, OFF_TOCB3, OFF_TOCB4};
@@ -422,7 +417,7 @@ static BOOL ldm_validate_tocblocks (struct block_device *bdev,
422 struct privhead *ph; 417 struct privhead *ph;
423 Sector sect; 418 Sector sect;
424 u8 *data; 419 u8 *data;
425 BOOL result = FALSE; 420 bool result = false;
426 int i; 421 int i;
427 422
428 BUG_ON (!bdev || !ldb); 423 BUG_ON (!bdev || !ldb);
@@ -465,7 +460,7 @@ static BOOL ldm_validate_tocblocks (struct block_device *bdev,
465 } 460 }
466 461
467 ldm_debug ("Validated TOCBLOCKs successfully."); 462 ldm_debug ("Validated TOCBLOCKs successfully.");
468 result = TRUE; 463 result = true;
469out: 464out:
470 kfree (tb[1]); 465 kfree (tb[1]);
471 kfree (tb[2]); 466 kfree (tb[2]);
@@ -482,15 +477,15 @@ out:
482 * Find the vmdb of the LDM Database stored on @bdev and return the parsed 477 * Find the vmdb of the LDM Database stored on @bdev and return the parsed
483 * information in @ldb. 478 * information in @ldb.
484 * 479 *
485 * Return: TRUE @ldb contains validated VBDB info 480 * Return: 'true' @ldb contains validated VBDB info
486 * FALSE @ldb contents are undefined 481 * 'false' @ldb contents are undefined
487 */ 482 */
488static BOOL ldm_validate_vmdb (struct block_device *bdev, unsigned long base, 483static bool ldm_validate_vmdb (struct block_device *bdev, unsigned long base,
489 struct ldmdb *ldb) 484 struct ldmdb *ldb)
490{ 485{
491 Sector sect; 486 Sector sect;
492 u8 *data; 487 u8 *data;
493 BOOL result = FALSE; 488 bool result = false;
494 struct vmdb *vm; 489 struct vmdb *vm;
495 struct tocblock *toc; 490 struct tocblock *toc;
496 491
@@ -502,7 +497,7 @@ static BOOL ldm_validate_vmdb (struct block_device *bdev, unsigned long base,
502 data = read_dev_sector (bdev, base + OFF_VMDB, &sect); 497 data = read_dev_sector (bdev, base + OFF_VMDB, &sect);
503 if (!data) { 498 if (!data) {
504 ldm_crit ("Disk read failed."); 499 ldm_crit ("Disk read failed.");
505 return FALSE; 500 return false;
506 } 501 }
507 502
508 if (!ldm_parse_vmdb (data, vm)) 503 if (!ldm_parse_vmdb (data, vm))
@@ -527,7 +522,7 @@ static BOOL ldm_validate_vmdb (struct block_device *bdev, unsigned long base,
527 goto out; 522 goto out;
528 } 523 }
529 524
530 result = TRUE; 525 result = true;
531out: 526out:
532 put_dev_sector (sect); 527 put_dev_sector (sect);
533 return result; 528 return result;
@@ -547,23 +542,23 @@ out:
547 * only likely to happen if the underlying device is strange. If that IS 542 * only likely to happen if the underlying device is strange. If that IS
548 * the case we should return zero to let someone else try. 543 * the case we should return zero to let someone else try.
549 * 544 *
550 * Return: TRUE @bdev is a dynamic disk 545 * Return: 'true' @bdev is a dynamic disk
551 * FALSE @bdev is not a dynamic disk, or an error occurred 546 * 'false' @bdev is not a dynamic disk, or an error occurred
552 */ 547 */
553static BOOL ldm_validate_partition_table (struct block_device *bdev) 548static bool ldm_validate_partition_table (struct block_device *bdev)
554{ 549{
555 Sector sect; 550 Sector sect;
556 u8 *data; 551 u8 *data;
557 struct partition *p; 552 struct partition *p;
558 int i; 553 int i;
559 BOOL result = FALSE; 554 bool result = false;
560 555
561 BUG_ON (!bdev); 556 BUG_ON (!bdev);
562 557
563 data = read_dev_sector (bdev, 0, &sect); 558 data = read_dev_sector (bdev, 0, &sect);
564 if (!data) { 559 if (!data) {
565 ldm_crit ("Disk read failed."); 560 ldm_crit ("Disk read failed.");
566 return FALSE; 561 return false;
567 } 562 }
568 563
569 if (*(__le16*) (data + 0x01FE) != cpu_to_le16 (MSDOS_LABEL_MAGIC)) 564 if (*(__le16*) (data + 0x01FE) != cpu_to_le16 (MSDOS_LABEL_MAGIC))
@@ -572,7 +567,7 @@ static BOOL ldm_validate_partition_table (struct block_device *bdev)
572 p = (struct partition*)(data + 0x01BE); 567 p = (struct partition*)(data + 0x01BE);
573 for (i = 0; i < 4; i++, p++) 568 for (i = 0; i < 4; i++, p++)
574 if (SYS_IND (p) == WIN2K_DYNAMIC_PARTITION) { 569 if (SYS_IND (p) == WIN2K_DYNAMIC_PARTITION) {
575 result = TRUE; 570 result = true;
576 break; 571 break;
577 } 572 }
578 573
@@ -625,10 +620,10 @@ static struct vblk * ldm_get_disk_objid (const struct ldmdb *ldb)
625 * N.B. This function creates the partitions in the order it finds partition 620 * N.B. This function creates the partitions in the order it finds partition
626 * objects in the linked list. 621 * objects in the linked list.
627 * 622 *
628 * Return: TRUE Partition created 623 * Return: 'true' Partition created
629 * FALSE Error, probably a range checking problem 624 * 'false' Error, probably a range checking problem
630 */ 625 */
631static BOOL ldm_create_data_partitions (struct parsed_partitions *pp, 626static bool ldm_create_data_partitions (struct parsed_partitions *pp,
632 const struct ldmdb *ldb) 627 const struct ldmdb *ldb)
633{ 628{
634 struct list_head *item; 629 struct list_head *item;
@@ -642,7 +637,7 @@ static BOOL ldm_create_data_partitions (struct parsed_partitions *pp,
642 disk = ldm_get_disk_objid (ldb); 637 disk = ldm_get_disk_objid (ldb);
643 if (!disk) { 638 if (!disk) {
644 ldm_crit ("Can't find the ID of this disk in the database."); 639 ldm_crit ("Can't find the ID of this disk in the database.");
645 return FALSE; 640 return false;
646 } 641 }
647 642
648 printk (" [LDM]"); 643 printk (" [LDM]");
@@ -661,7 +656,7 @@ static BOOL ldm_create_data_partitions (struct parsed_partitions *pp,
661 } 656 }
662 657
663 printk ("\n"); 658 printk ("\n");
664 return TRUE; 659 return true;
665} 660}
666 661
667 662
@@ -766,10 +761,10 @@ static int ldm_get_vstr (const u8 *block, u8 *buffer, int buflen)
766 * 761 *
767 * Read a raw VBLK Component object (version 3) into a vblk structure. 762 * Read a raw VBLK Component object (version 3) into a vblk structure.
768 * 763 *
769 * Return: TRUE @vb contains a Component VBLK 764 * Return: 'true' @vb contains a Component VBLK
770 * FALSE @vb contents are not defined 765 * 'false' @vb contents are not defined
771 */ 766 */
772static BOOL ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb) 767static bool ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb)
773{ 768{
774 int r_objid, r_name, r_vstate, r_child, r_parent, r_stripe, r_cols, len; 769 int r_objid, r_name, r_vstate, r_child, r_parent, r_stripe, r_cols, len;
775 struct vblk_comp *comp; 770 struct vblk_comp *comp;
@@ -792,11 +787,11 @@ static BOOL ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb)
792 len = r_parent; 787 len = r_parent;
793 } 788 }
794 if (len < 0) 789 if (len < 0)
795 return FALSE; 790 return false;
796 791
797 len += VBLK_SIZE_CMP3; 792 len += VBLK_SIZE_CMP3;
798 if (len != BE32 (buffer + 0x14)) 793 if (len != BE32 (buffer + 0x14))
799 return FALSE; 794 return false;
800 795
801 comp = &vb->vblk.comp; 796 comp = &vb->vblk.comp;
802 ldm_get_vstr (buffer + 0x18 + r_name, comp->state, 797 ldm_get_vstr (buffer + 0x18 + r_name, comp->state,
@@ -806,7 +801,7 @@ static BOOL ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb)
806 comp->parent_id = ldm_get_vnum (buffer + 0x2D + r_child); 801 comp->parent_id = ldm_get_vnum (buffer + 0x2D + r_child);
807 comp->chunksize = r_stripe ? ldm_get_vnum (buffer+r_parent+0x2E) : 0; 802 comp->chunksize = r_stripe ? ldm_get_vnum (buffer+r_parent+0x2E) : 0;
808 803
809 return TRUE; 804 return true;
810} 805}
811 806
812/** 807/**
@@ -817,8 +812,8 @@ static BOOL ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb)
817 * 812 *
818 * Read a raw VBLK Disk Group object (version 3) into a vblk structure. 813 * Read a raw VBLK Disk Group object (version 3) into a vblk structure.
819 * 814 *
820 * Return: TRUE @vb contains a Disk Group VBLK 815 * Return: 'true' @vb contains a Disk Group VBLK
821 * FALSE @vb contents are not defined 816 * 'false' @vb contents are not defined
822 */ 817 */
823static int ldm_parse_dgr3 (const u8 *buffer, int buflen, struct vblk *vb) 818static int ldm_parse_dgr3 (const u8 *buffer, int buflen, struct vblk *vb)
824{ 819{
@@ -841,16 +836,16 @@ static int ldm_parse_dgr3 (const u8 *buffer, int buflen, struct vblk *vb)
841 len = r_diskid; 836 len = r_diskid;
842 } 837 }
843 if (len < 0) 838 if (len < 0)
844 return FALSE; 839 return false;
845 840
846 len += VBLK_SIZE_DGR3; 841 len += VBLK_SIZE_DGR3;
847 if (len != BE32 (buffer + 0x14)) 842 if (len != BE32 (buffer + 0x14))
848 return FALSE; 843 return false;
849 844
850 dgrp = &vb->vblk.dgrp; 845 dgrp = &vb->vblk.dgrp;
851 ldm_get_vstr (buffer + 0x18 + r_name, dgrp->disk_id, 846 ldm_get_vstr (buffer + 0x18 + r_name, dgrp->disk_id,
852 sizeof (dgrp->disk_id)); 847 sizeof (dgrp->disk_id));
853 return TRUE; 848 return true;
854} 849}
855 850
856/** 851/**
@@ -861,10 +856,10 @@ static int ldm_parse_dgr3 (const u8 *buffer, int buflen, struct vblk *vb)
861 * 856 *
862 * Read a raw VBLK Disk Group object (version 4) into a vblk structure. 857 * Read a raw VBLK Disk Group object (version 4) into a vblk structure.
863 * 858 *
864 * Return: TRUE @vb contains a Disk Group VBLK 859 * Return: 'true' @vb contains a Disk Group VBLK
865 * FALSE @vb contents are not defined 860 * 'false' @vb contents are not defined
866 */ 861 */
867static BOOL ldm_parse_dgr4 (const u8 *buffer, int buflen, struct vblk *vb) 862static bool ldm_parse_dgr4 (const u8 *buffer, int buflen, struct vblk *vb)
868{ 863{
869 char buf[64]; 864 char buf[64];
870 int r_objid, r_name, r_id1, r_id2, len; 865 int r_objid, r_name, r_id1, r_id2, len;
@@ -885,16 +880,16 @@ static BOOL ldm_parse_dgr4 (const u8 *buffer, int buflen, struct vblk *vb)
885 len = r_name; 880 len = r_name;
886 } 881 }
887 if (len < 0) 882 if (len < 0)
888 return FALSE; 883 return false;
889 884
890 len += VBLK_SIZE_DGR4; 885 len += VBLK_SIZE_DGR4;
891 if (len != BE32 (buffer + 0x14)) 886 if (len != BE32 (buffer + 0x14))
892 return FALSE; 887 return false;
893 888
894 dgrp = &vb->vblk.dgrp; 889 dgrp = &vb->vblk.dgrp;
895 890
896 ldm_get_vstr (buffer + 0x18 + r_objid, buf, sizeof (buf)); 891 ldm_get_vstr (buffer + 0x18 + r_objid, buf, sizeof (buf));
897 return TRUE; 892 return true;
898} 893}
899 894
900/** 895/**
@@ -905,10 +900,10 @@ static BOOL ldm_parse_dgr4 (const u8 *buffer, int buflen, struct vblk *vb)
905 * 900 *
906 * Read a raw VBLK Disk object (version 3) into a vblk structure. 901 * Read a raw VBLK Disk object (version 3) into a vblk structure.
907 * 902 *
908 * Return: TRUE @vb contains a Disk VBLK 903 * Return: 'true' @vb contains a Disk VBLK
909 * FALSE @vb contents are not defined 904 * 'false' @vb contents are not defined
910 */ 905 */
911static BOOL ldm_parse_dsk3 (const u8 *buffer, int buflen, struct vblk *vb) 906static bool ldm_parse_dsk3 (const u8 *buffer, int buflen, struct vblk *vb)
912{ 907{
913 int r_objid, r_name, r_diskid, r_altname, len; 908 int r_objid, r_name, r_diskid, r_altname, len;
914 struct vblk_disk *disk; 909 struct vblk_disk *disk;
@@ -921,19 +916,19 @@ static BOOL ldm_parse_dsk3 (const u8 *buffer, int buflen, struct vblk *vb)
921 r_altname = ldm_relative (buffer, buflen, 0x18, r_diskid); 916 r_altname = ldm_relative (buffer, buflen, 0x18, r_diskid);
922 len = r_altname; 917 len = r_altname;
923 if (len < 0) 918 if (len < 0)
924 return FALSE; 919 return false;
925 920
926 len += VBLK_SIZE_DSK3; 921 len += VBLK_SIZE_DSK3;
927 if (len != BE32 (buffer + 0x14)) 922 if (len != BE32 (buffer + 0x14))
928 return FALSE; 923 return false;
929 924
930 disk = &vb->vblk.disk; 925 disk = &vb->vblk.disk;
931 ldm_get_vstr (buffer + 0x18 + r_diskid, disk->alt_name, 926 ldm_get_vstr (buffer + 0x18 + r_diskid, disk->alt_name,
932 sizeof (disk->alt_name)); 927 sizeof (disk->alt_name));
933 if (!ldm_parse_guid (buffer + 0x19 + r_name, disk->disk_id)) 928 if (!ldm_parse_guid (buffer + 0x19 + r_name, disk->disk_id))
934 return FALSE; 929 return false;
935 930
936 return TRUE; 931 return true;
937} 932}
938 933
939/** 934/**
@@ -944,10 +939,10 @@ static BOOL ldm_parse_dsk3 (const u8 *buffer, int buflen, struct vblk *vb)
944 * 939 *
945 * Read a raw VBLK Disk object (version 4) into a vblk structure. 940 * Read a raw VBLK Disk object (version 4) into a vblk structure.
946 * 941 *
947 * Return: TRUE @vb contains a Disk VBLK 942 * Return: 'true' @vb contains a Disk VBLK
948 * FALSE @vb contents are not defined 943 * 'false' @vb contents are not defined
949 */ 944 */
950static BOOL ldm_parse_dsk4 (const u8 *buffer, int buflen, struct vblk *vb) 945static bool ldm_parse_dsk4 (const u8 *buffer, int buflen, struct vblk *vb)
951{ 946{
952 int r_objid, r_name, len; 947 int r_objid, r_name, len;
953 struct vblk_disk *disk; 948 struct vblk_disk *disk;
@@ -958,15 +953,15 @@ static BOOL ldm_parse_dsk4 (const u8 *buffer, int buflen, struct vblk *vb)
958 r_name = ldm_relative (buffer, buflen, 0x18, r_objid); 953 r_name = ldm_relative (buffer, buflen, 0x18, r_objid);
959 len = r_name; 954 len = r_name;
960 if (len < 0) 955 if (len < 0)
961 return FALSE; 956 return false;
962 957
963 len += VBLK_SIZE_DSK4; 958 len += VBLK_SIZE_DSK4;
964 if (len != BE32 (buffer + 0x14)) 959 if (len != BE32 (buffer + 0x14))
965 return FALSE; 960 return false;
966 961
967 disk = &vb->vblk.disk; 962 disk = &vb->vblk.disk;
968 memcpy (disk->disk_id, buffer + 0x18 + r_name, GUID_SIZE); 963 memcpy (disk->disk_id, buffer + 0x18 + r_name, GUID_SIZE);
969 return TRUE; 964 return true;
970} 965}
971 966
972/** 967/**
@@ -977,10 +972,10 @@ static BOOL ldm_parse_dsk4 (const u8 *buffer, int buflen, struct vblk *vb)
977 * 972 *
978 * Read a raw VBLK Partition object (version 3) into a vblk structure. 973 * Read a raw VBLK Partition object (version 3) into a vblk structure.
979 * 974 *
980 * Return: TRUE @vb contains a Partition VBLK 975 * Return: 'true' @vb contains a Partition VBLK
981 * FALSE @vb contents are not defined 976 * 'false' @vb contents are not defined
982 */ 977 */
983static BOOL ldm_parse_prt3 (const u8 *buffer, int buflen, struct vblk *vb) 978static bool ldm_parse_prt3 (const u8 *buffer, int buflen, struct vblk *vb)
984{ 979{
985 int r_objid, r_name, r_size, r_parent, r_diskid, r_index, len; 980 int r_objid, r_name, r_size, r_parent, r_diskid, r_index, len;
986 struct vblk_part *part; 981 struct vblk_part *part;
@@ -1001,11 +996,11 @@ static BOOL ldm_parse_prt3 (const u8 *buffer, int buflen, struct vblk *vb)
1001 len = r_diskid; 996 len = r_diskid;
1002 } 997 }
1003 if (len < 0) 998 if (len < 0)
1004 return FALSE; 999 return false;
1005 1000
1006 len += VBLK_SIZE_PRT3; 1001 len += VBLK_SIZE_PRT3;
1007 if (len != BE32 (buffer + 0x14)) 1002 if (len != BE32 (buffer + 0x14))
1008 return FALSE; 1003 return false;
1009 1004
1010 part = &vb->vblk.part; 1005 part = &vb->vblk.part;
1011 part->start = BE64 (buffer + 0x24 + r_name); 1006 part->start = BE64 (buffer + 0x24 + r_name);
@@ -1018,7 +1013,7 @@ static BOOL ldm_parse_prt3 (const u8 *buffer, int buflen, struct vblk *vb)
1018 else 1013 else
1019 part->partnum = 0; 1014 part->partnum = 0;
1020 1015
1021 return TRUE; 1016 return true;
1022} 1017}
1023 1018
1024/** 1019/**
@@ -1029,10 +1024,10 @@ static BOOL ldm_parse_prt3 (const u8 *buffer, int buflen, struct vblk *vb)
1029 * 1024 *
1030 * Read a raw VBLK Volume object (version 5) into a vblk structure. 1025 * Read a raw VBLK Volume object (version 5) into a vblk structure.
1031 * 1026 *
1032 * Return: TRUE @vb contains a Volume VBLK 1027 * Return: 'true' @vb contains a Volume VBLK
1033 * FALSE @vb contents are not defined 1028 * 'false' @vb contents are not defined
1034 */ 1029 */
1035static BOOL ldm_parse_vol5 (const u8 *buffer, int buflen, struct vblk *vb) 1030static bool ldm_parse_vol5 (const u8 *buffer, int buflen, struct vblk *vb)
1036{ 1031{
1037 int r_objid, r_name, r_vtype, r_child, r_size, r_id1, r_id2, r_size2; 1032 int r_objid, r_name, r_vtype, r_child, r_size, r_id1, r_id2, r_size2;
1038 int r_drive, len; 1033 int r_drive, len;
@@ -1068,11 +1063,11 @@ static BOOL ldm_parse_vol5 (const u8 *buffer, int buflen, struct vblk *vb)
1068 1063
1069 len = r_drive; 1064 len = r_drive;
1070 if (len < 0) 1065 if (len < 0)
1071 return FALSE; 1066 return false;
1072 1067
1073 len += VBLK_SIZE_VOL5; 1068 len += VBLK_SIZE_VOL5;
1074 if (len != BE32 (buffer + 0x14)) 1069 if (len != BE32 (buffer + 0x14))
1075 return FALSE; 1070 return false;
1076 1071
1077 volu = &vb->vblk.volu; 1072 volu = &vb->vblk.volu;
1078 1073
@@ -1087,7 +1082,7 @@ static BOOL ldm_parse_vol5 (const u8 *buffer, int buflen, struct vblk *vb)
1087 ldm_get_vstr (buffer + 0x53 + r_size, volu->drive_hint, 1082 ldm_get_vstr (buffer + 0x53 + r_size, volu->drive_hint,
1088 sizeof (volu->drive_hint)); 1083 sizeof (volu->drive_hint));
1089 } 1084 }
1090 return TRUE; 1085 return true;
1091} 1086}
1092 1087
1093/** 1088/**
@@ -1100,12 +1095,12 @@ static BOOL ldm_parse_vol5 (const u8 *buffer, int buflen, struct vblk *vb)
1100 * information common to all VBLK types, then delegates the rest of the work to 1095 * information common to all VBLK types, then delegates the rest of the work to
1101 * helper functions: ldm_parse_*. 1096 * helper functions: ldm_parse_*.
1102 * 1097 *
1103 * Return: TRUE @vb contains a VBLK 1098 * Return: 'true' @vb contains a VBLK
1104 * FALSE @vb contents are not defined 1099 * 'false' @vb contents are not defined
1105 */ 1100 */
1106static BOOL ldm_parse_vblk (const u8 *buf, int len, struct vblk *vb) 1101static bool ldm_parse_vblk (const u8 *buf, int len, struct vblk *vb)
1107{ 1102{
1108 BOOL result = FALSE; 1103 bool result = false;
1109 int r_objid; 1104 int r_objid;
1110 1105
1111 BUG_ON (!buf || !vb); 1106 BUG_ON (!buf || !vb);
@@ -1113,7 +1108,7 @@ static BOOL ldm_parse_vblk (const u8 *buf, int len, struct vblk *vb)
1113 r_objid = ldm_relative (buf, len, 0x18, 0); 1108 r_objid = ldm_relative (buf, len, 0x18, 0);
1114 if (r_objid < 0) { 1109 if (r_objid < 0) {
1115 ldm_error ("VBLK header is corrupt."); 1110 ldm_error ("VBLK header is corrupt.");
1116 return FALSE; 1111 return false;
1117 } 1112 }
1118 1113
1119 vb->flags = buf[0x12]; 1114 vb->flags = buf[0x12];
@@ -1152,10 +1147,10 @@ static BOOL ldm_parse_vblk (const u8 *buf, int len, struct vblk *vb)
1152 * 1147 *
1153 * N.B. This function does not check the validity of the VBLKs. 1148 * N.B. This function does not check the validity of the VBLKs.
1154 * 1149 *
1155 * Return: TRUE The VBLK was added 1150 * Return: 'true' The VBLK was added
1156 * FALSE An error occurred 1151 * 'false' An error occurred
1157 */ 1152 */
1158static BOOL ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb) 1153static bool ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb)
1159{ 1154{
1160 struct vblk *vb; 1155 struct vblk *vb;
1161 struct list_head *item; 1156 struct list_head *item;
@@ -1165,12 +1160,12 @@ static BOOL ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb)
1165 vb = kmalloc (sizeof (*vb), GFP_KERNEL); 1160 vb = kmalloc (sizeof (*vb), GFP_KERNEL);
1166 if (!vb) { 1161 if (!vb) {
1167 ldm_crit ("Out of memory."); 1162 ldm_crit ("Out of memory.");
1168 return FALSE; 1163 return false;
1169 } 1164 }
1170 1165
1171 if (!ldm_parse_vblk (data, len, vb)) { 1166 if (!ldm_parse_vblk (data, len, vb)) {
1172 kfree(vb); 1167 kfree(vb);
1173 return FALSE; /* Already logged */ 1168 return false; /* Already logged */
1174 } 1169 }
1175 1170
1176 /* Put vblk into the correct list. */ 1171 /* Put vblk into the correct list. */
@@ -1196,13 +1191,13 @@ static BOOL ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb)
1196 if ((v->vblk.part.disk_id == vb->vblk.part.disk_id) && 1191 if ((v->vblk.part.disk_id == vb->vblk.part.disk_id) &&
1197 (v->vblk.part.start > vb->vblk.part.start)) { 1192 (v->vblk.part.start > vb->vblk.part.start)) {
1198 list_add_tail (&vb->list, &v->list); 1193 list_add_tail (&vb->list, &v->list);
1199 return TRUE; 1194 return true;
1200 } 1195 }
1201 } 1196 }
1202 list_add_tail (&vb->list, &ldb->v_part); 1197 list_add_tail (&vb->list, &ldb->v_part);
1203 break; 1198 break;
1204 } 1199 }
1205 return TRUE; 1200 return true;
1206} 1201}
1207 1202
1208/** 1203/**
@@ -1214,10 +1209,10 @@ static BOOL ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb)
1214 * Fragmented VBLKs may not be consecutive in the database, so they are placed 1209 * Fragmented VBLKs may not be consecutive in the database, so they are placed
1215 * in a list so they can be pieced together later. 1210 * in a list so they can be pieced together later.
1216 * 1211 *
1217 * Return: TRUE Success, the VBLK was added to the list 1212 * Return: 'true' Success, the VBLK was added to the list
1218 * FALSE Error, a problem occurred 1213 * 'false' Error, a problem occurred
1219 */ 1214 */
1220static BOOL ldm_frag_add (const u8 *data, int size, struct list_head *frags) 1215static bool ldm_frag_add (const u8 *data, int size, struct list_head *frags)
1221{ 1216{
1222 struct frag *f; 1217 struct frag *f;
1223 struct list_head *item; 1218 struct list_head *item;
@@ -1230,7 +1225,7 @@ static BOOL ldm_frag_add (const u8 *data, int size, struct list_head *frags)
1230 num = BE16 (data + 0x0E); 1225 num = BE16 (data + 0x0E);
1231 if ((num < 1) || (num > 4)) { 1226 if ((num < 1) || (num > 4)) {
1232 ldm_error ("A VBLK claims to have %d parts.", num); 1227 ldm_error ("A VBLK claims to have %d parts.", num);
1233 return FALSE; 1228 return false;
1234 } 1229 }
1235 1230
1236 list_for_each (item, frags) { 1231 list_for_each (item, frags) {
@@ -1242,7 +1237,7 @@ static BOOL ldm_frag_add (const u8 *data, int size, struct list_head *frags)
1242 f = kmalloc (sizeof (*f) + size*num, GFP_KERNEL); 1237 f = kmalloc (sizeof (*f) + size*num, GFP_KERNEL);
1243 if (!f) { 1238 if (!f) {
1244 ldm_crit ("Out of memory."); 1239 ldm_crit ("Out of memory.");
1245 return FALSE; 1240 return false;
1246 } 1241 }
1247 1242
1248 f->group = group; 1243 f->group = group;
@@ -1255,7 +1250,7 @@ found:
1255 if (f->map & (1 << rec)) { 1250 if (f->map & (1 << rec)) {
1256 ldm_error ("Duplicate VBLK, part %d.", rec); 1251 ldm_error ("Duplicate VBLK, part %d.", rec);
1257 f->map &= 0x7F; /* Mark the group as broken */ 1252 f->map &= 0x7F; /* Mark the group as broken */
1258 return FALSE; 1253 return false;
1259 } 1254 }
1260 1255
1261 f->map |= (1 << rec); 1256 f->map |= (1 << rec);
@@ -1266,7 +1261,7 @@ found:
1266 } 1261 }
1267 memcpy (f->data+rec*(size-VBLK_SIZE_HEAD)+VBLK_SIZE_HEAD, data, size); 1262 memcpy (f->data+rec*(size-VBLK_SIZE_HEAD)+VBLK_SIZE_HEAD, data, size);
1268 1263
1269 return TRUE; 1264 return true;
1270} 1265}
1271 1266
1272/** 1267/**
@@ -1295,10 +1290,10 @@ static void ldm_frag_free (struct list_head *list)
1295 * Now that all the fragmented VBLKs have been collected, they must be added to 1290 * Now that all the fragmented VBLKs have been collected, they must be added to
1296 * the database for later use. 1291 * the database for later use.
1297 * 1292 *
1298 * Return: TRUE All the fragments we added successfully 1293 * Return: 'true' All the fragments we added successfully
1299 * FALSE One or more of the fragments we invalid 1294 * 'false' One or more of the fragments we invalid
1300 */ 1295 */
1301static BOOL ldm_frag_commit (struct list_head *frags, struct ldmdb *ldb) 1296static bool ldm_frag_commit (struct list_head *frags, struct ldmdb *ldb)
1302{ 1297{
1303 struct frag *f; 1298 struct frag *f;
1304 struct list_head *item; 1299 struct list_head *item;
@@ -1311,13 +1306,13 @@ static BOOL ldm_frag_commit (struct list_head *frags, struct ldmdb *ldb)
1311 if (f->map != 0xFF) { 1306 if (f->map != 0xFF) {
1312 ldm_error ("VBLK group %d is incomplete (0x%02x).", 1307 ldm_error ("VBLK group %d is incomplete (0x%02x).",
1313 f->group, f->map); 1308 f->group, f->map);
1314 return FALSE; 1309 return false;
1315 } 1310 }
1316 1311
1317 if (!ldm_ldmdb_add (f->data, f->num*ldb->vm.vblk_size, ldb)) 1312 if (!ldm_ldmdb_add (f->data, f->num*ldb->vm.vblk_size, ldb))
1318 return FALSE; /* Already logged */ 1313 return false; /* Already logged */
1319 } 1314 }
1320 return TRUE; 1315 return true;
1321} 1316}
1322 1317
1323/** 1318/**
@@ -1329,16 +1324,16 @@ static BOOL ldm_frag_commit (struct list_head *frags, struct ldmdb *ldb)
1329 * To use the information from the VBLKs, they need to be read from the disk, 1324 * To use the information from the VBLKs, they need to be read from the disk,
1330 * unpacked and validated. We cache them in @ldb according to their type. 1325 * unpacked and validated. We cache them in @ldb according to their type.
1331 * 1326 *
1332 * Return: TRUE All the VBLKs were read successfully 1327 * Return: 'true' All the VBLKs were read successfully
1333 * FALSE An error occurred 1328 * 'false' An error occurred
1334 */ 1329 */
1335static BOOL ldm_get_vblks (struct block_device *bdev, unsigned long base, 1330static bool ldm_get_vblks (struct block_device *bdev, unsigned long base,
1336 struct ldmdb *ldb) 1331 struct ldmdb *ldb)
1337{ 1332{
1338 int size, perbuf, skip, finish, s, v, recs; 1333 int size, perbuf, skip, finish, s, v, recs;
1339 u8 *data = NULL; 1334 u8 *data = NULL;
1340 Sector sect; 1335 Sector sect;
1341 BOOL result = FALSE; 1336 bool result = false;
1342 LIST_HEAD (frags); 1337 LIST_HEAD (frags);
1343 1338
1344 BUG_ON (!bdev || !ldb); 1339 BUG_ON (!bdev || !ldb);