Fixed bug - fixes to dir header were not written to disk

This commit is contained in:
Bobbi Webber-Manners 2020-03-01 15:27:52 -05:00
parent 99612e4801
commit bc50613dda

View File

@ -880,9 +880,9 @@ int readdir(uint device, uint blocknum) {
printf(" %s)\n", filecount == 1 ? "entry" : "entries"); printf(" %s)\n", filecount == 1 ? "entry" : "entries");
hline(); hline();
/* Copy pointers and header to sorteddata[], zero the rest */ /* Copy pointers to sorteddata[], zero the rest */
bzero(curblk->sorteddata, BLKSZ); bzero(curblk->sorteddata, BLKSZ);
memcpy(curblk->sorteddata, curblk->data, PTRSZ + entsz); memcpy(curblk->sorteddata, curblk->data, PTRSZ);
#ifdef CHECK #ifdef CHECK
if (entsz != 0x27) { if (entsz != 0x27) {
@ -1420,6 +1420,7 @@ void copyent(uint srcblk, uint srcent, uint dstblk, uint dstent, uint device) {
* blocks. Note that the block and entry numbers are 1-based indices. * blocks. Note that the block and entry numbers are 1-based indices.
*/ */
void sortblocks(uint device) { void sortblocks(uint device) {
copyent(1, 1, 1, 1, device); /* Copy directory header */
uchar destblk = 1; uchar destblk = 1;
uchar destentry = 2; /* Skip header on first block */ uchar destentry = 2; /* Skip header on first block */
for(uint i=0; i<numfiles; ++i) { for(uint i=0; i<numfiles; ++i) {
@ -1520,7 +1521,7 @@ void processdir(uint device, uint blocknum) {
if (doverbose) { if (doverbose) {
printlist(); printlist();
} }
if (errs) { if ((strlen(fixopts) == 0) && errs) {
printf("Error scanning directory, will not sort\n"); printf("Error scanning directory, will not sort\n");
goto done; goto done;
} }
@ -1537,9 +1538,11 @@ void processdir(uint device, uint blocknum) {
puts("After sorting ..."); puts("After sorting ...");
printlist(); printlist();
} }
if (dowrite) if (dowrite) {
hline();
puts("Writing modified directory to disk");
errs = writedir(device); errs = writedir(device);
else if (doverbose) } else
puts("Not writing to disk without -w"); puts("Not writing to disk without -w");
} }
done: done: