home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Vol.c
-
- Contains: A dcmd which dumps all volumes from the VCB queue.
-
- Written by: JM3 = Jim Murphy
- DAL = Dave Lyons
- sad = Scott Douglas
-
- Copyright: ⌐ 1988,1993-1994, 1996, 1998 by Apple Computer, Inc., all rights reserved.
-
- File Ownership:
-
- DRI: Jim Murphy
-
- Other Contact: Dave Lyons
-
- Technology: MacsBug 6.5.x
-
- Writers:
-
- (DAL) Dave Lyons
- (sjb) Steve Bollinger
-
- Change History (most recent first):
-
- <8> 1/6/98 DAL Updated version number to 3.0.1.
- <7> 1/5/98 sjb Fix checks for locked volumes (hardware & software)
- <6> 25-Jan-96 JM3 Updated the sample build commands to be current. Took out lowmem
- define and included LowMem.h.
- <5> 11-Dec-94 JM3 Updated for new version 3 dcmd requirements.
- <4> 24-Jan-94 JM3 EqualString is now in TextUtils.h with the Universal Interfaces.
- <2> 9/10/93 DAL Fixed volume-name matching to work again (was using
- non-prototyped "EQUALSTRING" instead of EqualString). Widened
- the volume-name column. Changed "VCB at" to "VCB addr" and made
- it align for 32-bit addresses.
-
- Modification history:
- 29Nov88 sad revised for new dcmd names. display more info.
- 5Oct88 sad written.
-
- The following MPW commands will build the dcmd and copy it to the "Debugger Prefs" file
- in the System folder. The dcmd's name in MacsBug will be the name of the file built by
- the Linker.
-
- C Vol.c
- Link -o Vol -sg Main=STDCLIB,STDIO,SANELIB dcmdGlue.a.o Put.c.o Vol.c.o" ╢
- "{Libraries}Runtime.o" "{Libraries}Interface.o"
- BuildDcmd Vol 198 -format3
- Echo 'include "Vol";' | Rez -a -o "{systemFolder}Debugger Prefs"
-
- */
-
- #include <Types.h>
- #include <Memory.h>
- #include <OSUtils.h>
- #include <Files.h>
- #include <TextUtils.h>
- #include <LowMem.h>
-
- #include "dcmd.h"
- #include "put.h"
-
- static void DrawHdr()
- {
- // 1 2 3 4 5 6 7
- // 1234567890123456789012345678901234567890123456789012345678901234567890123456789
- dcmdDrawLine("\pvRef Vol Flg dRef Drive FSID #Blk BlkSiz #Files #Dirs Blsd Dir VCB addr");
-
- }
-
-
- static void DrawVCB(VCB* vcbp)
- {
-
- PutUHexWord(vcbp->vcbVRefNum);
- PutSpace();
- PutPStrTruncTo(vcbp->vcbVN,15+10);
- PutSpace();
- PutChar((vcbp->vcbFlags & 0x8000) ? 'D' : 'd');
- PutChar((vcbp->vcbAtrb & 0x0080) ? 'S' : 's');
- PutChar((vcbp->vcbAtrb & 0x0040) ? 'H' : 'h');
- PutSpace();
- PutUHexWord(vcbp->vcbDRefNum);
- PutSpace();
- PutSpace();
- PutUHexWord(vcbp->vcbDrvNum);
- PutSpace();
- PutUHexWord(vcbp->vcbFSID);
- PutSpace();
- PutUHexWord(vcbp->vcbNmAlBlks);
- PutSpace();
- PutUHexZTo(vcbp->vcbAlBlkSiz,6,47+10);
- PutSpace();
- PutUHexZTo(vcbp->vcbFilCnt,6,54+10);
- PutSpace();
- PutUHexZTo(vcbp->vcbDirCnt,6,61+10);
- PutSpace();
- PutUHexZTo(vcbp->vcbFndrInfo[0],6,70+10);
- PutSpace();
- PutUHexZTo((unsigned long)vcbp,8,77+10);
- PutLine();
-
- }
-
-
- // PrefixPStr
- //
- // Returns true if astr is equal to a prefix of bstr.
- // astr must not be longer than 31 characters.
-
- static Boolean PrefixPStr(const Str255 astr, const Str255 bstr)
- {
-
- char newstr[32];
- int alen = *astr;
- int blen = *bstr;
-
- if (alen <= blen)
- {
- BlockMove(bstr+1,newstr+1,alen);
- newstr[0] = alen;
- return EqualString(astr,newstr,false,true);
- }
-
- return false;
-
- }
-
-
-
- pascal void CommandEntry(dcmdBlock* paramPtr)
- {
-
- static const char usageStr[] = "\p[vRefNum|drvNum|\"vol name\"]";
-
- switch (paramPtr->request)
- {
- case dcmdInit:
- break;
-
- case dcmdHelp:
- dcmdDrawLine("\pDisplays volume information for the given vrefnum, volume name or all");
- dcmdDrawLine("\pmounted volumes. Flags are D/d=Dirty, S/s=Software locked,");
- dcmdDrawLine("\pH/h=Hardware locked.");
- break;
-
- case dcmdGetInfo:
- * (long *) &((GetInfoRequestBlockPtr) paramPtr->requestIOBlock)->dcmdVersion = 0x03018000; // version 3.0.1 final
- BlockMoveData(&usageStr, &((GetInfoRequestBlockPtr) paramPtr->requestIOBlock)->usageStr, usageStr[0]+1);
- break;
-
- case dcmdDoIt:
- {
- Boolean doOneVCB = false;
- long vref;
- short c;
- Boolean haveVolName = false;
- Str255 volname;
- VCB* vcbp;
- int numvcbs = 0;
- Boolean foundOne = false;
-
- dcmdSwapWorlds();
-
- dcmdDrawLine("\pDisplaying Volume Control Blocks");
-
- // get low-memory values after dcmdSwapWorlds()
- vcbp = (VCB*) (LMGetVCBQHdr()->qHead);
-
- c = dcmdPeekAtNextChar();
- if (c == '"' || c == '\'')
- {
- haveVolName = true;
- (void) dcmdGetNextParameter(volname);
- }
- else
- {
- (void) dcmdGetNextExpression(&vref, &doOneVCB);
- }
-
- if (doOneVCB)
- vref = (short) vref;
-
- while (vcbp)
- {
- if ((doOneVCB && (vcbp->vcbVRefNum == vref || vcbp->vcbDrvNum == vref)) ||
- (haveVolName && PrefixPStr(volname,vcbp->vcbVN)) ||
- (!doOneVCB && !haveVolName))
- {
- numvcbs++;
- if (!foundOne)
- {
- DrawHdr();
- foundOne = true;
- }
- DrawVCB(vcbp);
- }
- if (paramPtr->aborted)
- break;
- if (vcbp->qLink == 0)
- if (vcbp != (VCB*)(LMGetVCBQHdr()->qTail))
- dcmdDrawLine("\pVCB queue does not end at VCBQHdr.qTail");
- vcbp = (VCB*)vcbp->qLink;
- }
-
- if (!paramPtr->aborted)
- {
- if (haveVolName || doOneVCB)
- {
- if (!foundOne)
- if (haveVolName)
- {
- PutPStr("\pNo mounted volumes match \"");
- PutPStr(volname);
- PutChar('"');
- PutLine();
- }
- else
- {
- PutPStr("\pNo mounted volumes match ");
- PutUHexWord(vref);
- PutLine();
- }
- }
- else
- {
- PutUDec(numvcbs);
- PutPStr("\p VCBs");
- PutLine();
- }
- }
-
- dcmdSwapWorlds();
- break;
- }
-
- // Version 3 and newer dcmds must quietly ignore requests we don't recognize.
-
- default:
- break;
- }
-
- } // CommandEntry
-