summaryrefslogtreecommitdiff
path: root/sys/src/cmd/disk
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-07-14 22:33:27 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2015-07-14 22:33:27 +0200
commit90bd02d5af84eaaffe5adb1a175c8fbb2295a7e4 (patch)
tree061d4867c3b8f376169ce4beb8d0b6bfeb596fff /sys/src/cmd/disk
parent2e85e328864c215c2efa228f129ce3fa6aa1db1f (diff)
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.
Diffstat (limited to 'sys/src/cmd/disk')
-rw-r--r--sys/src/cmd/disk/9660/write.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sys/src/cmd/disk/9660/write.c b/sys/src/cmd/disk/9660/write.c
index e45f21c19..263e803c9 100644
--- a/sys/src/cmd/disk/9660/write.c
+++ b/sys/src/cmd/disk/9660/write.c
@@ -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;