ref: 72d25b9b6718ab571488c49e2bbbd3f860c97b61
parent: 5c36cb5e53a0529d72d85961b070b50b01a26699
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Jul 14 18:33:27 EDT 2015
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.
--- a/sys/src/cmd/disk/9660/write.c
+++ b/sys/src/cmd/disk/9660/write.c
@@ -53,6 +53,16 @@
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 @@
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;
--
⑨