Changeset 8f73af85 in rtems
- Timestamp:
- 11/20/14 23:19:13 (9 years ago)
- Branches:
- 4.11, 5, master
- Children:
- e8abdfb
- Parents:
- 5dff7425
- git-author:
- Joel Sherrill <joel.sherrill@…> (11/20/14 23:19:13)
- git-committer:
- Joel Sherrill <joel.sherrill@…> (11/21/14 19:13:21)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/libfs/src/dosfs/msdos_format.c
r5dff7425 r8f73af85 218 218 */ 219 219 while ((ret_val == 0) && 220 220 (sector_cnt > 0)) { 221 221 int percent = (sector_cnt * 100) / total_sectors; 222 222 if (percent != last_percent) { … … 311 311 312 312 bool finished = false; 313 int ret_val = 0;314 313 uint32_t fatdata_cluster_cnt; 315 314 uint32_t fat_capacity; … … 351 350 352 351 sectors_per_fat = ((fat_capacity 353 354 352 + (bytes_per_sector - 1)) 353 / bytes_per_sector); 355 354 356 355 fat_sectors_cnt = loc_align_object (sectors_per_fat * fat_num, … … 359 358 360 359 *data_cluster_cnt = (fatdata_cluster_cnt - 361 362 363 360 ((fat_sectors_cnt 361 + (sectors_per_cluster - 1)) 362 / sectors_per_cluster)); 364 363 /* 365 364 * data cluster count too big? Then make clusters bigger … … 380 379 } 381 380 } else if ((sectors_per_cluster * bytes_per_sector) 382 381 > MS_BYTES_PER_CLUSTER_LIMIT) { 383 382 finished = true; 384 383 } … … 388 387 *sectors_per_fat_ptr = fat_sectors_cnt / fat_num; 389 388 390 if (ret_val != 0) { 391 errno = EINVAL; 392 } 393 394 return ret_val; 389 return 0; 395 390 } 396 391 … … 526 521 */ 527 522 if (ret_val == 0) { 528 if ((rqdata == NULL) || 529 (rqdata->fat_num == 0)) { 523 if ((rqdata == NULL) || (rqdata->fat_num == 0)) { 530 524 fmt_params->fat_num = 2; 531 525 } … … 683 677 684 678 ret_val = msdos_format_eval_sectors_per_cluster(fmt_params->fattype, 685 686 687 688 689 690 691 692 693 694 679 fmt_params->bytes_per_sector, 680 fmt_params->totl_sector_cnt, 681 fmt_params->rsvd_sector_cnt, 682 fmt_params->root_dir_sectors, 683 fmt_params->fat_num, 684 fmt_params->sectors_per_cluster, 685 fmt_params->skip_alignment, 686 §ors_per_cluster_adj, 687 &fmt_params->sectors_per_fat, 688 &data_clusters_cnt); 695 689 fmt_params->sectors_per_cluster = sectors_per_cluster_adj; 696 690 fat_type = fmt_params->fattype; … … 744 738 */ 745 739 if (ret_val == 0) { 746 if ((rqdata != NULL) && 747 (rqdata->media != 0)) { 740 if ((rqdata != NULL) && (rqdata->media != 0)) { 748 741 const char valid_media_codes[] = 749 742 {0xF0,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}; 750 743 if (NULL==memchr(valid_media_codes, 751 752 753 754 744 rqdata->media, 745 sizeof(valid_media_codes))) { 746 ret_val = -1; 747 errno = EINVAL; 755 748 } 756 749 else { 757 750 fmt_params->media_code = rqdata->media; 758 751 } 759 752 } … … 789 782 int cnt; 790 783 from = "RTEMS"; /* default: make "from" point to OS Name */ 791 if ((rqdata != NULL) && 792 (rqdata->OEMName != NULL)) { 784 if ((rqdata != NULL) && (rqdata->OEMName != NULL)) { 793 785 from = rqdata->OEMName; 794 786 } 795 for (cnt = 0; 796 cnt < (sizeof(fmt_params->OEMName)-1); 797 cnt++) { 787 for (cnt = 0; cnt < (sizeof(fmt_params->OEMName)-1); cnt++) { 798 788 if (isprint((unsigned char)*from)) { 799 789 *to++ = *from++; 800 790 } 801 791 else { 802 803 804 805 806 807 792 /* 793 * non-printable character in given name, so keep stuck 794 * at that character and replace all following characters 795 * with a ' ' 796 */ 797 *to++=' '; 808 798 } 809 799 *to = '\0'; … … 820 810 from = ""; /* default: make "from" point to empty string */ 821 811 if ((rqdata != NULL) && 822 812 (rqdata->VolLabel != NULL)) { 823 813 from = rqdata->VolLabel; 824 814 fmt_params->VolLabel_present = true; 825 815 } 826 for (cnt = 0; 827 cnt < (sizeof(fmt_params->VolLabel)-1); 828 cnt++) { 816 for (cnt = 0; cnt < (sizeof(fmt_params->VolLabel)-1); cnt++) { 829 817 if (isprint((unsigned char)*from)) { 830 818 *to++ = *from++; 831 819 } 832 820 else { 833 834 835 836 837 838 821 /* 822 * non-printable character in given name, so keep stuck 823 * at that character and replace all following characters 824 * with a ' ' 825 */ 826 *to++=' '; 839 827 } 840 828 *to = '\0'; … … 901 889 */ 902 890 memcpy(FAT_GET_ADDR_BR_OEMNAME(mbr), 903 904 891 fmt_params->OEMName, 892 FAT_BR_OEMNAME_SIZE); 905 893 FAT_SET_BR_BYTES_PER_SECTOR(mbr , fmt_params->bytes_per_sector); 906 894 FAT_SET_BR_SECTORS_PER_CLUSTER(mbr , fmt_params->sectors_per_cluster); … … 925 913 FAT_SET_BR_VOLID(mbr , fmt_params->vol_id); /* volume id */ 926 914 memcpy(FAT_GET_ADDR_BR_VOLLAB(mbr), 927 928 915 fmt_params->VolLabel, 916 FAT_BR_VOLLAB_SIZE); 929 917 memcpy(FAT_GET_ADDR_BR_FILSYSTYPE(mbr), 930 931 932 933 918 (fmt_params->fattype == FAT_FAT12) 919 ? "FAT12 " 920 : "FAT16 ", 921 FAT_BR_FILSYSTYPE_SIZE); 934 922 } 935 923 else { … … 948 936 memset(FAT_GET_ADDR_BR_FAT32_VOLLAB(mbr) ,0,FAT_BR_VOLLAB_SIZE); 949 937 memcpy(FAT_GET_ADDR_BR_FAT32_FILSYSTYPE(mbr), 950 951 938 "FAT32 ", 939 FAT_BR_FILSYSTYPE_SIZE); 952 940 } 953 941 /* … … 1003 991 * write "empty" values for free cluster count and next cluster number 1004 992 */ 1005 FAT_SET_FSINFO_FREE_CLUSTER_COUNT(fsinfo+FAT_FSI_INFO, 1006 0xffffffff); 1007 FAT_SET_FSINFO_NEXT_FREE_CLUSTER (fsinfo+FAT_FSI_INFO, 1008 0xffffffff); 993 FAT_SET_FSINFO_FREE_CLUSTER_COUNT(fsinfo+FAT_FSI_INFO, 0xffffffff); 994 FAT_SET_FSINFO_NEXT_FREE_CLUSTER (fsinfo+FAT_FSI_INFO, 0xffffffff); 1009 995 return 0; 1010 996 } … … 1142 1128 (fmt_params.fsinfo_sec != 0)) { 1143 1129 ret_val = msdos_format_write_sec(fd, 1144 1145 1146 1130 fmt_params.fsinfo_sec, 1131 fmt_params.bytes_per_sector, 1132 tmp_sec); 1147 1133 } 1148 1134 /* … … 1240 1226 fmt_params.skip_alignment); 1241 1227 for (i = 0; 1242 1243 1228 (i < fmt_params.fat_num) && (ret_val == 0); 1229 i++) { 1244 1230 ret_val = msdos_format_write_sec 1245 1231 (fd,
Note: See TracChangeset
for help on using the changeset viewer.