Ralpè W® Mathisen Dept. of History Univ. of S. Carolina Columbia, S.C.29208 INSIDE THE CP/M DIRECTORY Iî thå October/Novembeò 198µ issuå oæ MOR“ É � discusseä á methoä oæ modifyinç thå dDaså IÉ directorù � iî ordeò tï retrievå datá whicè otherwiså woulä bå � lost® Á similaò methoä alsï caî bå useä foò thå CP/Í � directory¬ whicè ió founä oî everù disë whicè haó CP/Í � fileó oæ anù kinä oî it® Althougè CP/Í useró arå � usuallù unawarå oæ thå functioninç oæ thå directory¬ � itó importancå cannoô bå overemphasized® Onlù bù meanó � oæ thå informatioî ió thió directorù caî CP/Í accesó � thå resô oæ thå datá oî thå disk® Iæ anythinç werå tï � happeî tï thå directory¬ oò iæ iô werå tï havå � incorrecô informatioî iî iô somå oò alì oæ thå files¬ � oò theiò data¬ oî thå disë coulä becomå inaccessible® � Therå arå severaì wayó iî whicè thió kinä oæ disasteò � coulä happen® Sometimeó thå directorù caî bå � accidentalù overwritten¬ perhapó bù á disë drivå � malfunctioî oò bù accidentallù writinç oî thå disë witè � á non-Morro÷ computeò (I'vå haä botè happen)® Or¬ aî � abnormaì terminatioî iî thå midsô oæ á disë writå � operatioî caî prevenô thå directorù froí beinç properlù � updated¬ anä thå datá maù noô bå easù tï recreate¬ � especiallù iæ iô haó jusô beeî reaä iî oveò á modem¬ oò � just entered at the keyboard. Iô ió possiblå tï recoveò froí thió kind oæ error¬ � however¬ bù writinç directlù tï thå directory® Buô iæ � anù changeó arå goinç tï bå madå iî thå CP/Í disë � directory¬ iô ió firsô necessarù tï kno÷ ho÷ iô ió � organized® Unfortunately¬ thå CP/Í 2.² Operatinç � Systeí Useò Referencå Manual“ whicè comeó bundleä witè � thå Morro÷ systeí ió nï helð here® Iô discusseó thå � function“ oæ thå directorù (pp.89-12° iî mù version)¬ � buô iô doeó noô discusó ho÷ thå informatioî iî thå � directorù ió actuallù organized® Á littlå biô oæ � investigation¬ however¬ answers this question. Iô no÷ mighô bå stresseä thaô anù alterationó iî � thå directorù requirå thå uså oæ á utilitù (sucè aó DU-� 77© whicè wilì allo÷ thå useò tï accesó specifiã � groups¬ tracks¬ anä sectoró oî thå disk¬ anä botè tï � reaä froí anä writå upoî them® Becauså thå useò haó � completå controì oveò exactlù whaô bytå valueó arå � written¬ anä exactlù wherå theù arå written¬ thió kinä � oæ utilitù ió noô aó dangerouó aó iô maù sound! Thå µ 1/´ incè single-sideä doublå densitù floppù �Šdiskó contaiî 200Ë byteó oî 4° trackó (numbereä ° � througè 39)¬ oò 5Ë byteó peò track® Thå physicaì � trackó arå divideä intï µ 1024-bytå physicaì "sofô � sectors.¢ Oî mù computer¬ á Morro÷ MÄ ² (ROÍ revisioî � 2.3A)¬ thå firsô twï trackó (0-1© arå reserveä foò thå � CP/Í systemº CP/Í wilì noô normallù writå datá there® � Thå CP/Í system¬ however¬ accesseó thå disë bù logicaì � "sectors¢ anä "groups,¢ ratheò thaî bù physicaì trackó � anä sectors® Iô divideó thå disë intï logicaì � "sectors¢ oæ 12¸ byteó eacè (thå lengtè oæ thå standarä � CP/Í "record")¬ anä logicaì "groups¢ oæ 1¶ logicaì � recordó (thereforå eacè "group¢ containó 12¸ Ø 1¶ ½ � 204¸ oò 2Ë bytes)® Thå 3¸ user-accessiblå physicaì � tracks¬ therefore¬ arå divideä uð intï 9´ logicaì � groupó (188Ë bytes)¬ whicè begiî witè grouð 00¬ whicè � itselæ beginó aô thå beginninç oæ tracë ² (thaô is¬ aô � tracë 2¬ sectoò 1)® Thió explainó whù thå useò cannoô � uså CP/Í tï accesó trackó 0-1¬ foò theù arå "hidden¢ � belo÷ grouð 00® Whicè bringó uó tï thå directoryº iô ió locateä aô � thå beginninç oæ grouð 00¬ thaô ió aô thå beginninç oæ � tracë ² (beaò iî minä thaô thå numberinç oæ thå trackó � anä groupó beginó witè "0,¢ whereaó thaô oæ thå sectoró � beginó witè "1")® Groupó 0° anä 0± arå reserveä foò � thå directory» thå datá beginó witè grouð 0² (physicaì � tracë 2¬ logicaì sectoò 33)® Becauså therå ió nï � obviouó correlatioî betweeî thå logicaì groupó anä thå � physicaì trackó (groupó anä trackó overlap¬ thaô is¬ � somå groupó liå oî twï contiguouó tracks)¬ anä becauså � CP/Í workó witè thå groups¬ thå followinç discussioî � wilì bå writteî froí thå poinô oæ vie÷ oæ thå "groups,¢ � anä thå 128-bytå logicaì sectoró containeä withiî them. Notå too¬ thaô alì referenceó tï "sectors¢ refeò tï thå � 128-byte logical sectors¬ noô tï thå 1024-bytå physicaì � soft sectors. Thå besô waù tï learî tï worë witè thå CP/Í � directorù ió tï bå ablå tï looë righô aô it¬ buô � failinç that¬ thió ió ho÷ thå individuaì entrieó iî thå � ÃP/Í directorù arå seô uð (thió ió ho÷ thå firsô entrù � mighô appeaò wheî printeä bù DU-77): 00 NN NN NN NN NN NN NN NN EE EE EE LL LL LL LL GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG Thå firsô bytå iî thå entrù (bytå 00¬ valuå 00© haó thå � valuå 00È iæ thå filå ió active¬ thå valuå E5È iæ thå � filå haó beeî deleted® Thió explainó ho÷ á filå caî bå � "undeleted¢ (presuminç iô haó noô yeô beeî writteî � over)º jusô changå thå Eµ bacë tï á 00® Thå byteó listeä aó "NN¢ (byteó 0± througè 08© � includå thå heø valueó oæ thå namå oæ thå filå (8-�Šcharacteò maximum)¬ anä thå "TT¢ byteó (3-characteò � maximum© contaiî thå heø valueó oæ thå filå extension® � Blankó arå representeä bù heø blankó (20H)¬ anä therå � ió nï perioä betweeî thå namå anä thå extension® � Knowinç thió alsï caî bå useful® Foò CP/Í wilì allo÷ � somå kindó oæ softwarå tï creatå á filå witè lower-caså � letteró iî thå name¬ buô iô wilì noô allo÷ sucè á filå � tï bå accesseä bù á CP/Í routine¬ sucè aó PIÐ oò eveî � REN® Iô caî bå verù frustratinç tï discoveò thaô onå � haó inadvertentlù createä á valuablå filå witè lower-� caså letteró iî thå name¬ anä theî noô bå ablå tï � accesó it® TÏ correcô thå error¬ alì onå neeä dï ió tï � writå thå namå iî uppeò caså directlù tï thå CP/Í � directory. Thå "LL¢ valueó givå thå numbeò oæ CP/Í recordó � (thaô is¬ thå numbeò oæ 128-bytå logicaì sectors© iî � thå file¬ anä arå calculateä aó followsº Thå firsô "LL¢ � (presumablù iî hex¬ buô I'vå neveò haä á filå largå � enougè tï finä out© ió multiplieä bù 128¬ anä ió addeä � tï thå numbeò (giveî iî hex© iî thå fourtè "LL.¢ � Presumably¬ thå seconä anä thirä "LL"ó arå useä foò � verù largå files¬ buô undeò ordinarù circumstanceó � theiò valuå remainó 00H® Thå totaì numbeò oæ byteó oæ � disë storagå useä foò thå filå caî thereforå bå calculateä � by multiplying the sum of the "LL" values by 128. Thå "GG¢ valueó arå thå mosô important¬ foò theù � telì CP/Í whicè groupó thå datá iî anù filå arå storeä � in® Now¬ foò á newly-writteî filå oî á freshly- � formatteä disk¬ thå "GG¢ valueó shoulä reaä 0² 0³ 0´ 0µ � 0¶ anä sï oî (unuseä "GG"ó reaä 00)® Notå thaô everù � grouð thaô containó datá foò thió filå musô bå citeä iî � thå directory¬ anä theså groupó musô bå listeä iî thå � ordeò iî whicè theiò datá appear® Thå groupó neeä not¬ � however¬ bå allocateä bù CP/Í iî sequential¬ oò eveî � ascending¬ order® Thió explainó ho÷ CP/Í caî "find¢ � alì thå partó oæ á file¬ eveî wheî iô ió scattereä alì � oveò thå disk® Iô alsï explainó ho÷ CP/Í knowó whicè � groupó arå availablå foò datá storageº alì oæ thoså � groupó not“ listeä aó containinç datá foò aî activå � file® Notå thaô eacè directorù entrù containó 3² bytes¬ � witè 1¶ oæ theí useä foò thå grouð numbers» iæ á filå � requireó morå thaî 1¶ groups¬ CP/Í merelù writeó � anotheò entrù iî thå directorù foò thió fileº thió � explainó thå "EXT¢ entrù wheî onå doeó á "DIR"¬ foò thå � numbeò herå ió thå numbeò oæ entrieó iî thå directorù � (noô thaô onå eveò haó mucè uså foò it!)® Notå alsï � thaô wheî CP/Í writeó aî additionaì entrù foò á file¬ � onlù thå valueó oæ "LL¢ iî thå final“ entrù arå valid» � thoså iî earlieò entrieó merelù reflecô thå numbeò oæ � CP/M recordó iî thoså entries® Š Thió explanatioî alsï indicateó whù á numbeò oæ � smalì fileó caî eaô uð lotó oæ disë space¬ foò thå � smallesô uniô thaô CP/Í caî allocatå ió onå grouð (2K)¬ � sï á filå oæ eveî onå linå wilì uså uð 2Ë oæ storagå � (dï á DIÒ oæ á disë witè severaì fileó oæ varyinç � lengthº eveî thå smallesô wilì havå 2K¬ anä alì thå � numberó wilì bå even¬ foò CP/Í arriveó aô thå amounô � simplù bù multiplyinç thå numbeò oæ groupó useä foò � storagå bù two). Armeä witè thió knowledge¬ thå adventurouó useò � no÷ caî attacë á mangleä directory® Thå filå namå anä � extensioî caî bå writteî iî easilù enough¬ anä � calculationó wilì yielä thå nunbeò oæ CP/Í records¬ � whicè alsï caî bå entereä (thougè É havå noô founä á � neeä foò greaô accuracù here)® Thå tougè parô caî bå � iî insertinç thå "GG¢ values® Foò COÍ files¬ thió caî � onlù bå donå iæ onå caî reasonablù assumå thaô thå filå � waó storeä iî sequential¬ ascendinç groups® Foò ASCIÉ datá fileó thå tasë ió relativelù � easier® Simplù uså thå DU-7· (oò whatever© searcè � commanä ("=¢ iî DU-77© tï finä thå locatioî oæ thå � beginninç oæ thå fileº notå dowî thå grouð numbeò (iô � wilì bå xx.0°--herå thå sectoò numberó begiî witè � "00"!--¬ foò alì fileó starô aô thå beginninç oæ á � group)¬ anä enteò iô intï thå firsô bytå iî thå second“ � linå oæ thå directorù (aó above)® Theî hopå thaô thå � nexô grouð containó thå nexô sectioî oæ youò datá file» � iæ so¬ enteò thå grouð numbeò iî thå samå way® Iæ not¬ � iô wilì bå necessarù tï pagå bacë tï thå lasô sectoò oæ � thå previouó grouð tï seå wherå thå filå leaveó off¬ � anä theî uså thå searcè commanä tï finä thå nexô part® � Continuå iî thió manneò untiì alì thå groupó containinç � datá foò thió filå havå beeî entereä intï thå � directory® Anä dï not“ forgeô tï writå youò completeä � directorù ontï thå diskº yoõ wilì bå verù frustrateä iæ � yoõ do® Thió procedurå neeä noô bå donå foò everù filå � oî thå disk¬ onlù foò thå mosô importanô ones. Thió methoä alsï caî bå useä foò thoså rarå � occasionó wheî CP/Í recordó datá oî thå wronç � group/trackº tï correcô this¬ onå neeä onlù enteò thå � valuå oæ thå correcô grouð iî thå appropriatå locatioî � iî thå directory® Thió caî bå especiallù usefuì foò � largå fileó wheî thå erroò occuró neaò thå beginninç oæ � thå file. Therå ió alsï anotheò uså foò thió methoä whicè � thå morå adventuresomå readeró mighô wisè tï tryº � rewritinç á directorù oî CP/Í diskó writteî bù non-� Morro÷ computeró (includinç CP/Í 86)¬ buô whicè cannoô � bå reaä usinç IBM.COM¬ OSB.COM¬ oò XER.COM® Firsô oæ � all¬ trù thå DIÒ commanä usinç theså variouó formats® � Iæ yoõ geô á reaä error¬ forgeô it® Buô iæ iô comeó �Šbacë simplù "NOÔ FOUND¢ wheî yoõ kno÷ there'ó somethinç � ouô there¬ you'rå iî business® No÷ trù thå STAÔ *.ª � command® Thió mighô aô leasô lisô thå nameó oæ thå � fileó ouô there® Thå nexô thinç tï dï ió tï � experimentº witè thå disë iî questioî iî thå Bº drive¬ � executå DU-7· (oò whatever© iî thå Aº drivå anä looë � arounä youò disk® Yoõ maù finä (aó É have© thaô thå � directorù waó jusô writteî iî thå wronç place¬ oò thaô � thå wronç numberó werå inserteä foò thå "GG¢ values® � Trù movinç thå directorù around¬ anä everù sï ofteî trù � thå DIÒ commanä again® Whï knows¬ yoõ mighô geô lucky® � Anä iî á pinch¬ yoõ caî alwayó copù thå entirå disk¬ oò � aô leasô relevanô parts¬ sectoò bù sectoò tï á Morro÷ � formatteä disk¬ foò whicè yoõ alsï wilì havå tï creatå � youò owî directorù entry® But¬ again¬ yoõ mighô noô � wanô tï trù thió unlesó yoõ havå nï otheò waù oæ eveò � beinç ablå tï reaä thå foreigî disë undeò itó propeò � format.