Revision 3b46e624

b/Changelog
86 86
    (Johannes Schindelin)
87 87

  
88 88
version 0.7.2:
89
 
89

  
90 90
  - x86_64 fixes (Win2000 and Linux 2.6 boot in 32 bit)
91 91
  - merge self modifying code handling in dirty ram page mecanism.
92 92
  - MIPS fixes (Ralf Baechle)
......
201 201
  - FDC fixes for Win98
202 202

  
203 203
version 0.5.4:
204
 
204

  
205 205
  - qemu-fast fixes
206 206
  - BIOS area protection fix (aka EMM386.EXE fix) (Mike Nordell)
207 207
  - keyboard/mouse fix (Mike Nordell)
......
266 266
  - eflags optimisation fix for string operations
267 267

  
268 268
version 0.5.1:
269
 
269

  
270 270
  - float access fixes when using soft mmu
271 271
  - PC emulation support on PowerPC
272 272
  - A20 support
......
281 281
  - Major SPARC target fixes (dynamically linked programs begin to work)
282 282

  
283 283
version 0.5.0:
284
 
284

  
285 285
  - full hardware level VGA emulation
286 286
  - graphical display with SDL
287 287
  - added PS/2 mouse and keyboard emulation
......
319 319
 - SMP kernels can at least be booted
320 320

  
321 321
version 0.4.1:
322
 
322

  
323 323
 - more accurate timer support in vl.
324 324
 - more reliable NE2000 probe in vl.
325 325
 - added 2.5.66 kernel in vl-test.
b/aes.c
1294 1294
			AES_encrypt(tmp, tmp, key);
1295 1295
			memcpy(out, tmp, AES_BLOCK_SIZE);
1296 1296
			memcpy(ivec, tmp, AES_BLOCK_SIZE);
1297
		}		
1297
		}
1298 1298
	} else {
1299 1299
		while (len >= AES_BLOCK_SIZE) {
1300 1300
			memcpy(tmp, in, AES_BLOCK_SIZE);
......
1312 1312
			for(n=0; n < len; ++n)
1313 1313
				out[n] = tmp[n] ^ ivec[n];
1314 1314
			memcpy(ivec, tmp, AES_BLOCK_SIZE);
1315
		}		
1315
		}
1316 1316
	}
1317 1317
}
b/arm-dis.c
34 34
};
35 35

  
36 36
/* format of the assembler string :
37
  
37

  
38 38
   %%			%
39 39
   %<bitfield>d		print the bitfield in decimal
40 40
   %<bitfield>x		print the bitfield in hex
......
104 104
    {0x0c400000, 0x0ff00fff, "mar%c\tacc0, %12-15r, %16-19r"},
105 105
    {0x0c500000, 0x0ff00fff, "mra%c\t%12-15r, %16-19r, acc0"},
106 106
    {0xf450f000, 0xfc70f000, "pld\t%a"},
107
   
107

  
108 108
    /* V5 Instructions.  */
109 109
    {0xe1200070, 0xfff000f0, "bkpt\t0x%16-19X%12-15X%8-11X%0-3X"},
110 110
    {0xfa000000, 0xfe000000, "blx\t%B"},
......
116 116
    {0xfe000010, 0xff100010, "mcr2\t%8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}"},
117 117
    {0xfe100010, 0xff100010, "mrc2\t%8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}"},
118 118

  
119
    /* V5E "El Segundo" Instructions.  */   
119
    /* V5E "El Segundo" Instructions.  */
120 120
    {0x000000d0, 0x0e1000f0, "ldr%cd\t%12-15r, %s"},
121 121
    {0x000000f0, 0x0e1000f0, "str%cd\t%12-15r, %s"},
122 122
    {0x01000080, 0x0ff000f0, "smlabb%c\t%16-19r, %0-3r, %8-11r, %12-15r"},
......
621 621
     void * stream;
622 622
{
623 623
  func (stream, "%s", arm_regnames[given & 0xf]);
624
 
624

  
625 625
  if ((given & 0xff0) != 0)
626 626
    {
627 627
      if ((given & 0x10) == 0)
628 628
	{
629 629
	  int amount = (given & 0xf80) >> 7;
630 630
	  int shift = (given & 0x60) >> 5;
631
	 
631

  
632 632
	  if (amount == 0)
633 633
	    {
634 634
	      if (shift == 3)
......
636 636
		  func (stream, ", rrx");
637 637
		  return;
638 638
		}
639
	     
639

  
640 640
	      amount = 32;
641 641
	    }
642
	 
642

  
643 643
	  func (stream, ", %s #%d", arm_shift[shift], amount);
644 644
	}
645 645
      else
......
666 666
      if ((given & insn->mask) == insn->value)
667 667
	{
668 668
	  char * c;
669
	 
669

  
670 670
	  for (c = insn->assembler; *c; c++)
671 671
	    {
672 672
	      if (*c == '%')
......
682 682
			  && ((given & 0x02000000) == 0))
683 683
			{
684 684
			  int offset = given & 0xfff;
685
			 
685

  
686 686
			  func (stream, "[pc");
687 687

  
688 688
			  if (given & 0x01000000)
689 689
			    {
690 690
			      if ((given & 0x00800000) == 0)
691 691
				offset = - offset;
692
			 
692

  
693 693
			      /* Pre-indexed.  */
694 694
			      func (stream, ", #%d]", offset);
695 695

  
......
710 710
			      /* ie ignore the offset.  */
711 711
			      offset = pc + 8;
712 712
			    }
713
			 
713

  
714 714
			  func (stream, "\t; ");
715 715
			  info->print_address_func (offset, info);
716 716
			}
......
767 767
			{
768 768
                          /* PC relative with immediate offset.  */
769 769
			  int offset = ((given & 0xf00) >> 4) | (given & 0xf);
770
			 
770

  
771 771
			  if ((given & 0x00800000) == 0)
772 772
			    offset = -offset;
773
			 
773

  
774 774
			  func (stream, "[pc, #%d]\t; ", offset);
775
			 
775

  
776 776
			  (*info->print_address_func)
777 777
			    (offset + pc + 8, info);
778 778
			}
......
829 829
			    }
830 830
			}
831 831
		      break;
832
			 
832

  
833 833
		    case 'b':
834 834
		      (*info->print_address_func)
835 835
			(BDISP (given) * 4 + pc + 8, info);
