#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <errno.h>
#include "udanax.h"
Include dependency graph for disk.cxx:

Go to the source code of this file.
Functions | |
| int | findnumberofdamnsons (typediskloafptr diskptr) |
| ??? | |
| int | changeunterrefcount (typediskloaf *wholeloafp, char *originalloafp, int delta) |
| ??? | |
| int | changerefcount (typediskloafptr diskptr, int delta) |
| ??? | |
| void | readloaf (typediskloaf *loafptr, typediskloafptr diskptr) |
| ??? | |
| void | actuallyreadrawloaf (typeuberrawdiskloaf *loafptr, int blocknumber) |
| ??? | |
| void | writeloaf (typediskloaf *loafptr, typediskloafptr diskptr, int newloaf) |
| ??? | |
| void | actuallywriteloaf (typeuberrawdiskloaf *loafptr, int diskblocknumber) |
| ??? | |
| bool | initenffile (const char *filename) |
| ??? | |
| void | closediskfile () |
| ??? | |
Variables | |
| int | nolread = 0 |
| int | nolwrote = 0 |
| int | enffiledes |
| bool | enffileread |
(to be defined)
Definition in file disk.cxx.
|
||||||||||||
|
??? (to be defined) Definition at line 279 of file disk.cxx. References assert, DISKPTRNULL, dumpsubtree(), enffiledes, enffileread, goodblock(), L, nolread, and NUMBYTESINLOAF. Referenced by actuallyreadrawloaffromhash(), changerefcount(), findnumberofdamnsons(), partialdiskalloc(), readloaf(), readpartialdiskalloctablefromdisk(), and writeloaf().
00282 {
00283 /* L("entering actuallyreadloaf diskblocknumber = %d\n",blocknumber); */
00284 if (!loafptr || blocknumber == DISKPTRNULL) {
00285 #ifndef DISTRIBUTION
00286 L("loafptr = %d\n", blocknumber);
00287 if (loafptr)
00288 dumpsubtree((typecuc *) loafptr);
00289 assert(0); // bad readloaf call
00290 #else
00291 assert(0); // bad call
00292 #endif
00293 }
00294
00295 if (!enffileread) {
00296 if (close(enffiledes) != 0)
00297 perror("close failed in readloaf");
00298
00299 if ((enffiledes = open("enf.enf", O_RDWR, 0)) == -1) {
00300 perror("open");
00301 assert(0); // open
00302 }
00303 enffileread = true;
00304 }
00305
00306 if (!goodblock(blocknumber)) {
00307 #ifndef DISTRIBUTION
00308 L("loaf = %x\n", blocknumber);
00309 L("unallocated block in readloaf.\n");
00310 #endif
00311 abort();
00312 }
00313
00314 if (lseek(enffiledes, (long)blocknumber * NUMBYTESINLOAF, 0) < 0) {
00315 #ifndef DISTRIBUTION
00316 perror("lseek in readloaf");
00317 #endif
00318 assert(0); // lseek failed
00319 }
00320
00321 int nbytes = read(enffiledes, (char *) loafptr, sizeof(*loafptr));
00322 assert(nbytes > 0); // Incorrect Usage of Assertion
00323
00324 // dumphexstuff(loafptr);
00325 // if ((int) loafptr->xdbcloaf.xdbchedr.refcount < 0) {
00326 // assert(0); // readloaf read a loaf with refcount < 0
00327 // }
00328 ++nolread;
00329
00330 // return true;
00331 }
|
|
||||||||||||
|
??? (to be defined) Definition at line 410 of file disk.cxx. References assert, DISKPTRNULL, enffiledes, goodblock(), nolwrote, and NUMBYTESINLOAF. Referenced by changerefcount(), savepartialdiskalloctabletodisk(), and writeloaf().
00414 {
00415 if (!loafptr || diskblocknumber == DISKPTRNULL /* || (int) loafptr->xdbcloaf.xdbchedr.refcount < 0 */ )
00416 assert(0); // bad call
00417
00418 assert(goodblock(diskblocknumber)); // ERROR: unallocated block
00419
00420 if (lseek(enffiledes, (long)diskblocknumber * NUMBYTESINLOAF, 0) < 0) {
00421 perror("lseek");
00422 assert(0); // lseek failed
00423 }
00424
00425 int nbytes = write(enffiledes, (char *)loafptr, sizeof(*loafptr));
00426 assert(nbytes >= 0); // Incorrect Usage of Assert
00427
00428 ++nolwrote;
00429 }
|
|
||||||||||||
|
??? (to be defined) Definition at line 221 of file disk.cxx. References actuallyreadrawloaf(), actuallywriteloaf(), assert, changeunterrefcount(), typediskloafptr::diskblocknumber, diskfree(), DISKPTRNULL, findinsideloaf(), typediskloafptr::insidediskblocknumber, and numberofliveunterloafs(). Referenced by deletewithgarbageddescendents(), orglwritepart2(), and subtreewriterecurs().
00224 {
00225 if (diskptr.diskblocknumber == DISKPTRNULL)
00226 assert(0); // null diskptr in changerefcount
00227
00228 typeuberrawdiskloaf loaf;
00229 actuallyreadrawloaf(&loaf, diskptr.diskblocknumber);
00230
00231 char *loafp = findinsideloaf((typeuberdiskloaf *) &loaf, diskptr.insidediskblocknumber);
00232 int refcount = changeunterrefcount((typediskloaf *) &loaf, loafp, delta);
00233 int numberofunterloafs = numberofliveunterloafs((typeuberdiskloaf *) &loaf);
00234
00235 if (refcount > 0 && numberofunterloafs > 0)
00236 actuallywriteloaf( /* sizeof(typediskloaf), */ &loaf, diskptr.diskblocknumber);
00237 else
00238 diskfree(diskptr.diskblocknumber);
00239
00240 return refcount;
00241 }
|
|
||||||||||||||||
|
??? (to be defined) Definition at line 142 of file disk.cxx. References foo(), hgetfromloaf(), humber, humber3put(), humberput(), intlengthoflength(), and movmem. Referenced by changerefcount().
00146 {
00147 int ret;
00148 int numberofsons;
00149 char *loafp;
00150 int height, enftype;
00151 int isapex;
00152 unsigned int refcount;
00153 int foo;
00154 unsigned int oldlength, newlength, dummylength, dummy;
00155 int lengthdif;
00156 int size;
00157 char *refcountloafp;
00158
00159 loafp = (char *)originalloafp;
00160 /* loafp += 3; */
00161 hgetfromloaf(&size, loafp);
00162 hgetfromloaf(&isapex, loafp);
00163 // if (isapex) { assert(0); /* attempt to read apex in chengerefcount */); }
00164 hgetfromloaf(&height, loafp);
00165 hgetfromloaf(&enftype, loafp);
00166 hgetfromloaf(&numberofsons, loafp);
00167 refcountloafp = loafp;
00168 hgetfromloaf((int *) &refcount, loafp);
00169 foo = loafp - (char *)wholeloafp;
00170
00171 oldlength = intlengthoflength(refcount);
00172 refcount += delta;
00173 ret = refcount;
00174 newlength = intlengthoflength(refcount);
00175 /* L("changeunterrefcount A \n"); */
00176 if ((int) refcount > 0) {
00177 /* L("changeunterrefcount B \n"); */
00178 if (oldlength == newlength) {
00179 /* (void)humberput(refcount, loafp-oldlength, &dummylength); */
00180 } else {
00181 /* L("changeunterrefcount C \n"); */
00182 /* L("changeunterrefcoun bt oldlength = %d newlength = %d\n",oldlength,newlength); */
00183 lengthdif = newlength - oldlength;
00184 if (newlength > oldlength) {
00185 /* L("changeunterrefcount D \n"); */
00186 movmem(loafp, loafp - oldlength + newlength, sizeof(typeuberrawdiskloaf) - foo - newlength);
00187 } else if (newlength > oldlength) {
00188 /* L("changeunterrefcount E \n"); */
00189 movmem(loafp, loafp - oldlength + newlength, sizeof(typeuberrawdiskloaf) - foo - oldlength);
00190 }
00191 /* L("changeunterrefcount F \n"); */
00192 size = size + oldlength - newlength;
00193 (void)humber3put(size, (humber) originalloafp, &dummy);
00194 /* L("changeunterrefcount G \n"); */
00195 }
00196 /* L("changeunterrefcount H \n"); */
00197
00198 (void)humberput((int) refcount, (humber) refcountloafp /*-oldlength*/ , &dummylength);
00199 /* L("changeunterrefcount I \n"); */
00200 /* dumphexstuff(originalloafp); */
00201 /* L("changeunterrefcount J \n"); */
00202 } else {
00203 /* L("changeunterrefcount K \n"); */
00204 movmem(originalloafp + size, originalloafp + 1, sizeof(typeuberrawdiskloaf) - foo - size + 3);
00205 /* L("changeunterrefcount L \n"); */
00206 *originalloafp = 1;
00207 /* diskfree (diskptr.diskblocknumber); */
00208 }
00209 /* L("leaving changeunterrefoount \n"); */
00210 return ret;
00211 }
|
|
|
??? (to be defined) Definition at line 480 of file disk.cxx. References assert, diskallocexit(), and enffiledes. Referenced by flagquitting(), indiskexit(), and main().
00481 {
00482 diskallocexit(enffiledes);
00483 if (close(enffiledes) != 0) {
00484 perror("close in closediskfile");
00485 assert(0); // close failed
00486 }
00487 }
|
|
|
??? (to be defined) Definition at line 105 of file disk.cxx. References actuallyreadrawloaf(), assert, typediskloafptr::diskblocknumber, DISKPTRNULL, findinsideloaf(), hgetfromloaf(), and typediskloafptr::insidediskblocknumber.
00107 {
00108 if (diskptr.diskblocknumber == DISKPTRNULL)
00109 assert(0); // null diskptr in changerefcount
00110
00111 typeuberrawdiskloaf loaf;
00112 actuallyreadrawloaf(&loaf, diskptr.diskblocknumber);
00113
00114 char *loafp = findinsideloaf((typeuberdiskloaf *) &loaf, diskptr.insidediskblocknumber);
00115
00116 int size;
00117 hgetfromloaf(&size, loafp);
00118
00119 int isapex;
00120 hgetfromloaf(&isapex, loafp);
00121
00122 int height;
00123 hgetfromloaf(&height, loafp);
00124
00125 int enftype;
00126 hgetfromloaf(&enftype, loafp);
00127
00128 int numberofsons;
00129 hgetfromloaf(&numberofsons, loafp);
00130
00131 return numberofsons;
00132 }
|
|
|
??? (to be defined) Definition at line 439 of file disk.cxx. References assert, enffiledes, enffileread, errno, initheader(), initincorealloctables(), readallocinfo(), and writeallocinfo(). Referenced by initsession().
00441 {
00442 // static long times = 0;
00443 // assert(times == 0); // too many inits
00444 // ++times;
00445
00446 initincorealloctables();
00447 bool ret = true;
00448
00449 int fd = open(filename, O_RDWR, 0);
00450 if (fd == -1) {
00451 errno = 0;
00452 if ((fd = creat(filename, 0660)) == -1) {
00453 perror("initenffile");
00454 assert(0); // cant open enf.enf or creatit
00455 }
00456 initheader();
00457 enffileread = false;
00458 ret = false;
00459
00460 } else {
00461 ret = readallocinfo(fd);
00462 enffileread = true;
00463 }
00464
00465 if (!ret)
00466 writeallocinfo(fd);
00467
00468 enffiledes = fd;
00469 return ret;
00470 }
|
|
||||||||||||
|
??? (to be defined) Definition at line 252 of file disk.cxx. References actuallyreadrawloaf(), typediskloafptr::diskblocknumber, findinsideloaf(), humber, typediskloafptr::insidediskblocknumber, intof, and movmem. Referenced by inloaf(), and inorglinternal().
00255 {
00256 typeuberrawdiskloaf uberrawloaf;
00257 humber temp;
00258
00259 /* L("entering readloaf diskblocknumber = %d insdiediskblocknumber =
00260 * %d\n",diskptr.diskblocknumber,diskptr.insidediskblocknumber); */
00261 actuallyreadrawloaf(&uberrawloaf, diskptr.diskblocknumber);
00262 /* L("in readloaf dumping loaf\n"); */
00263 /* dumphexstuff(&uberrawloaf); */
00264 temp = (humber) findinsideloaf((typeuberdiskloaf *) & uberrawloaf, diskptr.insidediskblocknumber);
00265 if (!temp) {
00266 temp = (humber) (((char *)&uberrawloaf) + 6);
00267 }
00268 movmem(temp, loafptr, intof(temp)); /* humber at temp is length of loaf */
00269 }
|
|
||||||||||||||||
|
??? (to be defined) Definition at line 342 of file disk.cxx. References actuallyreadrawloaf(), actuallywriteloaf(), assert, typediskloafptr::diskblocknumber, findinsideloaf(), humber, typediskloafptr::insidediskblocknumber, intof, movmem, typeuberdiskloaf::numberofunterloafs, SIZEOFUBERDISKHEADER, and typeuberdiskloaf::versiondisknumber. Referenced by deletefullcrumandgarbageddescendents(), orglwritepart2(), and uniqueoutloaf().
00346 {
00347 /* typeuberdiskloaf loaf; */
00348 typeuberrawdiskloaf loaf;
00349 char *temp;
00350 char *last, *end;
00351 int s;
00352 short loaftemp;
00353
00354 /* L("entering writeloaf newloaf flag = %d diskblocknumber = %d insdiediskblocknumber =
00355 * %d\n",newloaf,diskptr.diskblocknumber,diskptr.insidediskblocknumber); */
00356 if (diskptr.insidediskblocknumber > 100) {
00357 #ifndef DISTRIBUTION
00358 assert(0); // in write laof large diskblocknumber
00359 #else
00360 assert(0); // bad
00361 #endif
00362 }
00363 /* dumphexstuff(loafptr); */
00364 (void)intof((humber) loafptr); /* test it to see if it starts with length */
00365
00366 /* test diskalloc if alloced read in else do as old version */
00367
00368 if (!newloaf) {
00369 /* L("writeloaf 1\n"); */
00370 actuallyreadrawloaf(&loaf, diskptr.diskblocknumber);
00371 /* dumphexstuff(&loaf); */
00372 /* L("writeloaf 2\n"); */
00373 temp = findinsideloaf((typeuberdiskloaf *) & loaf, diskptr.insidediskblocknumber);
00374 /* L("numberofunterloafs = %d\n",loaf.xuberdiskloaf.numberofunterloafs); */
00375 if (diskptr.insidediskblocknumber == loaf.xuberdiskloaf.numberofunterloafs) {
00376 end = temp + intof((humber) temp);
00377 } else {
00378 last = findinsideloaf((typeuberdiskloaf *) & loaf, (int) ntohs(loaf.xuberdiskloaf.numberofunterloafs) - 1);
00379 /* dumphexstuff(last); */
00380 /* L("last = %x\n",last); */
00381 end = last + intof((humber) last);
00382 }
00383 s = sizeof(typeuberrawdiskloaf) - (end - (char *)&loaf) - SIZEOFUBERDISKHEADER;
00384 /* L("s = %d\n",s); */
00385 movmem(loafptr, /* ((char*)&loaf)+6 */ temp, s);
00386 loaf.xuberdiskloaf.versiondisknumber = 1;
00387 loaftemp = ntohs(loaf.xuberdiskloaf.numberofunterloafs) + 1;
00388 loaf.xuberdiskloaf.numberofunterloafs = htons(loaftemp);
00389 } else {
00390 /* L("writeloaf A\n"); */
00391 movmem(loafptr, ((char *)&loaf) + 6, sizeof(typeuberrawdiskloaf) - SIZEOFUBERDISKHEADER);
00392 /* L("writeloaf B\n"); */
00393 loaf.xuberdiskloaf.versiondisknumber = htonl(1);
00394 loaf.xuberdiskloaf.numberofunterloafs = htons(1);
00395
00396 }
00397 /* dumphexstuff(&loaf); */
00398 actuallywriteloaf( /* size, */ &loaf, diskptr.diskblocknumber);
00399 /* L("leaving wrietloaf\n"); */
00400 }
|
|
|
Definition at line 94 of file disk.cxx. Referenced by actuallyreadrawloaf(), actuallywriteloaf(), closediskfile(), initenffile(), and readallocinfo(). |
|
|
Definition at line 95 of file disk.cxx. Referenced by actuallyreadrawloaf(), and initenffile(). |
|
|
Definition at line 91 of file disk.cxx. Referenced by actuallyreadrawloaf(), and ioinfo(). |
|
|
Definition at line 92 of file disk.cxx. Referenced by actuallywriteloaf(). |
1.3.4