/* * adfVolumeInfo * */ void adfVolumeInfo(struct Volume *vol) { struct bRootBlock root; char diskName[35]; int days,month,year; if (adfReadRootBlock(vol, vol->rootBlock, &root)!=RC_OK) return; memset(diskName, 0, 35); memcpy(diskName, root.diskName, root.nameLen); printf ("Name : %-30s\n",vol->volName); printf ("Type : "); switch(vol->dev->devType) { case DEVTYPE_FLOPDD: printf ("Floppy Double Density : 880 KBytes\n"); break; case DEVTYPE_FLOPHD: printf ("Floppy High Density : 1760 KBytes\n"); break; case DEVTYPE_HARDDISK: printf ("Hard Disk partition : %3.1f KBytes\n", (vol->lastBlock - vol->firstBlock +1) * 512.0/1024.0); break; case DEVTYPE_HARDFILE: printf ("HardFile : %3.1f KBytes\n", (vol->lastBlock - vol->firstBlock +1) * 512.0/1024.0); break; default: printf ("Unknown devType!\n"); } printf ("Filesystem : "); printf("%s ",isFFS(vol->dosType) ? "FFS" : "OFS"); if (isINTL(vol->dosType)) printf ("INTL "); if (isDIRCACHE(vol->dosType)) printf ("DIRCACHE "); putchar('\n'); printf("Free blocks = %d\n", adfCountFreeBlocks(vol)); if (vol->readOnly) printf("Read only\n"); else printf("Read/Write\n"); /* created */ adfDays2Date(root.coDays, &year, &month, &days); printf ("created %d/%02d/%02d %d:%02d:%02d\n",days,month,year, root.coMins/60,root.coMins%60,root.coTicks/50); adfDays2Date(root.days, &year, &month, &days); printf ("last access %d/%02d/%02d %d:%02d:%02d, ",days,month,year, root.mins/60,root.mins%60,root.ticks/50); adfDays2Date(root.cDays, &year, &month, &days); printf ("%d/%02d/%02d %d:%02d:%02d\n",days,month,year, root.cMins/60,root.cMins%60,root.cTicks/50); }
/*! \brief Mount a volume. * \param dev - The device containing the volume to mount. * \param nPart - The volume number to mount. * \param readOnly - TRUE if read only access is desired, FALSE otherwise. * \return The Volume, NULL in case of error. * * Mounts a designated volume (nPart) of the Device (dev), with specified read/write access (readOnly). * The first partition is #0. The current working directory is the root block. * * \b Internals \n * 1. Read the bootblock to determine vol->dosType and vol->datablockSize. \n * 2. Read the rootblock, fills vol->curDirPtr. \n * 3. Read and allocate the bitmap : vol->bitmapBlocks[], vol->bitmapTable[], vol->bitmapSize, vol->bitmapBlocksChg[]. \n */ struct Volume* adfMount( struct Device *dev, int nPart, BOOL readOnly ) { long nBlock; struct bRootBlock root; struct bBootBlock boot; struct Volume* vol; if (dev==NULL || nPart<nPart || nPart >= dev->nVol) { (*adfEnv.eFct)("adfMount : invalid parameter(s)"); return NULL; } vol = dev->volList[nPart]; vol->dev = dev; vol->mounted = TRUE; #ifdef _DEBUG_PRINTF_ printf("first=%ld last=%ld root=%ld\n",vol->firstBlock, vol->lastBlock, vol->rootBlock); #endif /*_DEBUG_PRINTF_*/ if (adfReadBootBlock(vol, &boot)!=RC_OK) { (*adfEnv.wFct)("adfMount : BootBlock invalid"); return NULL; } vol->dosType = boot.dosType[3]; if (isFFS(vol->dosType)) vol->datablockSize=512; else vol->datablockSize=488; if (dev->readOnly /*|| isDIRCACHE(vol->dosType)*/) vol->readOnly = TRUE; else vol->readOnly = readOnly; if (adfReadRootBlock(vol, vol->rootBlock, &root)!=RC_OK) { (*adfEnv.wFct)("adfMount : RootBlock invalid"); return NULL; } nBlock = vol->lastBlock - vol->firstBlock +1 - 2; adfReadBitmap( vol, nBlock, &root ); vol->curDirPtr = vol->rootBlock; #ifdef _DEBUG_PRINTF_ printf("blockSize=%d\n",vol->blockSize); #endif /*_DEBUG_PRINTF_*/ return( vol ); }
BOOL VolPropPage::OnInitDialog() { CPropertyPage::OnInitDialog(); WinADFDoc *pDoc = (WinADFDoc*)MDIGetActiveDoc(); ASSERT_VALID(pDoc); ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(WinADFDoc))); Volume *pVol = pDoc->GetVolume(); GetDlgItem(IDC_VOLNAME)->SetWindowText(pVol->getName().c_str()); int8_t type = pVol->getType(); CButton *pButton = (CButton*)GetDlgItem(IDC_FFS); pButton->SetCheck(isFFS(type)); pButton = (CButton*)GetDlgItem(IDC_INTL); pButton->SetCheck(isINTL(type)); pButton = (CButton*)GetDlgItem(IDC_DIRCACHE); pButton->SetCheck(isDIRCACHE(type)); uint32_t totalblocks = (pVol->getLastBlock()+1) - pVol->getFirstBlock(); uint32_t totalcap = totalblocks * BSIZE; CString fmt; fmt.Format("%s KB", comma(totalcap / 1024).c_str()); GetDlgItem(IDC_VOL_TOTAL)->SetWindowText(fmt); uint32_t freeblocks = pVol->freeblocks(); uint32_t freecap = freeblocks * BSIZE; fmt.Format("%s KB", comma(freecap / 1024).c_str()); GetDlgItem(IDC_VOL_FREE)->SetWindowText(fmt); uint32_t full = totalblocks - freeblocks; m_FullProgress.SetRange32(0, totalblocks); m_FullProgress.SetPos(full); m_FullProgress.SendMessage(PBM_SETBARCOLOR, 0, COLOR_PURPLE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void printVol(struct Volume* vol, int volNum) { printf("Volume : "); switch(vol->dev->devType) { case DEVTYPE_FLOPDD: printf ("Floppy 880 KBytes,"); break; case DEVTYPE_FLOPHD: printf ("Floppy 1760 KBytes,"); break; case DEVTYPE_HARDDISK: printf ("HD partition #%d %3.1f KBytes,", volNum, (vol->lastBlock - vol->firstBlock +1) * 512.0/1024.0); break; case DEVTYPE_HARDFILE: printf ("HardFile %3.1f KBytes,", (vol->lastBlock - vol->firstBlock +1) * 512.0/1024.0); break; default: printf ("???,"); } if (vol->volName!=NULL) printf(" \"%s\"", vol->volName); printf(" between sectors [%ld-%ld].",vol->firstBlock, vol->lastBlock); printf(" %s ",isFFS(vol->dosType) ? "FFS" : "OFS"); if (isINTL(vol->dosType)) printf ("INTL "); if (isDIRCACHE(vol->dosType)) printf ("DIRCACHE "); printf(". Filled at %2.1f%%.\n", 100.0- (adfCountFreeBlocks(vol)*100.0)/(vol->lastBlock - vol->firstBlock +1) ); }