......
911 911
		      {
912 912
			bfd_vma address;
913 913
			bfd_vma offset = 0;
914
		
914

  
915 915
			if (given & 0x00800000)
916 916
			  /* Is signed, hi bits should be ones.  */
917 917
			  offset = (-1) ^ 0x00ffffff;
......
920 920
			offset += given & 0x00ffffff;
921 921
			offset <<= 2;
922 922
			address = offset + pc + 8;
923
		
923

  
924 924
			if (given & 0x01000000)
925 925
			  /* H bit allows addressing to 2-byte boundaries.  */
926 926
			  address += 2;
......
976 976
			  func (stream, "3");
977 977
			}
978 978
		      break;
979
		
979

  
980 980
		    case 'P':
981 981
		      switch (given & 0x00080080)
982 982
			{
......
1040 1040
			  {
1041 1041
			  case '-':
1042 1042
			    c++;
1043
			   
1043

  
1044 1044
			    while (*c >= '0' && *c <= '9')
1045 1045
			      bitend = (bitend * 10) + *c++ - '0';
1046
			   
1046

  
1047 1047
			    if (!bitend)
1048 1048
			      abort ();
1049
			   
1049

  
1050 1050
			    switch (*c)
1051 1051
			      {
1052 1052
			      case 'r':
1053 1053
				{
1054 1054
				  long reg;
1055
				 
1055

  
1056 1056
				  reg = given >> bitstart;
1057 1057
				  reg &= (2 << (bitend - bitstart)) - 1;
1058
				 
1058

  
1059 1059
				  func (stream, "%s", arm_regnames[reg]);
1060 1060
				}
1061 1061
				break;
1062 1062
			      case 'd':
1063 1063
				{
1064 1064
				  long reg;
1065
				 
1065

  
1066 1066
				  reg = given >> bitstart;
1067 1067
				  reg &= (2 << (bitend - bitstart)) - 1;
1068
				 
1068

  
1069 1069
				  func (stream, "%d", reg);
1070 1070
				}
1071 1071
				break;
1072 1072
			      case 'x':
1073 1073
				{
1074 1074
				  long reg;
1075
				 
1075

  
1076 1076
				  reg = given >> bitstart;
1077 1077
				  reg &= (2 << (bitend - bitstart)) - 1;
1078
				 
1078

  
1079 1079
				  func (stream, "0x%08x", reg);
1080
				 
1080

  
1081 1081
				  /* Some SWI instructions have special
1082 1082
				     meanings.  */
1083 1083
				  if ((given & 0x0fffffff) == 0x0FF00000)
......
1089 1089
			      case 'X':
1090 1090
				{
1091 1091
				  long reg;
1092
				 
1092

  
1093 1093
				  reg = given >> bitstart;
1094 1094
				  reg &= (2 << (bitend - bitstart)) - 1;
1095
				 
1095

  
1096 1096
				  func (stream, "%01x", reg & 0xf);
1097 1097
				}
1098 1098
				break;
1099 1099
			      case 'f':
1100 1100
				{
1101 1101
				  long reg;
1102
				 
1102

  
1103 1103
				  reg = given >> bitstart;
1104 1104
				  reg &= (2 << (bitend - bitstart)) - 1;
1105
				 
1105

  
1106 1106
				  if (reg > 7)
1107 1107
				    func (stream, "#%s",
1108 1108
					  arm_fp_const[reg & 7]);
......
1163 1163
				    }
1164 1164
				  break;
1165 1165

  
1166
				 
1166

  
1167 1167
				default:
1168 1168
				  abort ();
1169 1169
				}
......
1252 1252
          if (!*c) /* Check for empty (not NULL) assembler string.  */
1253 1253
            {
1254 1254
	      long offset;
1255
	     
1255

  
1256 1256
	      info->bytes_per_chunk = 4;
1257 1257
	      info->bytes_per_line  = 4;
1258 1258

  
......
1274 1274
            {
1275 1275
	      info->bytes_per_chunk = 2;
1276 1276
	      info->bytes_per_line  = 4;
1277
	  	     
1277

  
1278 1278
              given &= 0xffff;
1279
	     
1279

  
1280 1280
              for (; *c; c++)
1281 1281
                {
1282 1282
                  if (*c == '%')
1283 1283
                    {
1284 1284
                      int domaskpc = 0;
1285 1285
                      int domasklr = 0;
1286
		     
1286

  
1287 1287
                      switch (*++c)
1288 1288
                        {
1289 1289
                        case '%':
......
1293 1293
                        case 'S':
1294 1294
                          {
1295 1295
                            long reg;
1296
			   
1296

  
1297 1297
                            reg = (given >> 3) & 0x7;
1298 1298
                            if (given & (1 << 6))
1299 1299
                              reg += 8;
1300
			   
1300

  
1301 1301
                            func (stream, "%s", arm_regnames[reg]);
1302 1302
                          }
1303 1303
                          break;
......
1305 1305
                        case 'D':
1306 1306
                          {
1307 1307
                            long reg;
1308
			   
1308

  
1309 1309
                            reg = given & 0x7;
1310 1310
                            if (given & (1 << 7))
1311 1311
                             reg += 8;
1312
			   
1312

  
1313 1313
                            func (stream, "%s", arm_regnames[reg]);
1314 1314
                          }
1315 1315
                          break;
......
1331 1331
                          {
1332 1332
                            int started = 0;
1333 1333
                            int reg;
1334
			   
1334

  
1335 1335
                            func (stream, "{");
1336
			   
1336

  
1337 1337
                            /* It would be nice if we could spot
1338 1338
                               ranges, and generate the rS-rE format: */
1339 1339
                            for (reg = 0; (reg < 8); reg++)
......
1370 1370
                          {
1371 1371
                            int bitstart = *c++ - '0';
1372 1372
                            int bitend = 0;
1373
			   
1373

  
1374 1374
                            while (*c >= '0' && *c <= '9')
1375 1375
                              bitstart = (bitstart * 10) + *c++ - '0';
1376 1376

  
......
1379 1379
                              case '-':
1380 1380
                                {
1381 1381
                                  long reg;
1382
				 
1382

  
1383 1383
                                  c++;
1384 1384
                                  while (*c >= '0' && *c <= '9')
1385 1385
                                    bitend = (bitend * 10) + *c++ - '0';
......
1478 1478
{
1479 1479
  if (option == NULL)
1480 1480
    return;
1481
     
1481

  
1482 1482
  if (strneq (option, "reg-names-", 10))
1483 1483
    {
1484 1484
      int i;
......
1491 1491
	    regname_selected = i;
1492 1492
	    break;
1493 1493
	  }
1494
     
1494

  
1495 1495
      if (i < 0)
1496 1496
	fprintf (stderr, _("Unrecognised register name set: %s\n"), option);
1497 1497
    }
......
1501 1501
    force_thumb = 0;
1502 1502
  else
1503 1503
    fprintf (stderr, _("Unrecognised disassembler option: %s\n"), option);
1504
 
1504

  
1505 1505
  return;
1506 1506
}
1507 1507

  
......
1512 1512
     char * options;
1513 1513
{
1514 1514
  char * space;
1515
 
1515

  
1516 1516
  if (options == NULL)
1517 1517
    return;
1518 1518

  
......
1550 1550
  if (info->disassembler_options)
1551 1551
    {
1552 1552
      parse_disassembler_options (info->disassembler_options);
1553
     
1553

  
1554 1554
      /* To avoid repeated parsing of these options, we remove them here.  */
1555 1555
      info->disassembler_options = NULL;
1556 1556
    }
1557
 
1557

  
1558 1558
  is_thumb = force_thumb;
1559 1559
  if (pc & 1)
1560 1560
    {
1561 1561
      is_thumb = 1;
1562 1562
      pc &= ~(bfd_vma) 1;
1563 1563
    }
1564
 
1564

  
1565 1565
#if 0
1566 1566
  if (!is_thumb && info->symbols != NULL)
1567 1567
    {
1568 1568
      if (bfd_asymbol_flavour (*info->symbols) == bfd_target_coff_flavour)
1569 1569
	{
1570 1570
	  coff_symbol_type * cs;
1571
	 
1571

  
1572 1572
	  cs = coffsymbol (*info->symbols);
1573 1573
	  is_thumb = (   cs->native->u.syment.n_sclass == C_THUMBEXT
1574 1574
		      || cs->native->u.syment.n_sclass == C_THUMBSTAT
......
1580 1580
	{
1581 1581
	  elf_symbol_type *  es;
1582 1582
	  unsigned int       type;
1583
	 
1583

  
1584 1584
	  es = *(elf_symbol_type **)(info->symbols);
1585 1585
	  type = ELF_ST_TYPE (es->internal_elf_sym.st_info);
1586
	 
1586

  
1587 1587
	  is_thumb = (type == STT_ARM_TFUNC) || (type == STT_ARM_16BIT);
1588 1588
	}
1589 1589
    }
1590 1590
#endif
1591
 
1591

  
1592 1592
  little = (info->endian == BFD_ENDIAN_LITTLE);
1593 1593
  info->bytes_per_chunk = 4;
1594 1594
  info->display_endian  = little ? BFD_ENDIAN_LITTLE : BFD_ENDIAN_BIG;
......
1599 1599
      if (status != 0 && is_thumb)
1600 1600
	{
1601 1601
	  info->bytes_per_chunk = 2;
1602
	 
1602

  
1603 1603
	  status = info->read_memory_func (pc, (bfd_byte *) b, 2, info);
1604 1604
	  b[3] = b[2] = 0;
1605 1605
	}
1606
     
1606

  
1607 1607
      if (status != 0)
1608 1608
	{
1609 1609
	  info->memory_error_func (status, pc, info);
1610 1610
	  return -1;
1611 1611
	}
1612
     
1612

  
1613 1613
      given = (b[0]) | (b[1] << 8) | (b[2] << 16) | (b[3] << 24);
1614 1614
    }
1615 1615
  else
......
1621 1621
	  info->memory_error_func (status, pc, info);
1622 1622
	  return -1;
1623 1623
	}
1624
     
1624

  
1625 1625
      if (is_thumb)
1626 1626
	{
1627 1627
	  if (pc & 0x2)
1628 1628
	    {
1629 1629
	      given = (b[2] << 8) | b[3];
1630
	     
1630

  
1631 1631
	      status = info->read_memory_func
1632 1632
		((pc + 4) & ~ 0x3, (bfd_byte *) b, 4, info);
1633 1633
	      if (status != 0)
......
1635 1635
		  info->memory_error_func (status, pc + 4, info);
1636 1636
		  return -1;
1637 1637
		}
1638
	     
1638

  
1639 1639
	      given |= (b[0] << 24) | (b[1] << 16);
1640 1640
	    }
1641 1641
	  else
......
1644 1644
      else
1645 1645
	given = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3]);
1646 1646
    }
1647
 
1647

  
1648 1648
  if (info->flags & INSN_HAS_RELOC)
1649 1649
    /* If the instruction has a reloc associated with it, then
1650 1650
       the offset field in the instruction will actually be the
......
1668 1668
  fprintf (stream, _("\n\
1669 1669
The following ARM specific disassembler options are supported for use with\n\
1670 1670
the -M switch:\n"));
1671
 
1671

  
1672 1672
  for (i = NUM_ARM_REGNAMES; i--;)
1673 1673
    fprintf (stream, "  reg-names-%s %*c%s\n",
1674 1674
	     regnames[i].name,
b/arm-semi.c
401 401
                }
402 402
                ts->heap_limit = limit;
403 403
            }
404
             
404

  
405 405
            ptr = lock_user(ARG(0), 16, 0);
406 406
            ptr[0] = tswap32(ts->heap_base);
407 407
            ptr[1] = tswap32(ts->heap_limit);
b/block-bochs.c
44 44
    char subtype[16]; // "Undoable" / "Volatile" / "Growing"
45 45
    uint32_t version;
46 46
    uint32_t header; // size of header
47
   
47

  
48 48
    union {
49 49
	struct {
50 50
	    uint32_t catalog; // num of entries
......
64 64
    char subtype[16]; // "Undoable" / "Volatile" / "Growing"
65 65
    uint32_t version;
66 66
    uint32_t header; // size of header
67
   
67

  
68 68
    union {
69 69
	struct {
70 70
	    uint32_t catalog; // num of entries
......
83 83

  
84 84
    uint32_t *catalog_bitmap;
85 85
    int catalog_size;
86
   
86

  
87 87
    int data_offset;
88
   
88

  
89 89
    int bitmap_blocks;
90 90
    int extent_blocks;
91 91
    int extent_size;
......
94 94
static int bochs_probe(const uint8_t *buf, int buf_size, const char *filename)
95 95
{
96 96
    const struct bochs_header *bochs = (const void *)buf;
97
   
97

  
98 98
    if (buf_size < HEADER_SIZE)
99 99
	return 0;
100 100

  
......
121 121
        if (fd < 0)
122 122
            return -1;
123 123
    }
124
   
124

  
125 125
    bs->read_only = 1; // no write support yet
126
   
126

  
127 127
    s->fd = fd;
128 128

  
129 129
    if (read(fd, &bochs, sizeof(bochs)) != sizeof(bochs)) {
......
161 161

  
162 162
    s->bitmap_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.bitmap) - 1) / 512;
163 163
    s->extent_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.extent) - 1) / 512;
164
   
164

  
165 165
    s->extent_size = le32_to_cpu(bochs.extra.redolog.extent);
166 166

  
167 167
    return 0;
......
180 180
    // seek to sector
181 181
    extent_index = offset / s->extent_size;
182 182
    extent_offset = (offset % s->extent_size) / 512;
183
   
183

  
184 184
    if (s->catalog_bitmap[extent_index] == 0xffffffff)
185 185
    {
186 186
//	fprintf(stderr, "page not allocated [%x - %x:%x]\n",
......
191 191
    bitmap_offset = s->data_offset + (512 * s->catalog_bitmap[extent_index] *
192 192
	(s->extent_blocks + s->bitmap_blocks));
193 193
    block_offset = bitmap_offset + (512 * (s->bitmap_blocks + extent_offset));
194
   
194

  
195 195
//    fprintf(stderr, "sect: %x [ext i: %x o: %x] -> %x bitmap: %x block: %x\n",
196 196
//	sector_num, extent_index, extent_offset,
197 197
//	le32_to_cpu(s->catalog_bitmap[extent_index]),
198 198
//	bitmap_offset, block_offset);
199
   
199

  
200 200
    // read in bitmap for current extent
201 201
    lseek(s->fd, bitmap_offset + (extent_offset / 8), SEEK_SET);
202
   
202

  
203 203
    read(s->fd, &bitmap_entry, 1);
204
   
204

  
205 205
    if (!((bitmap_entry >> (extent_offset % 8)) & 1))
206 206
    {
207 207
//	fprintf(stderr, "sector (%x) in bitmap not allocated\n",
......
210 210
    }
211 211

  
212 212
    lseek(s->fd, block_offset, SEEK_SET);
213
   
213

  
214 214
    return 0;
215 215
}
216 216

  
b/block-cloop.c
96 96
    if(inflateInit(&s->zstream) != Z_OK)
97 97
	goto cloop_close;
98 98
    s->current_block=s->n_blocks;
99
   
99

  
100 100
    s->sectors_per_block = s->block_size/512;
101 101
    bs->total_sectors = s->n_blocks*s->sectors_per_block;
102 102
    return 0;
......
107 107
    if(s->current_block != block_num) {
108 108
	int ret;
109 109
        uint32_t bytes = s->offsets[block_num+1]-s->offsets[block_num];
110
	   
110

  
111 111
	lseek(s->fd, s->offsets[block_num], SEEK_SET);
112 112
        ret = read(s->fd, s->compressed_block, bytes);
113 113
        if (ret != bytes)
b/block-cow.c
85 85
        be32_to_cpu(cow_header.version) != COW_VERSION) {
86 86
        goto fail;
87 87
    }
88
       
88

  
89 89
    /* cow image found */
90 90
    size = be64_to_cpu(cow_header.size);
91 91
    bs->total_sectors = size / 512;
92 92

  
93 93
    pstrcpy(bs->backing_file, sizeof(bs->backing_file),
94 94
            cow_header.backing_file);
95
   
95

  
96 96
    /* mmap the bitmap */
97 97
    s->cow_bitmap_size = ((bs->total_sectors + 7) >> 3) + sizeof(cow_header);
98 98
    s->cow_bitmap_addr = mmap(get_mmap_addr(s->cow_bitmap_size),
......
155 155
{
156 156
    BDRVCowState *s = bs->opaque;
157 157
    int ret, n;
158
   
158

  
159 159
    while (nb_sectors > 0) {
160 160
        if (is_changed(s->cow_bitmap, sector_num, nb_sectors, &n)) {
161 161
            lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
......
184 184
{
185 185
    BDRVCowState *s = bs->opaque;
186 186
    int ret, i;
187
   
187

  
188 188
    lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
189 189
    ret = write(s->fd, buf, nb_sectors * 512);
190 190
    if (ret != nb_sectors * 512)
b/block-dmg.c
28 28

  
29 29
typedef struct BDRVDMGState {
30 30
    int fd;
31
   
31

  
32 32
    /* each chunk contains a certain number of sectors,
33 33
     * offsets[i] is the offset in the .dmg file,
34 34
     * lengths[i] is the length of the compressed chunk,
......
86 86
    bs->read_only = 1;
87 87
    s->n_chunks = 0;
88 88
    s->offsets = s->lengths = s->sectors = s->sectorcounts = 0;
89
   
89

  
90 90
    /* read offset of info blocks */
91 91
    if(lseek(s->fd,-0x1d8,SEEK_END)<0) {
92 92
dmg_close:
......
167 167
	goto dmg_close;
168 168

  
169 169
    s->current_chunk = s->n_chunks;
170
   
170

  
171 171
    return 0;
172 172
}
173 173

  
b/block-qcow.c
80 80
static int qcow_probe(const uint8_t *buf, int buf_size, const char *filename)
81 81
{
82 82
    const QCowHeader *cow_header = (const void *)buf;
83
   
83

  
84 84
    if (buf_size >= sizeof(QCowHeader) &&
85 85
        be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&
86 86
        be32_to_cpu(cow_header->version) == QCOW_VERSION)
......
108 108
    be64_to_cpus(&header.size);
109 109
    be32_to_cpus(&header.crypt_method);
110 110
    be64_to_cpus(&header.l1_table_offset);
111
   
111

  
112 112
    if (header.magic != QCOW_MAGIC || header.version != QCOW_VERSION)
113 113
        goto fail;
114 114
    if (header.size <= 1 || header.cluster_bits < 9)
......
151 151
    if (!s->cluster_data)
152 152
        goto fail;
153 153
    s->cluster_cache_offset = -1;
154
   
154

  
155 155
    /* read the backing file name */
156 156
    if (header.backing_file_offset != 0) {
157 157
        len = header.backing_file_size;
......
177 177
    BDRVQcowState *s = bs->opaque;
178 178
    uint8_t keybuf[16];
179 179
    int len, i;
180
   
180

  
181 181
    memset(keybuf, 0, 16);
182 182
    len = strlen(key);
183 183
    if (len > 16)
......
262 262
    uint64_t l2_offset, *l2_table, cluster_offset, tmp;
263 263
    uint32_t min_count;
264 264
    int new_l2_table;
265
   
265

  
266 266
    l1_index = offset >> (s->l2_bits + s->cluster_bits);
267 267
    l2_offset = s->l1_table[l1_index];
268 268
    new_l2_table = 0;
......
420 420
    inflateEnd(strm);
421 421
    return 0;
422 422
}
423
                             
423

  
424 424
static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset)
425 425
{
426 426
    int ret, csize;
......
450 450
    BDRVQcowState *s = bs->opaque;
451 451
    int ret, index_in_cluster, n;
452 452
    uint64_t cluster_offset;
453
   
453

  
454 454
    while (nb_sectors > 0) {
455 455
        cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0);
456 456
        index_in_cluster = sector_num & (s->cluster_sectors - 1);
......
493 493
    BDRVQcowState *s = bs->opaque;
494 494
    int ret, index_in_cluster, n;
495 495
    uint64_t cluster_offset;
496
   
496

  
497 497
    while (nb_sectors > 0) {
498 498
        index_in_cluster = sector_num & (s->cluster_sectors - 1);
499 499
        n = s->cluster_sectors - index_in_cluster;
......
572 572
        qemu_aio_release(acb);
573 573
        return;
574 574
    }
575
   
575

  
576 576
    /* prepare next AIO request */
577 577
    acb->cluster_offset = get_cluster_offset(bs, acb->sector_num << 9,
578 578
                                             0, 0, 0, 0);
......
627 627
    acb->buf = buf;
628 628
    acb->nb_sectors = nb_sectors;
629 629
    acb->n = 0;
630
    acb->cluster_offset = 0;   
630
    acb->cluster_offset = 0;
631 631

  
632 632
    qcow_aio_read_cb(acb, 0);
633 633
    return &acb->common;
......
661 661
        qemu_aio_release(acb);
662 662
        return;
663 663
    }
664
   
664

  
665 665
    index_in_cluster = acb->sector_num & (s->cluster_sectors - 1);
666 666
    acb->n = s->cluster_sectors - index_in_cluster;
667 667
    if (acb->n > acb->nb_sectors)
......
701 701
{
702 702
    BDRVQcowState *s = bs->opaque;
703 703
    QCowAIOCB *acb;
704
   
704

  
705 705
    s->cluster_cache_offset = -1; /* disable compressed cache */
706 706

  
707 707
    acb = qemu_aio_get(bs, cb, opaque);
......
712 712
    acb->buf = (uint8_t *)buf;
713 713
    acb->nb_sectors = nb_sectors;
714 714
    acb->n = 0;
715
   
715

  
716 716
    qcow_aio_write_cb(acb, 0);
717 717
    return &acb->common;
718 718
}
......
774 774
    } else {
775 775
        header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
776 776
    }
777
   
777

  
778 778
    /* write all the data */
779 779
    write(fd, &header, sizeof(header));
780 780
    if (backing_file) {
......
864 864
            return -1;
865 865
        }
866 866
    }
867
   
867

  
868 868
    qemu_free(out_buf);
869 869
    return 0;
870 870
}
b/block-qcow2.c
37 37
  - Size of compressed clusters is stored in sectors to reduce bit usage
38 38
    in the cluster offsets.
39 39
  - Support for storing additional data (such as the VM state) in the
40
    snapshots. 
40
    snapshots.
41 41
  - If a backing store is used, the cluster size is not constrained
42 42
    (could be backported to QCOW).
43 43
  - L2 tables have always a size of one cluster.
......
176 176
static int qcow_probe(const uint8_t *buf, int buf_size, const char *filename)
177 177
{
178 178
    const QCowHeader *cow_header = (const void *)buf;
179
   
179

  
180 180
    if (buf_size >= sizeof(QCowHeader) &&
181 181
        be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&
182 182
        be32_to_cpu(cow_header->version) == QCOW_VERSION)
......
209 209
    be32_to_cpus(&header.refcount_table_clusters);
210 210
    be64_to_cpus(&header.snapshots_offset);
211 211
    be32_to_cpus(&header.nb_snapshots);
212
   
212

  
213 213
    if (header.magic != QCOW_MAGIC || header.version != QCOW_VERSION)
214 214
        goto fail;
215 215
    if (header.size <= 1 ||
......
267 267
    if (!s->cluster_data)
268 268
        goto fail;
269 269
    s->cluster_cache_offset = -1;
270
   
270

  
271 271
    if (refcount_init(bs) < 0)
272 272
        goto fail;
273 273

  
......
304 304
    BDRVQcowState *s = bs->opaque;
305 305
    uint8_t keybuf[16];
306 306
    int len, i;
307
   
307

  
308 308
    memset(keybuf, 0, 16);
309 309
    len = strlen(key);
310 310
    if (len > 16)
......
451 451

  
452 452
    /* write new table (align to cluster) */
453 453
    new_l1_table_offset = alloc_clusters(bs, new_l1_size2);
454
   
454

  
455 455
    for(i = 0; i < s->l1_size; i++)
456 456
        new_l1_table[i] = cpu_to_be64(new_l1_table[i]);
457 457
    ret = bdrv_pwrite(s->hd, new_l1_table_offset, new_l1_table, new_l1_size2);
......
459 459
        goto fail;
460 460
    for(i = 0; i < s->l1_size; i++)
461 461
        new_l1_table[i] = be64_to_cpu(new_l1_table[i]);
462
   
462

  
463 463
    /* set new table */
464 464
    data64 = cpu_to_be64(new_l1_table_offset);
465 465
    if (bdrv_pwrite(s->hd, offsetof(QCowHeader, l1_table_offset),
......
501 501
    BDRVQcowState *s = bs->opaque;
502 502
    int min_index, i, j, l1_index, l2_index, ret;
503 503
    uint64_t l2_offset, *l2_table, cluster_offset, tmp, old_l2_offset;
504
   
504

  
505 505
    l1_index = offset >> (s->l2_bits + s->cluster_bits);
506 506
    if (l1_index >= s->l1_size) {
507 507
        /* outside l1 table is allowed: we grow the table if needed */
......
600 600
           written */
601 601
        if ((n_end - n_start) < s->cluster_sectors) {
602 602
            uint64_t start_sect;
603
           
603

  
604 604
            start_sect = (offset & ~(s->cluster_size - 1)) >> 9;
605 605
            ret = copy_sectors(bs, start_sect,
606 606
                               cluster_offset, 0, n_start);
......
672 672
    inflateEnd(strm);
673 673
    return 0;
674 674
}
675
                             
675

  
676 676
static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset)
677 677
{
678 678
    int ret, csize, nb_csectors, sector_offset;
......
717 717
    BDRVQcowState *s = bs->opaque;
718 718
    int ret, index_in_cluster, n, n1;
719 719
    uint64_t cluster_offset;
720
   
720

  
721 721
    while (nb_sectors > 0) {
722 722
        cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0);
723 723
        index_in_cluster = sector_num & (s->cluster_sectors - 1);
......
762 762
    BDRVQcowState *s = bs->opaque;
763 763
    int ret, index_in_cluster, n;
764 764
    uint64_t cluster_offset;
765
   
765

  
766 766
    while (nb_sectors > 0) {
767 767
        index_in_cluster = sector_num & (s->cluster_sectors - 1);
768 768
        n = s->cluster_sectors - index_in_cluster;
......
841 841
        qemu_aio_release(acb);
842 842
        return;
843 843
    }
844
   
844

  
845 845
    /* prepare next AIO request */
846 846
    acb->cluster_offset = get_cluster_offset(bs, acb->sector_num << 9,
847 847
                                             0, 0, 0, 0);
......
948 948
        qemu_aio_release(acb);
949 949
        return;
950 950
    }
951
   
951

  
952 952
    index_in_cluster = acb->sector_num & (s->cluster_sectors - 1);
953 953
    acb->n = s->cluster_sectors - index_in_cluster;
954 954
    if (acb->n > acb->nb_sectors)
......
988 988
{
989 989
    BDRVQcowState *s = bs->opaque;
990 990
    QCowAIOCB *acb;
991
   
991

  
992 992
    s->cluster_cache_offset = -1; /* disable compressed cache */
993 993

  
994 994
    acb = qcow_aio_setup(bs, sector_num, (uint8_t*)buf, nb_sectors, cb, opaque);
995 995
    if (!acb)
996 996
        return NULL;
997
   
997

  
998 998
    qcow_aio_write_cb(acb, 0);
999 999
    return &acb->common;
1000 1000
}
......
1054 1054
    QCowHeader header;
1055 1055
    uint64_t tmp, offset;
1056 1056
    QCowCreateState s1, *s = &s1;
1057
   
1057

  
1058 1058
    memset(s, 0, sizeof(*s));
1059 1059

  
1060 1060
    fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
......
1096 1096
    s->refcount_block = qemu_mallocz(s->cluster_size);
1097 1097
    if (!s->refcount_block)
1098 1098
        goto fail;
1099
   
1099

  
1100 1100
    s->refcount_table_offset = offset;
1101 1101
    header.refcount_table_offset = cpu_to_be64(offset);
1102 1102
    header.refcount_table_clusters = cpu_to_be32(1);
......
1111 1111
    create_refcount_update(s, s->l1_table_offset, l1_size * sizeof(uint64_t));
1112 1112
    create_refcount_update(s, s->refcount_table_offset, s->cluster_size);
1113 1113
    create_refcount_update(s, s->refcount_block_offset, s->cluster_size);
1114
   
1114

  
1115 1115
    /* write all the data */
1116 1116
    write(fd, &header, sizeof(header));
1117 1117
    if (backing_file) {
......
1124 1124
    }
1125 1125
    lseek(fd, s->refcount_table_offset, SEEK_SET);
1126 1126
    write(fd, s->refcount_table, s->cluster_size);
1127
   
1127

  
1128 1128
    lseek(fd, s->refcount_block_offset, SEEK_SET);
1129 1129
    write(fd, s->refcount_block, s->cluster_size);
1130 1130

  
......
1153 1153
    ret = bdrv_truncate(s->hd, s->l1_table_offset + l1_length);
1154 1154
    if (ret < 0)
1155 1155
        return ret;
1156
   
1156

  
1157 1157
    l2_cache_reset(bs);
1158 1158
#endif
1159 1159
    return 0;
......
1223 1223
            return -1;
1224 1224
        }
1225 1225
    }
1226
   
1226

  
1227 1227
    qemu_free(out_buf);
1228 1228
    return 0;
1229 1229
}
......
1256 1256
    uint64_t *l1_table, *l2_table, l2_offset, offset, l1_size2, l1_allocated;
1257 1257
    int64_t old_offset, old_l2_offset;
1258 1258
    int l2_size, i, j, l1_modified, l2_modified, nb_csectors, refcount;
1259
   
1259

  
1260 1260
    l2_cache_reset(bs);
1261 1261

  
1262 1262
    l2_table = NULL;
......
1278 1278
        l1_table = s->l1_table;
1279 1279
        l1_allocated = 0;
1280 1280
    }
1281
   
1281

  
1282 1282
    l2_size = s->l2_size * sizeof(uint64_t);
1283 1283
    l2_table = qemu_malloc(l2_size);
1284 1284
    if (!l2_table)
......
1455 1455

  
1456 1456
    snapshots_offset = alloc_clusters(bs, snapshots_size);
1457 1457
    offset = snapshots_offset;
1458
   
1458

  
1459 1459
    for(i = 0; i < s->nb_snapshots; i++) {
1460 1460
        sn = s->snapshots + i;
1461 1461
        memset(&h, 0, sizeof(h));
......
1465 1465
        h.date_sec = cpu_to_be32(sn->date_sec);
1466 1466
        h.date_nsec = cpu_to_be32(sn->date_nsec);
1467 1467
        h.vm_clock_nsec = cpu_to_be64(sn->vm_clock_nsec);
1468
       
1468

  
1469 1469
        id_str_size = strlen(sn->id_str);
1470 1470
        name_size = strlen(sn->name);
1471 1471
        h.id_str_size = cpu_to_be16(id_str_size);
......
1533 1533
{
1534 1534
    BDRVQcowState *s = bs->opaque;
1535 1535
    int i, ret;
1536
   
1536

  
1537 1537
    ret = find_snapshot_by_id(bs, name);
1538 1538
    if (ret >= 0)
1539 1539
        return ret;
......
1552 1552
    QCowSnapshot *snapshots1, sn1, *sn = &sn1;
1553 1553
    int i, ret;
1554 1554
    uint64_t *l1_table = NULL;
1555
   
1555

  
1556 1556
    memset(sn, 0, sizeof(*sn));
1557 1557

  
1558 1558
    if (sn_info->id_str[0] == '\0') {
......
1663 1663
    BDRVQcowState *s = bs->opaque;
1664 1664
    QCowSnapshot *sn;
1665 1665
    int snapshot_index, ret;
1666
   
1666

  
1667 1667
    snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id);
1668 1668
    if (snapshot_index < 0)
1669 1669
        return -ENOENT;
......
1731 1731
{
1732 1732
    BDRVQcowState *s = bs->opaque;
1733 1733
    int ret, refcount_table_size2, i;
1734
   
1734

  
1735 1735
    s->refcount_block_cache = qemu_malloc(s->cluster_size);
1736 1736
    if (!s->refcount_block_cache)
1737 1737
        goto fail;
......
1839 1839
    BDRVQcowState *s = bs->opaque;
1840 1840
    int64_t offset, cluster_offset;
1841 1841
    int free_in_cluster;
1842
   
1842

  
1843 1843
    assert(size > 0 && size <= s->cluster_size);
1844 1844
    if (s->free_byte_offset == 0) {
1845 1845
        s->free_byte_offset = alloc_clusters(bs, s->cluster_size);
......
2043 2043
    BDRVQcowState *s = bs->opaque;
2044 2044
    int64_t start, last, cluster_offset;
2045 2045
    int k;
2046
   
2046

  
2047 2047
    if (size <= 0)
2048 2048
        return;
2049 2049

  
......
2086 2086
        goto fail;
2087 2087
    for(i = 0;i < l1_size; i++)
2088 2088
        be64_to_cpus(&l1_table[i]);
2089
   
2089

  
2090 2090
    l2_size = s->l2_size * sizeof(uint64_t);
2091 2091
    l2_table = qemu_malloc(l2_size);
2092 2092
    if (!l2_table)
......
2165 2165
    /* header */
2166 2166
    inc_refcounts(bs, refcount_table, nb_clusters,
2167 2167
                  0, s->cluster_size);
2168
   
2168

  
2169 2169
    check_refcounts_l1(bs, refcount_table, nb_clusters,
2170 2170
                       s->l1_table_offset, s->l1_size, 1);
2171 2171

  
b/block-raw.c
142 142
{
143 143
    BDRVRawState *s = bs->opaque;
144 144
    int ret;
145
   
145

  
146 146
    ret = fd_open(bs);
147 147
    if (ret < 0)
148 148
        return ret;
......
194 194
{
195 195
    BDRVRawState *s = bs->opaque;
196 196
    int ret;
197
   
197

  
198 198
    ret = fd_open(bs);
199 199
    if (ret < 0)
200 200
        return ret;
......
259 259
    struct sigaction act;
260 260

  
261 261
    aio_initialized = 1;
262
   
262

  
263 263
    sigfillset(&act.sa_mask);
264 264
    act.sa_flags = 0; /* do not restart syscalls to interrupt select() */
265 265
    act.sa_handler = aio_signal_handler;
......
547 547
    raw_close,
548 548
    raw_create,
549 549
    raw_flush,
550
   
550

  
551 551
    .bdrv_aio_read = raw_aio_read,
552 552
    .bdrv_aio_write = raw_aio_write,
553 553
    .bdrv_aio_cancel = raw_aio_cancel,
......
576 576
    if ( KERN_SUCCESS != kernResult ) {
577 577
        printf( "IOMasterPort returned %d\n", kernResult );
578 578
    }
579
   
579

  
580 580
    classesToMatch = IOServiceMatching( kIOCDMediaClass );
581 581
    if ( classesToMatch == NULL ) {
582 582
        printf( "IOServiceMatching returned a NULL dictionary.\n" );
......
588 588
    {
589 589
        printf( "IOServiceGetMatchingServices returned %d\n", kernResult );
590 590
    }
591
   
591

  
592 592
    return kernResult;
593 593
}
594 594

  
......
614 614
        }
615 615
        IOObjectRelease( nextMedia );
616 616
    }
617
   
617

  
618 618
    return kernResult;
619 619
}
620 620

  
......
634 634

  
635 635
        kernResult = FindEjectableCDMedia( &mediaIterator );
636 636
        kernResult = GetBSDPath( mediaIterator, bsdPath, sizeof( bsdPath ) );
637
   
637

  
638 638
        if ( bsdPath[ 0 ] != '\0' ) {
639 639
            strcat(bsdPath,"s0");
640 640
            /* some CDs don't have a partition 0 */
......
646 646
            }
647 647
            filename = bsdPath;
648 648
        }
649
       
649

  
650 650
        if ( mediaIterator )
651 651
            IOObjectRelease( mediaIterator );
652 652
    }
......
883 883
    raw_close,
884 884
    NULL,
885 885
    raw_flush,
886
   
886

  
887 887
    .bdrv_aio_read = raw_aio_read,
888 888
    .bdrv_aio_write = raw_aio_write,
889 889
    .bdrv_aio_cancel = raw_aio_cancel,
......
999 999
    OVERLAPPED ov;
1000 1000
    DWORD ret_count;
1001 1001
    int ret;
1002
   
1002

  
1003 1003
    memset(&ov, 0, sizeof(ov));
1004 1004
    ov.Offset = offset;
1005 1005
    ov.OffsetHigh = offset >> 32;
......
1021 1021
    OVERLAPPED ov;
1022 1022
    DWORD ret_count;
1023 1023
    int ret;
1024
   
1024

  
1025 1025
    memset(&ov, 0, sizeof(ov));
1026 1026
    ov.Offset = offset;
1027 1027
    ov.OffsetHigh = offset >> 32;
......
1256 1256
    raw_close,
1257 1257
    raw_create,
1258 1258
    raw_flush,
1259
   
1259

  
1260 1260
#if 0
1261 1261
    .bdrv_aio_read = raw_aio_read,
1262 1262
    .bdrv_aio_write = raw_aio_write,
......
1335 1335
        }
1336 1336
    }
1337 1337
    s->type = find_device_type(bs, filename);
1338
   
1338

  
1339 1339
    if ((flags & BDRV_O_ACCESS) == O_RDWR) {
1340 1340
        access_flags = GENERIC_READ | GENERIC_WRITE;
1341 1341
    } else {
......
1406 1406
    raw_close,
1407 1407
    NULL,
1408 1408
    raw_flush,
1409
   
1409

  
1410 1410
#if 0
1411 1411
    .bdrv_aio_read = raw_aio_read,
1412 1412
    .bdrv_aio_write = raw_aio_write,
b/block-vmdk.c
110 110

  
111 111
#define CHECK_CID 1
112 112

  
113
#define SECTOR_SIZE 512			
113
#define SECTOR_SIZE 512
114 114
#define DESC_SIZE 20*SECTOR_SIZE	// 20 sectors of 512 bytes each
115 115
#define HEADER_SIZE 512   			// first sector of 512 bytes
116 116

  
......
308 308

  
309 309
    fail_gd:
310 310
    qemu_free(gd_buf);
311
    fail_rgd:  
311
    fail_rgd:
312 312
    qemu_free(rgd_buf);
313 313
    fail:
314 314
    close(p_fd);
......
341 341
        p_name += sizeof("parentFileNameHint") + 1;
342 342
        if ((end_name = strchr(p_name,'\"')) == 0)
343 343
            return -1;
344
               
344

  
345 345
        strncpy(s->hd->backing_file, p_name, end_name - p_name);
346 346
        if (stat(s->hd->backing_file, &file_buf) != 0) {
347 347
            path_combine(parent_img_name, sizeof(parent_img_name),
......
761 761
    header.check_bytes[1] = 0x20;
762 762
    header.check_bytes[2] = 0xd;
763 763
    header.check_bytes[3] = 0xa;
764
   
765
    /* write all the data */   
764

  
765
    /* write all the data */
766 766
    write(fd, &magic, sizeof(magic));
767 767
    write(fd, &header, sizeof(header));
768 768

  
......
773 773
    for (i = 0, tmp = header.rgd_offset + gd_size;
774 774
         i < gt_count; i++, tmp += gt_size)
775 775
        write(fd, &tmp, sizeof(tmp));
776
  
776

  
777 777
    /* write backup grain directory */
778 778
    lseek(fd, le64_to_cpu(header.gd_offset) << 9, SEEK_SET);
779 779
    for (i = 0, tmp = header.gd_offset + gd_size;
b/block-vpc.c
65 65

  
66 66
typedef struct BDRVVPCState {
67 67
    int fd;
68
   
68

  
69 69
    int pagetable_entries;
70 70
    uint32_t *pagetable;
71 71

  
......
74 74
    uint8_t *pageentry_u8;
75 75
    uint32_t *pageentry_u32;
76 76
    uint16_t *pageentry_u16;
77
   
77

  
78 78
    uint64_t last_bitmap;
79 79
#endif
80 80
} BDRVVPCState;
......
97 97
        return -1;
98 98

  
99 99
    bs->read_only = 1; // no write support yet
100
   
100

  
101 101
    s->fd = fd;
102 102

  
103 103
    if (read(fd, &header, HEADER_SIZE) != HEADER_SIZE)
......
153 153

  
154 154
    pagetable_index = offset / s->pageentry_size;
155 155
    pageentry_index = (offset % s->pageentry_size) / 512;
156
   
156

  
157 157
    if (pagetable_index > s->pagetable_entries || s->pagetable[pagetable_index] == 0xffffffff)
158 158
	return -1; // not allocated
159 159

  
160 160
    bitmap_offset = 512 * s->pagetable[pagetable_index];
161 161
    block_offset = bitmap_offset + 512 + (512 * pageentry_index);
162
   
162

  
163 163
//    printf("sector: %" PRIx64 ", index: %x, offset: %x, bioff: %" PRIx64 ", bloff: %" PRIx64 "\n",
164 164
//	sector_num, pagetable_index, pageentry_index,
165 165
//	bitmap_offset, block_offset);
b/block-vvfat.c
153 153
	    index_to<0 || index_to>=array->next ||
154 154
	    index_from<0 || index_from>=array->next)
155 155
	return -1;
156
   
156

  
157 157
    if(index_to==index_from)
158 158
	return 0;
159 159

  
......
167 167
	memmove(to+is*count,to,from-to);
168 168
    else
169 169
	memmove(from,from+is*count,to-from);
170
   
170

  
171 171
    memcpy(to,buf,is*count);
172 172

  
173 173
    free(buf);
......
319 319
    BlockDriverState* bs; /* pointer to parent */
320 320
    unsigned int first_sectors_number; /* 1 for a single partition, 0x40 for a disk with partition table */
321 321
    unsigned char first_sectors[0x40*0x200];
322
   
322

  
323 323
    int fat_type; /* 16 or 32 */
324 324
    array_t fat,directory,mapping;
325
  
325

  
326 326
    unsigned int cluster_size;
327 327
    unsigned int sectors_per_cluster;
328 328
    unsigned int sectors_per_fat;
......
332 332
    uint32_t sector_count; /* total number of sectors of the partition */
333 333
    uint32_t cluster_count; /* total number of clusters of this partition */
334 334
    uint32_t max_fat_value;
335
  
335

  
336 336
    int current_fd;
337 337
    mapping_t* current_mapping;
338 338
    unsigned char* cluster; /* points to current cluster */
......
358 358
    partition_t* partition=&(real_mbr->partition[0]);
359 359

  
360 360
    memset(s->first_sectors,0,512);
361
  
361

  
362 362
    partition->attributes=0x80; /* bootable */
363 363
    partition->start_head=1;
364 364
    partition->start_sector=1;
......
478 478
    for(i=0;i<11;i++)
479 479
	chksum=(((chksum&0xfe)>>1)|((chksum&0x01)?0x80:0))
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff