35 |
35 |
36 #include "h_utl.h" |
36 #include "h_utl.h" |
37 #include "r_obey.h" |
37 #include "r_obey.h" |
38 #include "r_coreimage.h" |
38 #include "r_coreimage.h" |
39 #include "patchdataprocessor.h" |
39 #include "patchdataprocessor.h" |
40 #include "filesysteminterface.h" |
40 #include "fatimagegenerator.h" |
41 #include "r_driveimage.h" |
41 #include "r_driveimage.h" |
42 |
42 |
43 extern TInt gCodePagingOverride; |
43 extern TInt gCodePagingOverride; |
44 extern TInt gDataPagingOverride; |
44 extern TInt gDataPagingOverride; |
45 extern ECompression gCompress; |
45 extern ECompression gCompress; |
52 static char* const NullString = "" ; |
52 static char* const NullString = "" ; |
53 const ObeyFileKeyword ObeyFileReader::iKeywords[] = |
53 const ObeyFileKeyword ObeyFileReader::iKeywords[] = |
54 { |
54 { |
55 {_K("file"), 2,-2, EKeywordFile, "File to be copied into ROFS"}, |
55 {_K("file"), 2,-2, EKeywordFile, "File to be copied into ROFS"}, |
56 {_K("data"), 2,-2, EKeywordData, "same as file"}, |
56 {_K("data"), 2,-2, EKeywordData, "same as file"}, |
|
57 {_K("dir"), 2,1, EKeywordDir, "Directory to be created into FAT image"}, |
57 |
58 |
58 {_K("rofsname"), 1, 1, EKeywordRofsName, "output file for ROFS image"}, |
59 {_K("rofsname"), 1, 1, EKeywordRofsName, "output file for ROFS image"}, |
59 {_K("romsize"), 1, 1, EKeywordRomSize, "size of ROM image"}, |
60 {_K("romsize"), 1, 1, EKeywordRomSize, "size of ROM image"}, |
60 {_P("hide"), 2, -1, EKeywordHide, "Exclude named file from ROM directory structure"}, |
61 {_P("hide"), 2, -1, EKeywordHide, "Exclude named file from ROM directory structure"}, |
61 {_P("alias"), 2, -2, EKeywordAlias, "Create alias for existing file in ROM directory structure"}, |
62 {_P("alias"), 2, -2, EKeywordAlias, "Create alias for existing file in ROM directory structure"}, |
410 |
411 |
411 |
412 |
412 const FileAttributeKeyword ObeyFileReader::iAttributeKeywords[] = |
413 const FileAttributeKeyword ObeyFileReader::iAttributeKeywords[] = |
413 { |
414 { |
414 {"attrib",3 ,0,1,EAttributeAtt, "File attributes in ROM file system"}, |
415 {"attrib",3 ,0,1,EAttributeAtt, "File attributes in ROM file system"}, |
415 {"exattrib",3 ,0,1,EAttributeAttExtra, "File extra attributes in ROM file system"}, |
416 {"exattrib",3 ,0,1,EAttributeAttExtra, "File extra attributes in ROM file system"}, |
416 // {_K("compress") ,1,1,EAttributeCompress, "Compress file"}, |
|
417 {"stack",3 ,1,1,EAttributeStack, "?"}, |
417 {"stack",3 ,1,1,EAttributeStack, "?"}, |
418 {"fixed",3 ,1,0,EAttributeFixed, "Relocate to a fixed address space"}, |
418 {"fixed",3 ,1,0,EAttributeFixed, "Relocate to a fixed address space"}, |
419 {"priority",3 ,1,1,EAttributePriority, "Override process priority"}, |
419 {"priority",3 ,1,1,EAttributePriority, "Override process priority"}, |
420 {_K("uid1") ,1,1,EAttributeUid1, "Override first UID"}, |
420 {_K("uid1") ,1,1,EAttributeUid1, "Override first UID"}, |
421 {_K("uid2") ,1,1,EAttributeUid2, "Override second UID"}, |
421 {_K("uid2") ,1,1,EAttributeUid2, "Override second UID"}, |
787 if(*bigString == '\0') |
784 if(*bigString == '\0') |
788 { |
785 { |
789 Print(EWarning,"Not a valid Image Size. Default size is considered\n"); |
786 Print(EWarning,"Not a valid Image Size. Default size is considered\n"); |
790 break; |
787 break; |
791 } |
788 } |
792 #ifdef __LINUX__ |
789 |
793 errno = 0; |
790 Val(iConfigurableFatAttributes.iImageSize,bigString); |
794 iDataSize = strtoll(bigString,NULL,10); |
|
795 if((iDataSize == LONG_MAX) || (iDataSize == LONG_MIN) ||(errno == ERANGE)) |
|
796 { |
|
797 Print(EWarning,"Invalid Range. Default size is considered\n"); |
|
798 } |
|
799 #else |
|
800 iDataSize = _atoi64(bigString); |
|
801 #endif |
|
802 } |
791 } |
803 break; |
792 break; |
804 case EKeywordDataImageVolume: |
793 case EKeywordDataImageVolume: |
805 { |
794 { |
806 // Get the volume label provided by using "volume" keyword. |
795 // Get the volume label provided by using "volume" keyword. |
821 |
810 |
822 // Remove the new line character from the end |
811 // Remove the new line character from the end |
823 position = volumeLabel.find_first_of("\r\n"); |
812 position = volumeLabel.find_first_of("\r\n"); |
824 if (position != string::npos) |
813 if (position != string::npos) |
825 volumeLabel = volumeLabel.substr(0,position); |
814 volumeLabel = volumeLabel.substr(0,position); |
826 |
815 size_t length = volumeLabel.length() ; |
827 iConfigurableFatAttributes->iDriveVolumeLabel = volumeLabel.data() ; |
816 if(length > 11) |
|
817 length = 11 ; |
|
818 memcpy(iConfigurableFatAttributes.iDriveVolumeLabel,volumeLabel.c_str(),length) ; |
|
819 while(length != 11) |
|
820 iConfigurableFatAttributes.iDriveVolumeLabel[length++] = ' '; |
|
821 iConfigurableFatAttributes.iDriveVolumeLabel[length] = 0; |
828 } |
822 } |
829 else { |
823 else { |
830 Print(EWarning,"Value for Volume Label is not provided. Default value is considered.\n"); |
824 Print(EWarning,"Value for Volume Label is not provided. Default value is considered.\n"); |
831 } |
825 } |
832 break; |
826 break; |
837 TInt sectorSize = atoi(bigString); |
831 TInt sectorSize = atoi(bigString); |
838 if(sectorSize <= 0) { |
832 if(sectorSize <= 0) { |
839 Print(EWarning,"Invalid Sector Size value. Default value is considered.\n"); |
833 Print(EWarning,"Invalid Sector Size value. Default value is considered.\n"); |
840 } |
834 } |
841 else { |
835 else { |
842 iConfigurableFatAttributes->iDriveSectorSize = atoi(bigString); |
836 iConfigurableFatAttributes.iDriveSectorSize = atoi(bigString); |
843 } |
837 } |
844 } |
838 } |
845 break; |
839 break; |
846 case EKeywordDataImageNoOfFats: |
840 case EKeywordDataImageNoOfFats: |
847 { |
841 { |
848 const char* bigString = iReader.Word(1); |
842 const char* bigString = iReader.Word(1); |
849 TInt noOfFats = atoi(bigString); |
843 TInt noOfFats = atoi(bigString); |
850 if (noOfFats <=0) |
844 if (noOfFats <=0) |
851 Print(EWarning,"Invalid No of FATs specified. Default value is considered.\n"); |
845 Print(EWarning,"Invalid No of FATs specified. Default value is considered.\n"); |
852 else |
846 else |
853 iConfigurableFatAttributes->iDriveNoOfFATs = atoi(bigString); |
847 iConfigurableFatAttributes.iDriveNoOfFATs = atoi(bigString); |
854 } |
848 } |
855 break; |
849 break; |
856 default: |
850 default: |
857 // unexpected keyword iReader.Word(0), keep going. |
851 // unexpected keyword iReader.Word(0), keep going. |
858 break; |
852 break; |
877 Print(EError,"The name of the image file has not been supplied.\n"); |
871 Print(EError,"The name of the image file has not been supplied.\n"); |
878 Print(EError,"Use the keyword \"dataimagename\".\n"); |
872 Print(EError,"Use the keyword \"dataimagename\".\n"); |
879 retVal = EFalse; |
873 retVal = EFalse; |
880 } |
874 } |
881 // Check for '-'ve entered value. |
875 // Check for '-'ve entered value. |
882 if(iDataSize <= 0){ |
876 if(iConfigurableFatAttributes.iImageSize <= 0){ |
883 Print(EWarning,"Image Size should be positive. Default size is Considered.\n"); |
877 Print(EWarning,"Image Size should be positive. Default size is Considered.\n"); |
884 } |
878 } |
885 |
879 |
886 // File system format. |
880 // File system format. |
887 if(iDriveFileFormat==0) { |
881 if(iDriveFileFormat==0) { |
889 Print(EError,"Use the keyword \"dataimagefilesystem\".\n"); |
883 Print(EError,"Use the keyword \"dataimagefilesystem\".\n"); |
890 retVal = EFalse; |
884 retVal = EFalse; |
891 } |
885 } |
892 |
886 |
893 // Checking the validity of file system format. |
887 // Checking the validity of file system format. |
894 if(iDriveFileFormat){ |
888 if(iDriveFileFormat){ |
895 strupr((char *)iDriveFileFormat); |
889 if(stricmp(iDriveFileFormat,"FAT16") && stricmp(iDriveFileFormat,"FAT32")) { |
896 enum TFileSystem check = (TFileSystem)0; |
|
897 if(!(CDriveImage::FormatTranslation(iDriveFileFormat,check))) { |
|
898 Print(EError,"The name of the file system not supported : %s\n",iDriveFileFormat); |
890 Print(EError,"The name of the file system not supported : %s\n",iDriveFileFormat); |
899 retVal = EFalse; |
891 retVal = EFalse; |
900 } |
892 } |
901 } |
893 } |
902 if(retVal) |
894 if(retVal) |
948 |
941 |
949 default: |
942 default: |
950 return EFalse; |
943 return EFalse; |
951 } |
944 } |
952 |
945 |
953 if (aKeyword!=EKeywordHide) { |
946 if (aKeyword!=EKeywordHide && aKeyword!=EKeywordDir) { |
954 // check the PC file exists |
947 // check the PC file exists |
955 char* nname = NormaliseFileName(iReader.Word(1)); |
948 char* nname = NormaliseFileName(iReader.Word(1)); |
956 ifstream test(nname); |
949 ifstream test(nname); |
957 if(!test.is_open()){ |
950 if(!test.is_open()){ |
958 Print(EError,"Cannot open file %s for input.\n",iReader.Word(1)); |
951 Print(EError,"Cannot open file %s for input.\n",iReader.Word(1)); |
963 |
956 |
964 } |
957 } |
965 else |
958 else |
966 epocPathStart=1; |
959 epocPathStart=1; |
967 |
960 |
968 iNumberOfFiles++; |
961 if(aKeyword != EKeywordDir) |
|
962 iNumberOfFiles++; |
969 |
963 |
970 TBool endOfName=EFalse; |
964 TBool endOfName=EFalse; |
971 const char *epocStartPtr= IsValidFilePath(iReader.Word(epocPathStart)); |
965 const char *epocStartPtr; |
|
966 if(aKeyword != EKeywordDir) |
|
967 epocStartPtr = IsValidFilePath(iReader.Word(epocPathStart)); |
|
968 else |
|
969 epocStartPtr = IsValidDirPath(iReader.Word(epocPathStart)); |
972 char *epocEndPtr = const_cast<char*>(epocStartPtr); |
970 char *epocEndPtr = const_cast<char*>(epocStartPtr); |
973 |
971 |
974 if (epocStartPtr == NULL) { |
972 if (epocStartPtr == NULL) { |
975 Print(EError, "Invalid destination path on line %d\n",currentLine); |
973 Print(EError, "Invalid destination path on line %d\n",currentLine); |
976 return EFalse; |
974 return EFalse; |
980 TRomNode* subDir=0; |
978 TRomNode* subDir=0; |
981 TRomBuilderEntry *file=0; |
979 TRomBuilderEntry *file=0; |
982 |
980 |
983 while (!endOfName) { |
981 while (!endOfName) { |
984 endOfName = GetNextBitOfFileName(epocEndPtr); |
982 endOfName = GetNextBitOfFileName(epocEndPtr); |
985 if (endOfName) { // file |
983 if (endOfName && (aKeyword!=EKeywordDir)) { // file |
986 TRomNode* alreadyExists=dir->FindInDirectory(epocStartPtr); |
984 TRomNode* alreadyExists=dir->FindInDirectory(epocStartPtr); |
987 if ((aKeyword != EKeywordHide) && alreadyExists) { // duplicate file |
985 if ((aKeyword != EKeywordHide) && alreadyExists) { // duplicate file |
988 if (gKeepGoing) { |
986 if (gKeepGoing) { |
989 Print(EWarning, "Duplicate file for %s on line %d, will be ignored\n",iReader.Word(1),iReader.CurrentLine()); |
987 Print(EWarning, "Duplicate file for %s on line %d, will be ignored\n",iReader.Word(1),iReader.CurrentLine()); |
990 iNumberOfFiles--; |
988 iNumberOfFiles--; |
1032 |
1030 |
1033 dir->AddFile(node); // to drive directory structure. |
1031 dir->AddFile(node); // to drive directory structure. |
1034 } |
1032 } |
1035 else { |
1033 else { |
1036 // directory |
1034 // directory |
|
1035 //for directory creation, given /sys/bin/, it's possible to reach 0 at the end, just ignore that... |
|
1036 if(!*epocStartPtr) |
|
1037 break; |
|
1038 |
1037 subDir = dir->FindInDirectory(epocStartPtr); |
1039 subDir = dir->FindInDirectory(epocStartPtr); |
1038 if (!subDir){ // sub directory does not exist |
1040 if (!subDir){ // sub directory does not exist |
1039 if(aKeyword==EKeywordHide) { |
1041 if(aKeyword==EKeywordHide) { |
1040 Print(EWarning, "Hiding non-existent file %s on line %d\n", |
1042 Print(EWarning, "Hiding non-existent file %s on line %d\n", |
1041 iReader.Word(1),iReader.CurrentLine()); |
1043 iReader.Word(1),iReader.CurrentLine()); |