📄 verifyvd.c
字号:
#include "../nsrHdrs/nsr.h"#include <stdlib.h>#include <stdio.h>#include <string.h>#include <ctype.h>#include "chkudf.h"#include "protos.h"/* * This set of functions is used to verify individual volume structures. * In addition, appropriate information is pulled off and stored in global * variables. The fields that are not checked or displayed should be, I * just haven't implemented it. The code is pretty simple but tedious. * Each interesting (to me) field of the Main descriptor is displayed, * and if a difference is found between the Main and Reserve sequences, * the Reserve field is also displayed. * * If the reserve sequence doesn't exist, no errors are generated here * because it is flagged earlier and would make a messy display. *//* * The following routine checks the PVD. It looks for legal values in most * fields and verifies that the main and reserve PVD are equivalent. A few * fields are not checked or displayed: * UINT8 aImplementationUse[64]; * UINT32 uPredecessorVDSLoc; * UINT16 uFlags; * UINT8 aReserved[22]; */int checkPVD(struct PrimaryVolDes *mPVD, struct PrimaryVolDes *rPVD){ int error; error = CheckTag((struct tag *)mPVD, U_endian32(mPVD->sTag.uTagLoc), TAGID_PVD, 496, 496); DumpError(); if (error < CHECKTAG_OK_LIMIT) { printf(" (M) Volume Identifier: "); printDstring( mPVD->aVolID, 32); if (RVDS_Len && memcmp(mPVD->aVolID, rPVD->aVolID, 32)) { printf("**(R) Volume Identifier: "); printDstring(rPVD->aVolID, 32); } printf(" (M) Volume Set ID: "); printDstring( mPVD->aVolSetID, 128); if (RVDS_Len && memcmp(mPVD->aVolSetID, rPVD->aVolSetID, 128)) { printf("**(R) Volume Set ID: "); printDstring( rPVD->aVolSetID, 128); } printf(" (M) Recording Time: "); printTimestamp( mPVD->sRecordingTime); if (RVDS_Len && memcmp(&mPVD->sRecordingTime, &rPVD->sRecordingTime, sizeof(struct timestamp))) { printf(" (R) Recording Time: "); printTimestamp( rPVD->sRecordingTime); } printf(" (M) Primary Volume Descriptor number is %u.\n", U_endian32(mPVD->uPrimVolDesNum)); if (RVDS_Len && (U_endian32(mPVD->uPrimVolDesNum) != U_endian32(rPVD->uPrimVolDesNum))) { printf(" (R) Primary Volume Descriptor number is %u.\n", U_endian32(rPVD->uPrimVolDesNum)); } if ((U_endian16(mPVD->uVSN) != 1) || (U_endian16(mPVD->uMaxVSN) != 1) || (RVDS_Len && ((U_endian16(rPVD->uVSN) != 1) || (U_endian16(rPVD->uMaxVSN) != 1)))) { printf("%s(M) Volume %u of %u.\n", U_endian16(mPVD->uVSN) > U_endian16(mPVD->uMaxVSN) ? "**" : " ", U_endian16(mPVD->uVSN), U_endian16(mPVD->uMaxVSN)); if ((U_endian16(mPVD->uVSN) != U_endian16(rPVD->uVSN)) || U_endian16((mPVD->uMaxVSN) != U_endian16(rPVD->uMaxVSN))) { printf("**(R) Volume %u of %u.\n", U_endian16(rPVD->uVSN), U_endian16(rPVD->uMaxVSN)); } } if ((U_endian16(mPVD->uInterchangeLev) != 2) || (RVDS_Len && (U_endian16(rPVD->uInterchangeLev) != 2))) { printf(" (M) Interchange level is %u.\n", U_endian16(mPVD->uInterchangeLev)); if (RVDS_Len && (U_endian16(mPVD->uInterchangeLev) != U_endian16(rPVD->uInterchangeLev))) { printf("**(R) Interchange level is %u.\n", U_endian16(rPVD->uInterchangeLev)); } } if ((U_endian16(mPVD->uMaxInterchangeLev) != 3) || (RVDS_Len && (U_endian16(rPVD->uMaxInterchangeLev) != 3))) { printf("**(M) Max. Interchange level is %u.\n", U_endian16(mPVD->uMaxInterchangeLev)); if (RVDS_Len && (U_endian16(mPVD->uMaxInterchangeLev) != U_endian16(rPVD->uMaxInterchangeLev))) { printf("**(R) Max. Interchange level is %u.\n", U_endian16(rPVD->uMaxInterchangeLev)); } } if ((U_endian32(mPVD->uCharSetList) != 1) || (RVDS_Len && (U_endian32(rPVD->uCharSetList) != 1))) { printf("**(M) Character set list is 0x%08x.\n", U_endian32(mPVD->uCharSetList)); if (RVDS_Len && (U_endian32(mPVD->uCharSetList) != U_endian32(rPVD->uCharSetList))) { printf("**(R) Character set list is 0x%08x.\n", U_endian32(rPVD->uCharSetList)); } } if ((U_endian32(mPVD->uMaxCharSetList) != 1) || (RVDS_Len && (U_endian32(rPVD->uMaxCharSetList) != 1))) { printf("**(M) Max. Character set list is 0x%08x.\n", U_endian32(mPVD->uMaxCharSetList)); if (RVDS_Len && (U_endian32(mPVD->uMaxCharSetList) != U_endian32(rPVD->uMaxCharSetList))) { printf("**(R) Max. Character set list is 0x%08x.\n", U_endian32(rPVD->uMaxCharSetList)); } } if (!Is_Charspec(mPVD->sDesCharSet)) { printf("**(M) Description Character Set is: "); printCharSpec(mPVD->sDesCharSet); } if (RVDS_Len && !Is_Charspec(rPVD->sDesCharSet)) { printf("**(R) Description Character Set is: "); printCharSpec(rPVD->sDesCharSet); } if (!Is_Charspec(mPVD->sExplanatoryCharSet)) { printf("**(M) Description Character Set is: "); printCharSpec(mPVD->sExplanatoryCharSet); } if (RVDS_Len && !Is_Charspec(rPVD->sExplanatoryCharSet)) { printf("**(R) Description Character Set is: "); printCharSpec(rPVD->sExplanatoryCharSet); } if (RVDS_Len && memcmp(&mPVD->sVolAbstract, &rPVD->sVolAbstract, sizeof(struct extent_ad))) { printf("**(M) Volume Abstract location: "); printExtentAD(mPVD->sVolAbstract); printf("**(R) Volume Abstract location: "); printExtentAD(rPVD->sVolAbstract); } if (RVDS_Len && memcmp(&mPVD->sVolCopyrightNotice, &rPVD->sVolCopyrightNotice, sizeof(struct extent_ad))) { printf("**(M) Volume Abstract location: "); printExtentAD(mPVD->sVolCopyrightNotice); printf("**(R) Volume Abstract location: "); printExtentAD(rPVD->sVolCopyrightNotice); } printf(" (M) App. ID: "); DisplayImplID((struct implEntityId *)&mPVD->sApplicationID); if (RVDS_Len && memcmp(&mPVD->sApplicationID, &rPVD->sApplicationID, sizeof(struct udfEntityId))) { printf("**(R) App. ID: "); DisplayImplID((struct implEntityId *)&rPVD->sApplicationID); } printf(" (M) Impl. ID: "); DisplayImplID(&mPVD->sImplementationID); if (RVDS_Len && memcmp(&mPVD->sImplementationID, &rPVD->sImplementationID, sizeof(struct udfEntityId))) { printf("**(R) Impl. ID: "); DisplayImplID(&rPVD->sImplementationID); } } return Error.Code;}/* * The following routine checks the IUVD. It looks for legal values in most * fields and verifies that the main and reserve IUVD are equivalent. A few * fields are not checked or displayed: * UINT8 aImplementationUse[128]; */int checkIUVD(struct ImpUseDesc *mIUVD, struct ImpUseDesc *rIUVD){ int error; struct LVInformation *mLVI, *rLVI; error = CheckTag((struct tag *)mIUVD, U_endian32(mIUVD->sTag.uTagLoc), TAGID_IUD, 0, secsize); DumpError(); if (error < CHECKTAG_OK_LIMIT) { printf("%s(M) Impl. ID: ", CheckRegid(&mIUVD->sImplementationIdentifier, E_REGID_IUVD) ? "**" : " "); DisplayUdfID(&mIUVD->sImplementationIdentifier); if (RVDS_Len && CheckRegid(&rIUVD->sImplementationIdentifier, E_REGID_IUVD)) { printf("**(R) Impl. ID: "); DisplayUdfID(&rIUVD->sImplementationIdentifier); } mLVI = (struct LVInformation *)&(mIUVD->aReserved[0]); rLVI = (struct LVInformation *)&(rIUVD->aReserved[0]); if (!Is_Charspec(mLVI->sLVICharset)) { printf("**(M) Description Character Set is: "); printCharSpec(mLVI->sLVICharset); } if (RVDS_Len && !Is_Charspec(rLVI->sLVICharset)) { printf("**(R) Description Character Set is: "); printCharSpec(rLVI->sLVICharset); } if (memcmp(LogVolID, mLVI->aLogicalVolumeIdentifier, 128)) { printf("**(M) Logical Volume Identifier doesn't match LVD\n"); } printf(" (M) Logical Volume Identifier: "); printDstring(mLVI->aLogicalVolumeIdentifier, 128); if (RVDS_Len && memcmp(mLVI->aLogicalVolumeIdentifier, rLVI->aLogicalVolumeIdentifier, 128)) { printf("**(R) Logical Volume Identifier: "); printDstring(rLVI->aLogicalVolumeIdentifier, 128); } printf(" (M) Logical Volume Info 1: "); printDstring(mLVI->aLVInfo1, 36); if (RVDS_Len && memcmp(mLVI->aLVInfo1, rLVI->aLVInfo1, 36)) { printf("**(R) Logical Volume Info 1: "); printDstring(rLVI->aLVInfo1, 36); } printf(" (M) Logical Volume Info 2: "); printDstring(mLVI->aLVInfo2, 36); if (RVDS_Len && memcmp(mLVI->aLVInfo2, rLVI->aLVInfo2, 36)) { printf("**(R) Logical Volume Info 2: "); printDstring(rLVI->aLVInfo2, 36); } printf(" (M) Logical Volume Info 3: "); printDstring(mLVI->aLVInfo3, 36); if (RVDS_Len && memcmp(mLVI->aLVInfo3, rLVI->aLVInfo3, 36)) { printf("**(R) Logical Volume Info 3: "); printDstring(rLVI->aLVInfo3, 36); } printf(" (M) Impl. ID: "); DisplayImplID(&mLVI->sImplementationID); if (RVDS_Len && memcmp(&mLVI->sImplementationID, &rLVI->sImplementationID, sizeof(struct udfEntityId))) { printf("**(R) Impl. ID: "); DisplayImplID(&rLVI->sImplementationID); } } return 0;}/* * The following routine checks the PD. It looks for legal values in most * fields and verifies that the main and reserve PD are equivalent. A few * fields are not checked or displayed: * UINT8 aPartContentsUse[128]; * UINT8 aImplementationUse[128]; * UINT8 aReserved[156]; */int checkPD(struct PartDesc *mPD, struct PartDesc *rPD){ int hit, i, error; struct PartHeaderDesc *PHD; error = CheckTag((struct tag *)mPD, U_endian32(mPD->sTag.uTagLoc), TAGID_PD, 496, 496); DumpError(); if (error < CHECKTAG_OK_LIMIT) { printf(" (M) Partition number %d.\n", U_endian16(mPD->uPartNumber)); if (RVDS_Len && (U_endian16(mPD->uPartNumber) != U_endian16(rPD->uPartNumber))) { printf("**(R) Partition number %d.\n", U_endian16(rPD->uPartNumber)); } printf(" (M) Partition flags: %04x (Space %sAllocated)\n", U_endian16(mPD->uPartFlags), U_endian16(mPD->uPartFlags) & PARTITION_ALLOCATED ? "" : "NOT "); if (RVDS_Len && (U_endian16(mPD->uPartFlags) != U_endian16(rPD->uPartFlags))) { printf(" (R) Partition flags: %04x (Space %sAllocated)\n", U_endian16(rPD->uPartFlags), U_endian16(rPD->uPartFlags) & PARTITION_ALLOCATED ? "" : "NOT "); } if (memcmp((UINT8 *)&mPD->sPartContents +1, E_REGID_NSR, 5)) { printf("**(M) Illegal partition contents identifier\n "); DisplayRegIDID(&mPD->sPartContents); printf("\n"); } if (*((UINT8 *)(&mPD->sPartContents) + 6) - '0' != UDF_Version) { printf("**(M) NSR version is %d, partition claims %d. Changing.\n", UDF_Version, *((UINT8 *)(&mPD->sPartContents) + 6) - '0'); UDF_Version = *((UINT8 *)(&mPD->sPartContents) + 6) - '0'; Version_OK = TRUE; } if (RVDS_Len && memcmp((UINT8 *)&mPD->sPartContents, (UINT8 *)&rPD->sPartContents, sizeof(struct regid))) { printf("**(R) Reserve sequence partition contents identifier\n "); DisplayRegIDID(&rPD->sPartContents); printf("\n"); } printf(" (M) Impl. ID: "); DisplayImplID(&mPD->sImplementationID); if (RVDS_Len && memcmp(&mPD->sImplementationID, &rPD->sImplementationID, sizeof(struct udfEntityId))) { printf("**(R) Impl. ID: "); DisplayImplID(&rPD->sImplementationID); } switch (U_endian32(mPD->uAccessType)) { case ACCESS_UNSPECIFIED: printf(" (M) Access Type Unspecified.\n"); break; case ACCESS_READ_ONLY: printf(" (M) Access Type Read Only.\n"); break; case ACCESS_WORM: printf(" (M) Access Type Write Once.\n"); break; case ACCESS_REWRITABLE: printf(" (M) Access Type Rewritable.\n"); break; case ACCESS_OVERWRITABLE: printf(" (M) Access Type Overwritable.\n"); break; default: printf("**(M) Access Type Non-Standard.\n"); break; } if (RVDS_Len && (U_endian32(mPD->uAccessType) != U_endian32(rPD->uAccessType))) { switch (U_endian32(rPD->uAccessType)) { case ACCESS_UNSPECIFIED: printf("**(R) Access Type Unspecified.\n"); break; case ACCESS_READ_ONLY: printf("**(R) Access Type Read Only.\n"); break; case ACCESS_WORM: printf("**(R) Access Type Write Once.\n"); break; case ACCESS_REWRITABLE: printf("**(R) Access Type Rewritable.\n"); break; case ACCESS_OVERWRITABLE: printf("**(R) Access Type Overwritable.\n"); break; default: printf("**(R) Access Type Non-Standard.\n"); break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -