Revision 3b46e624 block-vvfat.c
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)) |
480 | 480 |
+(unsigned char)entry->name[i]; |
481 |
|
|
481 |
|
|
482 | 482 |
return chksum; |
483 | 483 |
} |
484 | 484 |
|
... | ... | |
554 | 554 |
s->sectors_per_fat * 0x200 / s->fat.item_size - 1); |
555 | 555 |
} |
556 | 556 |
memset(s->fat.pointer,0,s->fat.size); |
557 |
|
|
557 |
|
|
558 | 558 |
switch(s->fat_type) { |
559 | 559 |
case 12: s->max_fat_value=0xfff; break; |
560 | 560 |
case 16: s->max_fat_value=0xffff; break; |
... | ... | |
579 | 579 |
memcpy(entry->name,filename,strlen(filename)); |
580 | 580 |
return entry; |
581 | 581 |
} |
582 |
|
|
582 |
|
|
583 | 583 |
entry_long=create_long_filename(s,filename); |
584 |
|
|
584 |
|
|
585 | 585 |
i = strlen(filename); |
586 | 586 |
for(j = i - 1; j>0 && filename[j]!='.';j--); |
587 | 587 |
if (j > 0) |
... | ... | |
592 | 592 |
entry=array_get_next(&(s->directory)); |
593 | 593 |
memset(entry->name,0x20,11); |
594 | 594 |
strncpy(entry->name,filename,i); |
595 |
|
|
595 |
|
|
596 | 596 |
if(j > 0) |
597 | 597 |
for (i = 0; i < 3 && filename[j+1+i]; i++) |
598 | 598 |
entry->extension[i] = filename[j+1+i]; |
... | ... | |
675 | 675 |
mapping->end = mapping->begin; |
676 | 676 |
return -1; |
677 | 677 |
} |
678 |
|
|
678 |
|
|
679 | 679 |
i = mapping->info.dir.first_dir_index = |
680 | 680 |
first_cluster == 0 ? 0 : s->directory.next; |
681 | 681 |
|
... | ... | |
774 | 774 |
|
775 | 775 |
direntry = (direntry_t*)array_get(&(s->directory), mapping->dir_index); |
776 | 776 |
set_begin_of_direntry(direntry, mapping->begin); |
777 |
|
|
777 |
|
|
778 | 778 |
return 0; |
779 | 779 |
} |
780 | 780 |
|
... | ... | |
825 | 825 |
*/ |
826 | 826 |
i = 1+s->sectors_per_cluster*0x200*8/s->fat_type; |
827 | 827 |
s->sectors_per_fat=(s->sector_count+i)/i; /* round up */ |
828 |
|
|
828 |
|
|
829 | 829 |
array_init(&(s->mapping),sizeof(mapping_t)); |
830 | 830 |
array_init(&(s->directory),sizeof(direntry_t)); |
831 | 831 |
|
... | ... | |
987 | 987 |
s->qcow_filename = NULL; |
988 | 988 |
s->fat2 = NULL; |
989 | 989 |
s->downcase_short_names = 1; |
990 |
|
|
990 |
|
|
991 | 991 |
if (!strstart(dirname, "fat:", NULL)) |
992 | 992 |
return -1; |
993 | 993 |
|
... | ... | |
1709 | 1709 |
} else |
1710 | 1710 |
/* new directory */ |
1711 | 1711 |
schedule_mkdir(s, cluster_num, strdup(path)); |
1712 |
|
|
1712 |
|
|
1713 | 1713 |
lfn_init(&lfn); |
1714 | 1714 |
do { |
1715 | 1715 |
int i; |
... | ... | |
2069 | 2069 |
|
2070 | 2070 |
mapping = next_mapping; |
2071 | 2071 |
} |
2072 |
|
|
2072 |
|
|
2073 | 2073 |
cluster = c1; |
2074 | 2074 |
} |
2075 | 2075 |
|
Also available in: Unified diff