Handle getdir entries in order passed. Currently they are handed to the
authorDerrik Pates <demon@now.ai>
Wed, 18 May 2011 15:58:51 +0000 (09:58 -0600)
committerDerrik Pates <demon@now.ai>
Wed, 18 May 2011 15:58:51 +0000 (09:58 -0600)
filler call in reverse order; this is kind of a pain in the butt.

Fuse.xs

diff --git a/Fuse.xs b/Fuse.xs
index 38fa85d..45d718b 100755 (executable)
--- a/Fuse.xs
+++ b/Fuse.xs
@@ -225,6 +225,7 @@ int _PLfuse_readdir(const char *file, void *dirh, fuse_fill_dir_t dirfil, off_t
 
 int _PLfuse_getdir(const char *file, fuse_dirh_t dirh, fuse_dirfil_t dirfil) {
        int prv, rv;
+       SV **swp;
        FUSE_CONTEXT_PRE;
        DEBUGf("getdir begin\n");
        ENTER;
@@ -235,9 +236,14 @@ int _PLfuse_getdir(const char *file, fuse_dirh_t dirh, fuse_dirfil_t dirfil) {
        prv = call_sv(MY_CXT.callback[2],G_ARRAY);
        SPAGAIN;
        if(prv) {
+               /* Should yield the bottom of the current stack... */
+               swp = &TOPs - prv + 1;
                rv = POPi;
-               while(--prv)
-                       dirfil(dirh,POPp,0,0);
+               /* Sort of a hack to walk the stack in order, instead of reverse
+                * order - trying to explain to potential users why they need to
+                * reverse the order of this array would be confusing, at best. */
+               while (swp <= &TOPs)
+                       dirfil(dirh,SvPVx_nolen(*(swp++)),0,0);
        } else {
                fprintf(stderr,"getdir() handler returned nothing!\n");
                rv = -ENOSYS;