mk9660: write data in alphabetical order

*after* writing, the directory tree gets alphabetically sorted for
path table. this causes data to not be in the same order as it was
written causing seeks when taring up the filesystem.

so instead write the files in alphabetical order as well to better
match the directory sorting.
This commit is contained in:
cinap_lenrek 2015-07-14 22:33:27 +02:00
parent 2e85e32886
commit 90bd02d5af

View file

@ -53,6 +53,16 @@ rewritedotdot(Cdimg *cd, Direc *d, Direc *dparent)
Cwrite(cd, buf, Blocksize);
}
static int
alphacmp(void *va, void *vb)
{
Direc *a, *b;
a = va;
b = vb;
return strcmp(a->name, b->name);
}
/*
* Write each non-directory file. We copy the file to
* the cd image, and then if it turns out that we've
@ -72,6 +82,9 @@ writefiles(Dump *d, Cdimg *cd, Direc *direc)
Dumpdir *dd;
if(direc->mode & DMDIR) {
/* write data in alphabetical order avoiding seeks */
qsort(direc->child, direc->nchild, sizeof(direc->child[0]), alphacmp);
for(i=0; i<direc->nchild; i++)
writefiles(d, cd, &direc->child[i]);
return;