⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 verifyvd.c

📁 存取UDF格式的DVD光盘的驱动程序
💻 C
📖 第 1 页 / 共 2 页
字号:
      }    }    printf("  (M) Partition starts at sector %d.\n", U_endian32(mPD->uPartStartingLoc));    if (RVDS_Len && (U_endian32(mPD->uPartStartingLoc) != U_endian32(rPD->uPartStartingLoc))) {      printf("**(R) Partition starts at sector %d.\n", U_endian32(rPD->uPartStartingLoc));    }    printf("  (M) Partition length is %d sectors.\n", U_endian32(mPD->uPartLength));    if (RVDS_Len && (U_endian32(mPD->uPartLength) != U_endian32(rPD->uPartLength))) {      printf("**(R) Partition Length is %d sectors.\n", U_endian32(rPD->uPartLength));    }    track_volspace(U_endian32(mPD->uPartStartingLoc), U_endian32(mPD->uPartLength), "A partition");    hit = 0;    for (i = 0; i < PTN_no; i++) {      if (Part_Info[i].Num == U_endian16(mPD->uPartNumber)) {        Part_Info[i].Offs = U_endian32(mPD->uPartStartingLoc);        Part_Info[i].Len = U_endian32(mPD->uPartLength);        hit++;        PHD = (struct PartHeaderDesc *)(mPD->aPartContentsUse);        if (U_endian32(PHD->USB.ExtentLength.Length32)) {          Part_Info[i].Space = U_endian32(PHD->USB.Location);          Part_Info[i].SpLen = U_endian32(PHD->USB.ExtentLength.Length32) & 0x3FFFFFFF;          Part_Info[i].SpMap = malloc(Part_Info[i].SpLen);          Part_Info[i].MyMap = malloc(Part_Info[i].SpLen);          if (Part_Info[i].MyMap) {            memset(Part_Info[i].MyMap, 0xff, Part_Info[i].SpLen);          }        }      }    }    if (hit != 1) {      printf("  (M) partition %d was referenced by %d maps.\n", U_endian16(mPD->uPartNumber),             hit);    }  } else {    Fatal = TRUE;  }  DumpError();  return 0;}/*  * The following routine checks the LVD.  It looks for legal values in most * fields and verifies that the main and reserve LVD are equivalent.  A few * fields are not checked or displayed: *   UINT8 aImplementationUse[128]; */int checkLVD(struct LogVolDesc *mLVD, struct LogVolDesc *rLVD){  int i, offset, error;  struct PartMap1   *sPartMap1;  struct PartMapVAT *sPartMapVAT;  struct PartMapSP  *sPartMapSP;  error = CheckTag((struct tag *)mLVD, U_endian32(mLVD->sTag.uTagLoc), TAGID_LVD, 424, secsize);  DumpError();  if (error < CHECKTAG_OK_LIMIT) {    if (!Is_Charspec(mLVD->sDesCharSet)) {      printf("**(M) Description Character Set is: ");      printCharSpec(mLVD->sDesCharSet);    }    if (RVDS_Len && !Is_Charspec(rLVD->sDesCharSet)) {      printf("**(R) Description Character Set is: ");      printCharSpec(rLVD->sDesCharSet);    }    memcpy(LogVolID, mLVD->uLogVolID, 128);    printf("  (M) Logical Volume ID:     ");    printDstring( mLVD->uLogVolID, 128);    if (RVDS_Len && memcmp(mLVD->uLogVolID, rLVD->uLogVolID, 128)) {      printf("**(R) Logical Volume ID:     ");      printDstring( rLVD->uLogVolID, 128);    }    blocksize = U_endian32(mLVD->uLogBlkSize);    if (blocksize < secsize) {      printf("**(M) Block size of %d is less than sector size of %d!.\n",             blocksize, secsize);      Fatal = TRUE;    } else {      while (!((1 << bdivshift) & blocksize)) {        bdivshift++;      }      s_per_b = blocksize / secsize;    }    if (blocksize != secsize) {      printf("**(M) Block size is %d, sector size is %d.\n", blocksize, secsize);    }    if (RVDS_Len && (U_endian32(rLVD->uLogBlkSize) != blocksize)) {      printf("**(R) Block size is %d.\n", rLVD->uLogBlkSize);    }    if (CheckRegid((struct udfEntityId *)&mLVD->sDomainID, UDF_DOMAIN_ID)) {      printf("**(M) Domain Identifier: ");      DisplayUdfID((struct udfEntityId *)&mLVD->sDomainID);    }    if (RVDS_Len && CheckRegid((struct udfEntityId *)&rLVD->sDomainID, UDF_DOMAIN_ID)) {      printf("**(R) Domain Identifier: ");      DisplayUdfID((struct udfEntityId *)&rLVD->sDomainID);    }    printf("  (M) Impl. ID: ");    DisplayImplID(&mLVD->sImplementationID);    if (RVDS_Len && memcmp(&mLVD->sImplementationID, &rLVD->sImplementationID, sizeof(struct udfEntityId))) {      printf("**(R) Impl. ID: ");      DisplayImplID(&rLVD->sImplementationID);    }    memcpy(&FSD, &mLVD->uLogVolUse, 16);    if (FSD.ExtentLength.bf.Length == 0) {      Fatal = TRUE;      printf("**");    } else {      printf("  ");    }    printf("(M) File Set Descriptor location is ");    printLongAd(&FSD);    if (RVDS_Len && memcmp(&FSD, &rLVD->uLogVolUse, 16)) {      printf("**(R) File Set Descriptor Location is ");      printLongAd((struct long_ad *)&rLVD->uLogVolUse);    }    for (i = 0; i < NUM_PARTS; i++) {      Part_Info[i].type = PTN_TYP_NONE;      Part_Info[i].Num = 0;      Part_Info[i].Offs = 0;      Part_Info[i].Len = 0;      Part_Info[i].Space = -1;      Part_Info[i].Extra = NULL;      Part_Info[i].SpMap = NULL;      Part_Info[i].MyMap = NULL;    }    printf("  (M) There %s %d partition map entr%s.\n", U_endian32(mLVD->uNumPartMaps) == 1 ? "is" : "are",             U_endian32(mLVD->uNumPartMaps), U_endian32(mLVD->uNumPartMaps) == 1 ? "y" : "ies");    if (RVDS_Len && (U_endian32(mLVD->uNumPartMaps) != U_endian32(rLVD->uNumPartMaps))) {      printf("**(R) There %s %d partition map entr%s.\n", U_endian32(rLVD->uNumPartMaps) == 1 ? "is" : "are",              U_endian32(rLVD->uNumPartMaps), U_endian32(rLVD->uNumPartMaps) == 1 ? "y" : "ies");    }    if (U_endian32(mLVD->uNumPartMaps) > NUM_PARTS) {      Error.Code = ERR_TOO_MANY_PARTS;      DumpError();      Fatal = TRUE;    } else {      PTN_no = U_endian32(mLVD->uNumPartMaps);      if (PTN_no == 0) {        printf("**No Partition Map Entries.\n");        Fatal = TRUE;      }      offset = sizeof(struct LogVolDesc);      for (i = 0; i < PTN_no; i++) {        printf("  (M) Partition map entry %d is ", i);        sPartMap1 = (struct PartMap1 *)((UINT8 *)mLVD + offset);        sPartMapVAT = (struct PartMapVAT *)sPartMap1;        sPartMapSP = (struct PartMapSP *)sPartMap1;        switch(sPartMap1->uPartMapType) {          case 1:              Part_Info[i].type = PTN_TYP_REAL;              Part_Info[i].Num  = U_endian16(sPartMap1->uPartNum);              printf("type 1 (real) and references partition %d.\n", Part_Info[i].Num);            break;          case 2:              if (!strncmp(E_REGID_CD_VP, sPartMapVAT->sVATIdentifier.aID, strlen(E_REGID_CD_VP))) {                Part_Info[i].type = PTN_TYP_VIRTUAL;                Part_Info[i].Num  = U_endian16(sPartMapVAT->uPartNum);                printf("type 2 (virtual) and references partition %d.\n", Part_Info[i].Num);              } else if (!strncmp(E_REGID_CD_SP, sPartMapVAT->sVATIdentifier.aID, strlen(E_REGID_CD_SP))) {                Part_Info[i].type = PTN_TYP_SPARE;                Part_Info[i].Num  = U_endian16(sPartMapSP->uPartNum);                printf("type 2 (sparable) and references partition %d.\n", Part_Info[i].Num);                Part_Info[i].Extra = malloc(sizeof(struct _sST_desc));                if ((struct _sST_desc *)Part_Info[i].Extra) {                  printf("  (M) %d sparing map(s), %d bytes long, mapping %d sectors each.\n",                          sPartMapSP->N_ST, U_endian32(sPartMapSP->SpareSize), U_endian16(sPartMapSP->uPacketLength));                  ((struct _sST_desc *)Part_Info[i].Extra)->Size = U_endian32(sPartMapSP->SpareSize);                  ((struct _sST_desc *)Part_Info[i].Extra)->Count = sPartMapSP->N_ST;                  ((struct _sST_desc *)Part_Info[i].Extra)->Extent = U_endian16(sPartMapSP->uPacketLength);                  ((struct _sST_desc *)Part_Info[i].Extra)->Location[0] = U_endian32(sPartMapSP->SpareLoc[0]);                  ((struct _sST_desc *)Part_Info[i].Extra)->Location[1] = U_endian32(sPartMapSP->SpareLoc[1]);                  ((struct _sST_desc *)Part_Info[i].Extra)->Location[2] = U_endian32(sPartMapSP->SpareLoc[2]);                  ((struct _sST_desc *)Part_Info[i].Extra)->Location[3] = U_endian32(sPartMapSP->SpareLoc[3]);                }              } else {                Part_Info[i].type = PTN_TYP_NONE;                printf("type 2 (unknown).\n");              }            break;          default:              Part_Info[i].type = PTN_TYP_NONE;              printf("illegal type (%d).\n", sPartMap1->uPartMapType);        }        offset += sPartMap1->uPartMapLen;      }    }    offset -= sizeof(struct LogVolDesc);    if (offset != U_endian32(mLVD->uMapTabLen)) {      printf("**(M) Found %d bytes of map entries, LVD claims %d.\n", offset,             U_endian32(mLVD->uMapTabLen));    }    if (RVDS_Len && (offset != U_endian32(rLVD->uMapTabLen))) {      printf("**(R) Found %d bytes of map entries, LVD claims %d.\n", offset,             U_endian32(rLVD->uMapTabLen));    }    printf("  (M) Integrity Sequence is %d bytes at %d.\n",            U_endian32(mLVD->integritySeqExtent.Length), U_endian32(mLVD->integritySeqExtent.Location));    if (RVDS_Len && memcmp(&mLVD->integritySeqExtent, &rLVD->integritySeqExtent,                sizeof(struct extent_ad))) {      printf("**(R) Integrity Sequence is %d bytes at %d.\n",              U_endian32(rLVD->integritySeqExtent.Length), U_endian32(rLVD->integritySeqExtent.Location));    }    track_volspace(U_endian32(mLVD->integritySeqExtent.Location), U_endian32(mLVD->integritySeqExtent.Length) >> sdivshift,                    "Integrity Sequence");    verifyLVID(U_endian32(mLVD->integritySeqExtent.Location), U_endian32(mLVD->integritySeqExtent.Length));  } else {    Fatal = TRUE;  }  DumpError();  return Error.Code;}/*  * The following routine checks the USD.  It looks for legal values in most * fields and verifies that the main and reserve USD are equivalent.   */int checkUSD(struct UnallocSpDesHead *mUSD, struct UnallocSpDesHead *rUSD){  int i, error;  error = CheckTag((struct tag *)mUSD, U_endian32(mUSD->sTag.uTagLoc), TAGID_USD, 8, secsize);  DumpError();  if (error < CHECKTAG_OK_LIMIT) {    printf("  (M) Number of Allocation Descriptors: %d\n", U_endian32(mUSD->uNumAllocationDes));    if (RVDS_Len && (U_endian32(mUSD->uNumAllocationDes) != U_endian32(rUSD->uNumAllocationDes))) {      printf("**(R) Number of Allocation Descriptors: %d\n", U_endian32(rUSD->uNumAllocationDes));    }    if (U_endian32(mUSD->uNumAllocationDes) > 0) {      printf("  (M) Space allocation descriptors:\n");    }    for (i = 0; i < U_endian32(mUSD->uNumAllocationDes); i++) {      printf("    %d bytes (%d blocks) @ %d\n",               U_endian32(*((UINT32 *) ((UINT8 *)mUSD + sizeof(struct UnallocSpDesHead) + i * sizeof(struct extent_ad)))),               U_endian32(*((UINT32 *) ((UINT8 *)mUSD + sizeof(struct UnallocSpDesHead) + i * sizeof(struct extent_ad)))) >> sdivshift,               U_endian32(*((UINT32 *) ((UINT8 *)mUSD + sizeof(struct UnallocSpDesHead) + i * sizeof(struct extent_ad)) + 1)));      track_volspace(U_endian32(*((UINT32 *)((UINT8 *)mUSD + sizeof(struct UnallocSpDesHead) + i * sizeof(struct extent_ad)) + 1)),                     U_endian32(*((UINT32 *)((UINT8 *)mUSD + sizeof(struct UnallocSpDesHead) + i * sizeof(struct extent_ad)))) >> sdivshift,                     "Unallocated Space");    }    if (RVDS_Len && (memcmp((UINT8 *)mUSD + sizeof(struct UnallocSpDesHead),                (UINT8 *)rUSD + sizeof(struct UnallocSpDesHead),                U_endian32(mUSD->uNumAllocationDes) * sizeof(struct extent_ad)) ||                (U_endian32(mUSD->uNumAllocationDes) != U_endian32(rUSD->uNumAllocationDes)))) {      printf("**(R) Space allocation descriptors:\n");      for (i = 0; i < U_endian32(rUSD->uNumAllocationDes); i++) {        printf("    %d bytes (%d blocks) @ %d\n",                U_endian32(*((UINT32 *) ((UINT8 *)rUSD + sizeof(struct UnallocSpDesHead) + i * sizeof(struct extent_ad)))),               U_endian32(*((UINT32 *) ((UINT8 *)rUSD + sizeof(struct UnallocSpDesHead) + i * sizeof(struct extent_ad)))) >> sdivshift,               U_endian32(*((UINT32 *) ((UINT8 *)rUSD + sizeof(struct UnallocSpDesHead) + i * sizeof(struct extent_ad)) + 1)));      track_volspace(*((UINT32 *)((UINT8 *)rUSD + sizeof(struct UnallocSpDesHead) + i * sizeof(struct extent_ad)) + 1),                     *((UINT32 *)((UINT8 *)rUSD + sizeof(struct UnallocSpDesHead) + i * sizeof(struct extent_ad))) >> sdivshift,                     "Unallocated Space from Reserve USD");      }    }  }  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -